Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: no name for expr |a| #67634

Closed
jsartisohn opened this issue Dec 26, 2019 · 2 comments · Fixed by #67687
Closed

ICE: no name for expr |a| #67634

jsartisohn opened this issue Dec 26, 2019 · 2 comments · Fixed by #67687
Labels
A-borrow-checker Area: The borrow checker A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jsartisohn
Copy link

jsartisohn commented Dec 26, 2019

The compiler panics when referencing a captured variable inside a nested closure.

This happens on the playground nightly build "rustc 1.42.0-nightly (ed33453 2019-12-25) running on x86_64-unknown-linux-gnu" as well as MSVC stable "stable-x86_64-pc-windows-msvc updated - rustc 1.40.0 (73528e3 2019-12-16)".

This issue feels awfully related to #67252. But from what I gathered, its fix (#67289) went live a couple of days ago and should be in the playground version 1.42.0-nightly (ed33453 2019-12-25).

I tried this code (minimal-ish example):
https://gist.github.com/rust-play/362fc228ed152a41e5b216603e7c236f

fn main() {
    let _ = vec![0]
        .iter()
        .flat_map(|a| vec![0].iter().map(|_| &a))
        .collect::<Vec<_>>();
}

I expected to see this happen: No compiler errors or warnings and especially no crash.

Meta

rustc --version --verbose:
rustc 1.40.0 (73528e3 2019-12-16)
binary: rustc
commit-hash: 73528e3
commit-date: 2019-12-16
host: x86_64-pc-windows-msvc
release: 1.40.0
LLVM version: 9.0

Backtrace (from the playground):

Standard Error

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: src/librustc/hir/map/mod.rs:955: no name for expr |a| <[_]>::into_vec(box [0]).iter().map(|_| &a) (hir_id=HirId { owner: DefIndex(3), local_id: 40 })

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:895:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1057
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:195
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:215
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:476
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::hir::map::Map::name
  21: rustc_mir::borrow_check::diagnostics::conflict_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough
  22: rustc_mir::borrow_check::MirBorrowckCtxt::check_for_invalidation_at_exit
  23: rustc_mir::borrow_check::flows::Flows::with_outgoing_borrows
  24: <rustc_mir::borrow_check::MirBorrowckCtxt as rustc_mir::dataflow::DataflowResultsConsumer>::visit_terminator_entry
  25: rustc_mir::borrow_check::do_mir_borrowck
  26: rustc::ty::context::GlobalCtxt::enter_local
  27: rustc_mir::borrow_check::mir_borrowck
  28: rustc::ty::query::__query_compute::mir_borrowck
  29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  30: rustc::dep_graph::graph::DepGraph::with_task_impl
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  32: rustc_mir::borrow_check::type_check::TypeChecker::check_rvalue
  33: rustc_mir::borrow_check::type_check::TypeChecker::typeck_mir
  34: rustc_mir::borrow_check::type_check::type_check
  35: rustc_mir::borrow_check::nll::compute_regions
  36: rustc_mir::borrow_check::do_mir_borrowck
  37: rustc::ty::context::GlobalCtxt::enter_local
  38: rustc_mir::borrow_check::mir_borrowck
  39: rustc::ty::query::__query_compute::mir_borrowck
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  44: rustc_interface::passes::analysis
  45: rustc::ty::query::__query_compute::analysis
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  48: rustc::ty::context::tls::enter_global
  49: rustc_interface::interface::run_compiler_in_existing_thread_pool
  50: std::thread::local::LocalKey<T>::with
  51: scoped_tls::ScopedKey<T>::set
  52: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (ed33453a3 2019-12-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] processing `main::{{closure}}#0`
#1 [mir_borrowck] processing `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `playground`.

To learn more, run the command again with --verbose.
@Centril Centril added A-borrow-checker Area: The borrow checker A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 26, 2019
@Centril
Copy link
Contributor

Centril commented Dec 26, 2019

Reduced:

fn main() {
    [0].iter().flat_map(|a| [0].iter().map(|_| &a));
}

@matthewjasper
Copy link
Contributor

Assertion is from name when called here:

self.infcx.tcx.hir().name(fn_hir_id),

@estebank estebank added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Dec 28, 2019
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Dec 29, 2019
Do not ICE on lifetime error involving closures

Fix rust-lang#67634.
@bors bors closed this as completed in 3928ace Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants