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 in mir building with captured value of unresolved type, None in compiler/rustc_mir_build/src/build/expr/as_place.rs #110453

Closed
conradludgate opened this issue Apr 17, 2023 · 11 comments · Fixed by #122988
Labels
A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

@conradludgate
Copy link
Contributor

conradludgate commented Apr 17, 2023

Code

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1977129cfed4ad3641190eef3e6ebc97

mod a {
    use crate::B;
    pub fn a() -> B { B }
}
pub struct B;

mod handlers {
    use crate::a::{a, B};
    pub struct C(B);

    pub fn c() -> impl Fn() -> C {
        let a1 = ();
        || C((a(), a1).into())
    }
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (d0f204e4d 2023-04-16)
binary: rustc
commit-hash: d0f204e4d750b62f9d6c2593405e828757126832
commit-date: 2023-04-16
host: aarch64-apple-darwin
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error[E0603]: struct import `B` is private
  --> src/lib.rs:12:19
   |
12 |     use crate::a::B;
   |                   ^ private struct import
   |
note: the struct import `B` is defined here...
  --> src/lib.rs:2:9
   |
2  |     use crate::B;
   |         ^^^^^^^^
note: ...and refers to the struct `B` which is defined here
  --> src/lib.rs:8:1
   |
8  | pub struct B;
   | ^^^^^^^^^^^^^ consider importing it directly

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_mir_build/src/build/expr/as_place.rs:256:31

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.71.0-nightly (d0f204e4d 2023-04-16) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [mir_built] building MIR for `handlers::c::{closure#0}::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `handlers::c::{closure#0}::{closure#0}`
#2 [unsafety_check_result] unsafety-checking `handlers::c::{closure#0}`
#3 [unsafety_check_result] unsafety-checking `handlers::c`
#4 [mir_const] preparing `handlers::c` for borrow checking
#5 [mir_promoted] processing MIR for `handlers::c`
#6 [mir_borrowck] borrow-checking `handlers::c`
#7 [type_of] computing type of `handlers::c::{opaque#0}`
#8 [check_mod_item_types] checking item types in module `handlers`
#9 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0603`.
Backtrace

stack backtrace:
   0:        0x103491894 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbe6b2e192ca15116
   1:        0x1034e4988 - core::fmt::write::hd6a055451ad3f5fd
   2:        0x10348733c - std::io::Write::write_fmt::h3bd90167a87b98a7
   3:        0x1034916a8 - std::sys_common::backtrace::print::hc24f8cd977e05789
   4:        0x1034940bc - std::panicking::default_hook::{{closure}}::h86be795d87f6f599
   5:        0x103493e7c - std::panicking::default_hook::h33158989e4e670cd
   6:        0x10b98f898 - rustc_driver_impl[2b4a73ce5be55b2]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10349477c - std::panicking::rust_panic_with_hook::he1c4ce779ead934c
   8:        0x103494534 - std::panicking::begin_panic_handler::{{closure}}::h8107a332a0a8a016
   9:        0x103491cb4 - std::sys_common::backtrace::__rust_end_short_backtrace::hfd6621bf0e44821e
  10:        0x103494308 - _rust_begin_unwind
  11:        0x103510430 - core::panicking::panic_fmt::h68c357d89a917539
  12:        0x1035104a0 - core::panicking::panic::hb3c8208af4dcc4f1
  13:        0x10e69c964 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest
  14:        0x10e6999cc - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_temp_inner
  15:        0x10e6990d4 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_operand
  16:        0x10e699274 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_operand
  17:        0x10e6aa2ac - <alloc[f4f0542297ee9225]::vec::Vec<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand> as alloc[f4f0542297ee9225]::vec::spec_from_iter::SpecFromIter<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand, core[504f2899fffd0de7]::iter::adapters::map::Map<core[504f2899fffd0de7]::iter::adapters::copied::Copied<core[504f2899fffd0de7]::slice::iter::Iter<rustc_middle[9da08aa6ecd6d5c0]::thir::ExprId>>, <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_rvalue::{closure#3}>>>::from_iter
  18:        0x10e689e78 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_rvalue
  19:        0x10e699c18 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest
  20:        0x10e6999cc - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_temp_inner
  21:        0x10e6990d4 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_operand
  22:        0x10e687b28 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_call_operand
  23:        0x10e687ca8 - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::as_call_operand
  24:        0x10e6cea24 - <core[504f2899fffd0de7]::iter::adapters::copied::Copied<core[504f2899fffd0de7]::slice::iter::Iter<rustc_middle[9da08aa6ecd6d5c0]::thir::ExprId>> as core[504f2899fffd0de7]::iter::traits::iterator::Iterator>::fold::<(), core[504f2899fffd0de7]::iter::adapters::map::map_fold<rustc_middle[9da08aa6ecd6d5c0]::thir::ExprId, rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand, (), <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#3}, core[504f2899fffd0de7]::iter::traits::iterator::Iterator::for_each::call<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand, <alloc[f4f0542297ee9225]::vec::Vec<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand>>::extend_trusted<core[504f2899fffd0de7]::iter::adapters::map::Map<core[504f2899fffd0de7]::iter::adapters::copied::Copied<core[504f2899fffd0de7]::slice::iter::Iter<rustc_middle[9da08aa6ecd6d5c0]::thir::ExprId>>, <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#3}>>::{closure#0}>::{closure#0}>::{closure#0}>
  25:        0x10e6a9ffc - <alloc[f4f0542297ee9225]::vec::Vec<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand> as alloc[f4f0542297ee9225]::vec::spec_from_iter::SpecFromIter<rustc_middle[9da08aa6ecd6d5c0]::mir::syntax::Operand, core[504f2899fffd0de7]::iter::adapters::map::Map<core[504f2899fffd0de7]::iter::adapters::copied::Copied<core[504f2899fffd0de7]::slice::iter::Iter<rustc_middle[9da08aa6ecd6d5c0]::thir::ExprId>>, <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  26:        0x10e69ad6c - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest
  27:        0x10e69f25c - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::in_scope::<<rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#0}::{closure#0}, ()>
  28:        0x10e69d12c - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#0}
  29:        0x10e69accc - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest
  30:        0x10e69f25c - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::in_scope::<<rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#0}::{closure#0}, ()>
  31:        0x10e69d12c - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest::{closure#0}
  32:        0x10e69accc - <rustc_mir_build[17ef53cc3e5b72c9]::build::Builder>::expr_into_dest
  33:        0x10e68315c - rustc_mir_build[17ef53cc3e5b72c9]::build::mir_build
  34:        0x10e68119c - rustc_mir_build[17ef53cc3e5b72c9]::build::mir_built
  35:        0x10ec64cf0 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::mir_built, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  36:        0x10eb6a160 - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::mir_built, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  37:        0x10ed5cccc - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::mir_built
  38:        0x10e14dff4 - rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::unsafety_check_result
  39:        0x10e14aac0 - <rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::provide::{closure#0} as core[504f2899fffd0de7]::ops::function::FnOnce<(rustc_middle[9da08aa6ecd6d5c0]::ty::context::TyCtxt, rustc_span[219dcf8acbb1c73e]::def_id::LocalDefId)>>::call_once
  40:        0x10ec24658 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  41:        0x10eb348bc - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  42:        0x10ed623a0 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::unsafety_check_result
  43:        0x10e14c6dc - <rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::UnsafetyChecker as rustc_middle[9da08aa6ecd6d5c0]::mir::visit::Visitor>::visit_rvalue
  44:        0x10e14e19c - rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::unsafety_check_result
  45:        0x10e14aac0 - <rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::provide::{closure#0} as core[504f2899fffd0de7]::ops::function::FnOnce<(rustc_middle[9da08aa6ecd6d5c0]::ty::context::TyCtxt, rustc_span[219dcf8acbb1c73e]::def_id::LocalDefId)>>::call_once
  46:        0x10ec24658 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  47:        0x10eb348bc - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  48:        0x10ed623a0 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::unsafety_check_result
  49:        0x10e14c6dc - <rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::UnsafetyChecker as rustc_middle[9da08aa6ecd6d5c0]::mir::visit::Visitor>::visit_rvalue
  50:        0x10e14e19c - rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::unsafety_check_result
  51:        0x10e14aac0 - <rustc_mir_transform[2f1f3373e510a36a]::check_unsafety::provide::{closure#0} as core[504f2899fffd0de7]::ops::function::FnOnce<(rustc_middle[9da08aa6ecd6d5c0]::ty::context::TyCtxt, rustc_span[219dcf8acbb1c73e]::def_id::LocalDefId)>>::call_once
  52:        0x10ec24658 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  53:        0x10eb348bc - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::unsafety_check_result, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  54:        0x10ed623a0 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::unsafety_check_result
  55:        0x10e1744d4 - rustc_mir_transform[2f1f3373e510a36a]::mir_const
  56:        0x10ec6567c - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::mir_const, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  57:        0x10eb6a83c - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::mir_const, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  58:        0x10ed5ce8c - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::mir_const
  59:        0x10e174e10 - rustc_mir_transform[2f1f3373e510a36a]::mir_promoted
  60:        0x10ebd1ff4 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::mir_promoted, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  61:        0x10eaf2d78 - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::mir_promoted, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  62:        0x10ed5d920 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::mir_promoted
  63:        0x10e78017c - rustc_borrowck[f3efb053a40a8e7a]::mir_borrowck
  64:        0x10e76464c - <rustc_borrowck[f3efb053a40a8e7a]::provide::{closure#0} as core[504f2899fffd0de7]::ops::function::FnOnce<(rustc_middle[9da08aa6ecd6d5c0]::ty::context::TyCtxt, rustc_span[219dcf8acbb1c73e]::def_id::LocalDefId)>>::call_once
  65:        0x10ebd07a0 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::mir_borrowck, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  66:        0x10eaf1f5c - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::mir_borrowck, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  67:        0x10ed64ff8 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::mir_borrowck
  68:        0x10e0509fc - rustc_hir_analysis[480d2d1e8c0c78d3]::collect::type_of::find_opaque_ty_constraints_for_rpit
  69:        0x10e04ffc4 - rustc_hir_analysis[480d2d1e8c0c78d3]::collect::type_of::type_of
  70:        0x10ec5df28 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::type_of, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  71:        0x10eb645bc - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::type_of, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  72:        0x10ed5a2f0 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::type_of
  73:        0x10e014d84 - rustc_hir_analysis[480d2d1e8c0c78d3]::check::check::check_item_type
  74:        0x10e01cdf4 - rustc_hir_analysis[480d2d1e8c0c78d3]::check::check::check_mod_item_types
  75:        0x10ec152e4 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::check_mod_item_types, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  76:        0x10eb28dd8 - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::check_mod_item_types, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  77:        0x10ed636c0 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::check_mod_item_types
  78:        0x10dff3480 - <rustc_session[6471261595ef6f64]::session::Session>::time::<(), rustc_hir_analysis[480d2d1e8c0c78d3]::check_crate::{closure#6}>
  79:        0x10dfb37f0 - rustc_hir_analysis[480d2d1e8c0c78d3]::check_crate
  80:        0x10baab610 - rustc_interface[4abc9379261c4bab]::passes::analysis
  81:        0x10ec5eb54 - <std[aa9a5926a012de0d]::thread::local::LocalKey<core[504f2899fffd0de7]::cell::Cell<*const ()>>>::with::<rustc_middle[9da08aa6ecd6d5c0]::ty::context::tls::enter_context<rustc_query_system[72e7dbc91c3512cd]::query::plumbing::execute_job_incr<rustc_query_impl[60724b15931b629e]::queries::analysis, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[9da08aa6ecd6d5c0]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[72e7dbc91c3512cd]::dep_graph::graph::DepNodeIndex)>
  82:        0x10eb64b5c - rustc_query_system[72e7dbc91c3512cd]::query::plumbing::try_execute_query::<rustc_query_impl[60724b15931b629e]::queries::analysis, rustc_query_impl[60724b15931b629e]::plumbing::QueryCtxt>
  83:        0x10ed5a978 - <rustc_query_impl[60724b15931b629e]::Queries as rustc_middle[9da08aa6ecd6d5c0]::ty::query::QueryEngine>::analysis
  84:        0x10b9a5b3c - <rustc_interface[4abc9379261c4bab]::queries::QueryResult<&rustc_middle[9da08aa6ecd6d5c0]::ty::context::GlobalCtxt>>::enter::<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  85:        0x10b9e1ab8 - <rustc_interface[4abc9379261c4bab]::interface::Compiler>::enter::<rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}::{closure#2}, core[504f2899fffd0de7]::result::Result<core[504f2899fffd0de7]::option::Option<rustc_interface[4abc9379261c4bab]::queries::Linker>, rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>
  86:        0x10b9987ec - rustc_span[219dcf8acbb1c73e]::set_source_map::<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_interface[4abc9379261c4bab]::interface::run_compiler<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  87:        0x10b9a6cfc - <scoped_tls[b7e4fed238ec6414]::ScopedKey<rustc_span[219dcf8acbb1c73e]::SessionGlobals>>::set::<rustc_interface[4abc9379261c4bab]::interface::run_compiler<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}>::{closure#0}, core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>
  88:        0x10b997bb8 - std[aa9a5926a012de0d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4abc9379261c4bab]::util::run_in_thread_pool_with_globals<rustc_interface[4abc9379261c4bab]::interface::run_compiler<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}>::{closure#0}, core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>
  89:        0x10b99cf98 - <<std[aa9a5926a012de0d]::thread::Builder>::spawn_unchecked_<rustc_interface[4abc9379261c4bab]::util::run_in_thread_pool_with_globals<rustc_interface[4abc9379261c4bab]::interface::run_compiler<core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>, rustc_driver_impl[2b4a73ce5be55b2]::run_compiler::{closure#1}>::{closure#0}, core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[504f2899fffd0de7]::result::Result<(), rustc_span[219dcf8acbb1c73e]::ErrorGuaranteed>>::{closure#1} as core[504f2899fffd0de7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  90:        0x10349ce24 - std::sys::unix::thread::Thread::new::thread_start::heeaa880b39b03cd7
  91:        0x1a79f026c - __pthread_deallocate

@conradludgate conradludgate added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 17, 2023
@Noratrieb
Copy link
Member

self.try_to_place(cx).unwrap()
}
/// Creates a `Place` or returns `None` if an upvar cannot be resolved
pub(in crate::build) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Place<'tcx>> {
let resolved = self.resolve_upvar(cx);
let builder = resolved.as_ref().unwrap_or(self);
let PlaceBase::Local(local) = builder.base else { return None };

Looks like it can't resolve the closure upvar in MIR building.

@Noratrieb
Copy link
Member

Noratrieb commented Apr 17, 2023

bisection shows that this has been broken since ~forever

@conradludgate
Copy link
Contributor Author

Seems to require edition 2021 capturing

@matthiaskrgr
Copy link
Member

might be related to #108683

@clubby789
Copy link
Contributor

Slightly smaller repro

pub struct B;
pub fn a() -> B { B }

mod handlers {
    pub struct C(B);
    pub fn c() -> impl Fn() -> C {
        let a1 = ();
        || C((crate::a(), a1).into())
    }
}

Moving C out of handlers and importing it prevents the ICE.
Similar symptom as #108683 (2021 closure analysis prevent capture of a variable which needs to be captured) but not the same root cause afaict, as there's no patterns in the closure

@Noratrieb Noratrieb changed the title build_mir ICE ICE in mir building with captured value of unresolved type Apr 17, 2023
@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jun 17, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 17, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium +T-compiler

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 21, 2023
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 25, 2023
@matthiaskrgr matthiaskrgr changed the title ICE in mir building with captured value of unresolved type ICE in mir building with captured value of unresolved type, None in compiler/rustc_mir_build/src/build/expr/as_place.rs Jul 26, 2023
@matthiaskrgr matthiaskrgr added the A-edition-2021 Area: The 2021 edition label Jul 26, 2023
@matthiaskrgr
Copy link
Member

another repro:

fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
    move |a| f(a * 2)
}

@clubby789
Copy link
Contributor

This repro doesn't ICE on stable, only nightly, whereas the other repros ICE on both. Possibly another bug?

@matthiaskrgr
Copy link
Member

Hmm interesting, query stack seemed pretty much the same from what I saw.
I bisected #110453 (comment) and it boiled down to #116436 ( cc @compiler-errors )

I could imagine that the code change now causes the former ICE to pop up in additional places now?

@matthiaskrgr
Copy link
Member

Fixed by #118751 I think

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Dec 13, 2023

Oh we should add a test! Can also grab one from #117802

@matthiaskrgr matthiaskrgr reopened this Dec 13, 2023
@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 13, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 24, 2024
…ype, None in compiler/rustc_mir_build/src/build/expr/as_place.rs rust-lang#110453

Fixes rust-lang#110453
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2024
Rollup merge of rust-lang#122988 - matthiaskrgr:icetests, r=petrochenkov

add even more tests!

Fixes rust-lang#109869
Fixes rust-lang#110453
Fixes rust-lang#109020
Fixes rust-lang#108580
Fixes rust-lang#108220
Fixes rust-lang#113045
Fixes rust-lang#113133
Fixes rust-lang#114464
Fixes rust-lang#116599
Fixes rust-lang#119731
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.

8 participants
@matthiaskrgr @apiraino @conradludgate @clubby789 @rustbot @Noratrieb @rust-lang-glacier-bot and others