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: Unexpected type Alias(...) for 'Field' projection , edition 2021 #105819

Closed
matthiaskrgr opened this issue Dec 17, 2022 · 5 comments · Fixed by #114022
Closed

ICE: Unexpected type Alias(...) for 'Field' projection , edition 2021 #105819

matthiaskrgr opened this issue Dec 17, 2022 · 5 comments · Fixed by #114022
Assignees
Labels
A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Dec 17, 2022

Code

src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs

#![feature(type_alias_impl_trait)]
// check-pass

fn main() {}

fn upvar() {
    #[derive(Copy, Clone)]
    struct Foo((u32, u32));

    type T = impl Copy;
    let foo: T = Foo((1u32, 2u32));
    let x = move || {
        let Foo((a, b)) = foo;
    };
}

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (74699b82c 2022-12-17)
binary: rustc
commit-hash: 74699b82cac980b9fb423a4ec2f131209b6a7630
commit-date: 2022-12-17
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6

Error output

rustc issue-96572-unconstrained.rs --edition=2021


Backtrace

error: internal compiler error: compiler/rustc_mir_build/src/build/expr/as_place.rs:438:18: couldn't create field type, unexpected base type: upvar::T

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
   0:     0x7fb515e3ec5a - std::backtrace_rs::backtrace::libunwind::trace::h2607aefc39696f6a
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb515e3ec5a - std::backtrace_rs::backtrace::trace_unsynchronized::hc144a75d57c2c7b3
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb515e3ec5a - std::sys_common::backtrace::_print_fmt::h342ddc14684da589
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fb515e3ec5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdc98134100963a2f
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb511dc836e - core::fmt::write::h2470da262daef57b
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/core/src/fmt/mod.rs:1208:17
   5:     0x7fb515e32e35 - std::io::Write::write_fmt::hbb84f5c56a9ffd7e
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/io/mod.rs:1682:15
   6:     0x7fb515e3ea25 - std::sys_common::backtrace::_print::h09788334315e2227
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fb515e3ea25 - std::sys_common::backtrace::print::h91b882168c879aff
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fb515e40daf - std::panicking::default_hook::{{closure}}::h8265382c0fcd6c24
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/panicking.rs:267:22
   9:     0x7fb515e40aeb - std::panicking::default_hook::hce97146ae255ffa1
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/panicking.rs:286:9
  10:     0x7fb515066bd1 - <rustc_driver[9ceb0128d4545407]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[bbfcb7d5d352d6d8]::ops::function::FnOnce<(&core[bbfcb7d5d352d6d8]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7fb515e415ad - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hefea13a236451b00
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/alloc/src/boxed.rs:2032:9
  12:     0x7fb515e415ad - std::panicking::rust_panic_with_hook::haad14347c6e2995e
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/panicking.rs:692:13
  13:     0x7fb51550c6b1 - std[ffc5064dcb802758]::panicking::begin_panic::<rustc_errors[a1afcc29edf9f643]::ExplicitBug>::{closure#0}
  14:     0x7fb51550bf26 - std[ffc5064dcb802758]::sys_common::backtrace::__rust_end_short_backtrace::<std[ffc5064dcb802758]::panicking::begin_panic<rustc_errors[a1afcc29edf9f643]::ExplicitBug>::{closure#0}, !>
  15:     0x7fb515568bf6 - std[ffc5064dcb802758]::panicking::begin_panic::<rustc_errors[a1afcc29edf9f643]::ExplicitBug>
  16:     0x7fb51550bd66 - std[ffc5064dcb802758]::panic::panic_any::<rustc_errors[a1afcc29edf9f643]::ExplicitBug>
  17:     0x7fb515509336 - <rustc_errors[a1afcc29edf9f643]::HandlerInner>::bug::<&alloc[34db83fb13497f51]::string::String>
  18:     0x7fb515508fa0 - <rustc_errors[a1afcc29edf9f643]::Handler>::bug::<&alloc[34db83fb13497f51]::string::String>
  19:     0x7fb5155d0a9e - rustc_middle[4e38d5d2b9306e4d]::ty::context::tls::with_context_opt::<rustc_middle[4e38d5d2b9306e4d]::ty::context::tls::with_opt<rustc_middle[4e38d5d2b9306e4d]::util::bug::opt_span_bug_fmt<rustc_span[5fbaba9c6a6126d5]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7fb5155d0d66 - rustc_middle[4e38d5d2b9306e4d]::util::bug::opt_span_bug_fmt::<rustc_span[5fbaba9c6a6126d5]::span_encoding::Span>
  21:     0x7fb513314f33 - rustc_middle[4e38d5d2b9306e4d]::util::bug::bug_fmt
  22:     0x7fb513528e5d - <rustc_mir_build[734256960e97beec]::build::expr::as_place::PlaceBuilder>::field
  23:     0x7fb5135246e2 - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_as_place
  24:     0x7fb513524663 - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_as_place
  25:     0x7fb513530a78 - <core[bbfcb7d5d352d6d8]::iter::adapters::copied::Copied<core[bbfcb7d5d352d6d8]::slice::iter::Iter<rustc_middle[4e38d5d2b9306e4d]::thir::ExprId>> as core[bbfcb7d5d352d6d8]::iter::traits::iterator::Iterator>::fold::<(), core[bbfcb7d5d352d6d8]::iter::adapters::map::map_fold<rustc_middle[4e38d5d2b9306e4d]::thir::ExprId, rustc_middle[4e38d5d2b9306e4d]::mir::syntax::Operand, (), <rustc_mir_build[734256960e97beec]::build::Builder>::as_rvalue::{closure#4}, core[bbfcb7d5d352d6d8]::iter::traits::iterator::Iterator::for_each::call<rustc_middle[4e38d5d2b9306e4d]::mir::syntax::Operand, <alloc[34db83fb13497f51]::vec::Vec<rustc_middle[4e38d5d2b9306e4d]::mir::syntax::Operand>>::extend_trusted<core[bbfcb7d5d352d6d8]::iter::adapters::map::Map<core[bbfcb7d5d352d6d8]::iter::adapters::copied::Copied<core[bbfcb7d5d352d6d8]::slice::iter::Iter<rustc_middle[4e38d5d2b9306e4d]::thir::ExprId>>, <rustc_mir_build[734256960e97beec]::build::Builder>::as_rvalue::{closure#4}>>::{closure#0}>::{closure#0}>::{closure#0}>
  26:     0x7fb51352ffab - <alloc[34db83fb13497f51]::vec::Vec<rustc_middle[4e38d5d2b9306e4d]::mir::syntax::Operand> as alloc[34db83fb13497f51]::vec::spec_from_iter::SpecFromIter<rustc_middle[4e38d5d2b9306e4d]::mir::syntax::Operand, core[bbfcb7d5d352d6d8]::iter::adapters::map::Map<core[bbfcb7d5d352d6d8]::iter::adapters::copied::Copied<core[bbfcb7d5d352d6d8]::slice::iter::Iter<rustc_middle[4e38d5d2b9306e4d]::thir::ExprId>>, <rustc_mir_build[734256960e97beec]::build::Builder>::as_rvalue::{closure#4}>>>::from_iter
  27:     0x7fb51350638a - <rustc_mir_build[734256960e97beec]::build::Builder>::as_rvalue
  28:     0x7fb513514b04 - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_into_dest
  29:     0x7fb5135149dc - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_into_dest
  30:     0x7fb513535a8c - <rustc_mir_build[734256960e97beec]::build::Builder>::ast_block_stmts
  31:     0x7fb51352ec88 - <rustc_mir_build[734256960e97beec]::build::Builder>::ast_block
  32:     0x7fb513515898 - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_into_dest
  33:     0x7fb5135149dc - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_into_dest
  34:     0x7fb5135149dc - <rustc_mir_build[734256960e97beec]::build::Builder>::expr_into_dest
  35:     0x7fb5140cfa47 - rustc_mir_build[734256960e97beec]::build::mir_built
  36:     0x7fb5139cea3a - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::DefaultCache<rustc_middle[4e38d5d2b9306e4d]::ty::WithOptConstParam<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId>, &rustc_data_structures[53fd8e05c19798dc]::steal::Steal<rustc_middle[4e38d5d2b9306e4d]::mir::Body>>>
  37:     0x7fb5139da82a - rustc_mir_transform[94f81ae76961faa1]::check_unsafety::unsafety_check_result
  38:     0x7fb5139d4866 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::VecCache<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId, &rustc_middle[4e38d5d2b9306e4d]::mir::query::UnsafetyCheckResult>>
  39:     0x7fb5139d11f4 - rustc_mir_transform[94f81ae76961faa1]::mir_const
  40:     0x7fb5139ced70 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::DefaultCache<rustc_middle[4e38d5d2b9306e4d]::ty::WithOptConstParam<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId>, &rustc_data_structures[53fd8e05c19798dc]::steal::Steal<rustc_middle[4e38d5d2b9306e4d]::mir::Body>>>
  41:     0x7fb513d9dc54 - rustc_mir_transform[94f81ae76961faa1]::mir_promoted
  42:     0x7fb513d9c1fa - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::DefaultCache<rustc_middle[4e38d5d2b9306e4d]::ty::WithOptConstParam<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId>, (&rustc_data_structures[53fd8e05c19798dc]::steal::Steal<rustc_middle[4e38d5d2b9306e4d]::mir::Body>, &rustc_data_structures[53fd8e05c19798dc]::steal::Steal<rustc_index[665f3613b191e921]::vec::IndexVec<rustc_middle[4e38d5d2b9306e4d]::mir::Promoted, rustc_middle[4e38d5d2b9306e4d]::mir::Body>>)>>
  43:     0x7fb513d9aa4f - rustc_borrowck[533f25d0079c6f0f]::mir_borrowck
  44:     0x7fb51402c92e - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::VecCache<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId, &rustc_middle[4e38d5d2b9306e4d]::mir::query::BorrowCheckResult>>
  45:     0x7fb514a1839a - <rustc_query_impl[49d76624473611be]::Queries as rustc_middle[4e38d5d2b9306e4d]::ty::query::QueryEngine>::mir_borrowck
  46:     0x7fb515191d77 - <rustc_hir_analysis[ae59112018bd4566]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  47:     0x7fb515191666 - rustc_hir_analysis[ae59112018bd4566]::collect::type_of::find_opaque_ty_constraints_for_tait
  48:     0x7fb51486c75f - rustc_hir_analysis[ae59112018bd4566]::collect::type_of::type_of
  49:     0x7fb51391aad7 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::get_query::<rustc_query_impl[49d76624473611be]::queries::type_of, rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt>
  50:     0x7fb5141a8c19 - rustc_hir_analysis[ae59112018bd4566]::check::check::check_mod_item_types
  51:     0x7fb513bd2b31 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::VecCache<rustc_span[5fbaba9c6a6126d5]::def_id::LocalDefId, ()>>
  52:     0x7fb514457033 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::get_query::<rustc_query_impl[49d76624473611be]::queries::check_mod_item_types, rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt>
  53:     0x7fb5146fa555 - <rustc_middle[4e38d5d2b9306e4d]::hir::map::Map>::for_each_module::<rustc_hir_analysis[ae59112018bd4566]::check_crate::{closure#6}::{closure#0}>
  54:     0x7fb5135d2752 - rustc_hir_analysis[ae59112018bd4566]::check_crate
  55:     0x7fb5135d239b - rustc_interface[50801890e46a75d8]::passes::analysis
  56:     0x7fb51482a9c7 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::try_execute_query::<rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt, rustc_query_system[f6b5e3aef1ad0eab]::query::caches::DefaultCache<(), core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>>
  57:     0x7fb51482a6c0 - rustc_query_system[f6b5e3aef1ad0eab]::query::plumbing::get_query::<rustc_query_impl[49d76624473611be]::queries::analysis, rustc_query_impl[49d76624473611be]::plumbing::QueryCtxt>
  58:     0x7fb5142f7193 - <rustc_interface[50801890e46a75d8]::passes::QueryContext>::enter::<rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>
  59:     0x7fb5142f3543 - <rustc_interface[50801890e46a75d8]::interface::Compiler>::enter::<rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}::{closure#2}, core[bbfcb7d5d352d6d8]::result::Result<core[bbfcb7d5d352d6d8]::option::Option<rustc_interface[50801890e46a75d8]::queries::Linker>, rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>
  60:     0x7fb5142ee558 - rustc_span[5fbaba9c6a6126d5]::with_source_map::<core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>, rustc_interface[50801890e46a75d8]::interface::run_compiler<core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>, rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  61:     0x7fb5142ee045 - <scoped_tls[db5d9dfb431505bb]::ScopedKey<rustc_span[5fbaba9c6a6126d5]::SessionGlobals>>::set::<rustc_interface[50801890e46a75d8]::interface::run_compiler<core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>, rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}>::{closure#0}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>
  62:     0x7fb5142ed632 - std[ffc5064dcb802758]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[50801890e46a75d8]::util::run_in_thread_pool_with_globals<rustc_interface[50801890e46a75d8]::interface::run_compiler<core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>, rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}>::{closure#0}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>
  63:     0x7fb51492829e - <<std[ffc5064dcb802758]::thread::Builder>::spawn_unchecked_<rustc_interface[50801890e46a75d8]::util::run_in_thread_pool_with_globals<rustc_interface[50801890e46a75d8]::interface::run_compiler<core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>, rustc_driver[9ceb0128d4545407]::run_compiler::{closure#1}>::{closure#0}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bbfcb7d5d352d6d8]::result::Result<(), rustc_errors[a1afcc29edf9f643]::ErrorGuaranteed>>::{closure#1} as core[bbfcb7d5d352d6d8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  64:     0x7fb515e48823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h67a3660415c1c402
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/alloc/src/boxed.rs:2000:9
  65:     0x7fb515e48823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he60abfaa26b4de0c
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/alloc/src/boxed.rs:2000:9
  66:     0x7fb515e48823 - std::sys::unix::thread::Thread::new::thread_start::hd33ece6941cc9dcc
                               at /rustc/74699b82cac980b9fb423a4ec2f131209b6a7630/library/std/src/sys/unix/thread.rs:108:17
  67:     0x7fb511b058fd - <unknown>
  68:     0x7fb511b87a60 - <unknown>
  69:                0x0 - <unknown>

note: 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.68.0-nightly (74699b82c 2022-12-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_built] building MIR for `upvar`
#1 [unsafety_check_result] unsafety-checking `upvar`
#2 [mir_const] preparing `upvar` for borrow checking
#3 [mir_promoted] processing MIR for `upvar`
#4 [mir_borrowck] borrow-checking `upvar`
#5 [type_of] computing type of `upvar::T::{opaque#0}`
#6 [check_mod_item_types] checking item types in top-level module
#7 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. A-edition-2021 Area: The 2021 edition S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Dec 17, 2022
@oli-obk oli-obk self-assigned this Dec 17, 2022
@jruderman
Copy link
Contributor

Regression in nightly-2022-03-31, perhaps from #94081 (CC @oli-obk)

Commits in range
  commit[0] 2022-03-29UTC: Auto merge of #95448 - Dylan-DPC:rollup-wpj5yto, r=Dylan-DPC
  commit[1] 2022-03-30UTC: Auto merge of #95455 - RalfJung:miri, r=RalfJung
  commit[2] 2022-03-30UTC: Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakis
  commit[3] 2022-03-30UTC: Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
  commit[4] 2022-03-30UTC: Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee
  commit[5] 2022-03-30UTC: Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se
  commit[6] 2022-03-30UTC: Auto merge of #95458 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
  commit[7] 2022-03-30UTC: Auto merge of #95425 - nnethercote:yet-more-parse_tt-improvements, r=petrochenkov

@matthiaskrgr
Copy link
Member Author

That's weird, this showed up in my nightly ice gathering as something new (from yesterday to today) but I guess the ICE just changed?
with Beta, I get error: internal compiler error: compiler/rustc_middle/src/ty/closure.rs:172:25: Unexpected type Opaque(DefId(0:34 ~ issue_96572_unconstrained[e303]::upvar::T::{opaque#0}), []) for Field projection

with nightly I get error: internal compiler error: compiler/rustc_mir_build/src/build/expr/as_place.rs:438:18: couldn't create field type, unexpected base type: upvar::T

@jruderman
Copy link
Contributor

Indeed, the ICE changed in nightly-2022-12-17 due to #103880

@matthiaskrgr matthiaskrgr changed the title ICE: couldn't create field type, unexpected base type: upvar::T, edition 2021 ICE: Unexpected type Alias(...) for Field projection , edition 2021 Jan 21, 2023
@matthiaskrgr matthiaskrgr changed the title ICE: Unexpected type Alias(...) for Field projection , edition 2021 ICE: Unexpected type Alias(...) for 'Field' projection , edition 2021 Jan 21, 2023
@matthiaskrgr
Copy link
Member Author

Update backtrace:

Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/closure.rs:172:25: Unexpected type Alias(Opaque, AliasTy { substs: [], def_id: DefId(0:13 ~ c[e654]::upvar::T::{opaque#0}) }) for `Field` projection
  --> c.rs:13:27
   |
13 |         let Foo((a, b)) = foo;
   |                           ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/compiler/rustc_errors/src/lib.rs:987:33
stack backtrace:
   0:     0x7fce191653ca - std::backtrace_rs::backtrace::libunwind::trace::ha92ef9f6ccd5e56b
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fce191653ca - std::backtrace_rs::backtrace::trace_unsynchronized::ha44c299690166f2b
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fce191653ca - std::sys_common::backtrace::_print_fmt::h19cd3f39c344a33c
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fce191653ca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h293cba156d45b475
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fce191c867e - core::fmt::write::h2a89c5a2cd2a0936
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/core/src/fmt/mod.rs:1213:17
   5:     0x7fce19155a15 - std::io::Write::write_fmt::h61b873d4305ed5fb
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/io/mod.rs:1682:15
   6:     0x7fce19165195 - std::sys_common::backtrace::_print::he80b3ad6361d876c
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fce19165195 - std::sys_common::backtrace::print::ha340fba9744b3a51
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fce19167f5f - std::panicking::default_hook::{{closure}}::hbb5472f169f46106
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/panicking.rs:267:22
   9:     0x7fce19167c9b - std::panicking::default_hook::h910b88c51274ec02
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/panicking.rs:286:9
  10:     0x7fce1c45ec54 - rustc_driver[639bbb82542a12c4]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fce1916879a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hf5cbaf936ef8179d
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/alloc/src/boxed.rs:2002:9
  12:     0x7fce1916879a - std::panicking::rust_panic_with_hook::h637d33e8738b38ce
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/panicking.rs:692:13
  13:     0x7fce1c9c8521 - std[160d0d017ec6e0b8]::panicking::begin_panic::<rustc_errors[ab114d7d6097e91e]::ExplicitBug>::{closure#0}
  14:     0x7fce1c9c4fe6 - std[160d0d017ec6e0b8]::sys_common::backtrace::__rust_end_short_backtrace::<std[160d0d017ec6e0b8]::panicking::begin_panic<rustc_errors[ab114d7d6097e91e]::ExplicitBug>::{closure#0}, !>
  15:     0x7fce1ca27686 - std[160d0d017ec6e0b8]::panicking::begin_panic::<rustc_errors[ab114d7d6097e91e]::ExplicitBug>
  16:     0x7fce1c9e0366 - std[160d0d017ec6e0b8]::panic::panic_any::<rustc_errors[ab114d7d6097e91e]::ExplicitBug>
  17:     0x7fce1c9dfd22 - <rustc_errors[ab114d7d6097e91e]::HandlerInner>::span_bug::<rustc_span[6badc9707177032f]::span_encoding::Span, &alloc[3c9e883abe43a86f]::string::String>
  18:     0x7fce1c9ded77 - <rustc_errors[ab114d7d6097e91e]::Handler>::span_bug::<rustc_span[6badc9707177032f]::span_encoding::Span, &alloc[3c9e883abe43a86f]::string::String>
  19:     0x7fce1c9eed0b - rustc_middle[81963a276c0c8277]::util::bug::opt_span_bug_fmt::<rustc_span[6badc9707177032f]::span_encoding::Span>::{closure#0}
  20:     0x7fce1c9ec09a - rustc_middle[81963a276c0c8277]::ty::context::tls::with_opt::<rustc_middle[81963a276c0c8277]::util::bug::opt_span_bug_fmt<rustc_span[6badc9707177032f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fce1c9ec06a - rustc_middle[81963a276c0c8277]::ty::context::tls::with_context_opt::<rustc_middle[81963a276c0c8277]::ty::context::tls::with_opt<rustc_middle[81963a276c0c8277]::util::bug::opt_span_bug_fmt<rustc_span[6badc9707177032f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fce1c9eec46 - rustc_middle[81963a276c0c8277]::util::bug::opt_span_bug_fmt::<rustc_span[6badc9707177032f]::span_encoding::Span>
  23:     0x7fce1c9eec04 - rustc_middle[81963a276c0c8277]::util::bug::span_bug_fmt::<rustc_span[6badc9707177032f]::span_encoding::Span>
  24:     0x7fce1b97edd4 - <&mut rustc_middle[81963a276c0c8277]::ty::closure::symbols_for_closure_captures::{closure#0} as core[dd0ad632f08e6ea1]::ops::function::FnOnce<(&rustc_middle[81963a276c0c8277]::ty::closure::CapturedPlace,)>>::call_once
  25:     0x7fce1b97e3ef - <alloc[3c9e883abe43a86f]::vec::Vec<rustc_span[6badc9707177032f]::symbol::Symbol> as alloc[3c9e883abe43a86f]::vec::spec_from_iter::SpecFromIter<rustc_span[6badc9707177032f]::symbol::Symbol, core[dd0ad632f08e6ea1]::iter::adapters::map::Map<core[dd0ad632f08e6ea1]::iter::adapters::flatten::Flatten<core[dd0ad632f08e6ea1]::option::IntoIter<core[dd0ad632f08e6ea1]::iter::adapters::flatten::FlatMap<indexmap[469fb5cc230ef844]::map::Values<rustc_hir[af482e64e9f01e9c]::hir_id::HirId, alloc[3c9e883abe43a86f]::vec::Vec<rustc_middle[81963a276c0c8277]::ty::closure::CapturedPlace>>, core[dd0ad632f08e6ea1]::slice::iter::Iter<rustc_middle[81963a276c0c8277]::ty::closure::CapturedPlace>, <rustc_middle[81963a276c0c8277]::ty::typeck_results::TypeckResults>::closure_min_captures_flattened::{closure#0}::{closure#0}>>>, rustc_middle[81963a276c0c8277]::ty::closure::symbols_for_closure_captures::{closure#0}>>>::from_iter
  26:     0x7fce1b97e1ec - rustc_middle[81963a276c0c8277]::ty::closure::symbols_for_closure_captures
  27:     0x7fce1b9f87c7 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::symbols_for_closure_captures, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  28:     0x7fce1be4e6ff - <rustc_query_impl[2185a4df21703c4]::Queries as rustc_middle[81963a276c0c8277]::ty::query::QueryEngine>::symbols_for_closure_captures
  29:     0x7fce1b5acc4f - rustc_mir_build[ff9628d6c6d389c5]::build::mir_built
  30:     0x7fce1b24f415 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::mir_built, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  31:     0x7fce1b58208d - rustc_mir_transform[137284fa802fab14]::check_unsafety::unsafety_check_result
  32:     0x7fce1b39aa19 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::unsafety_check_result, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  33:     0x7fce1be4fe44 - <rustc_query_impl[2185a4df21703c4]::Queries as rustc_middle[81963a276c0c8277]::ty::query::QueryEngine>::unsafety_check_result
  34:     0x7fce1b584cce - rustc_mir_transform[137284fa802fab14]::check_unsafety::unsafety_check_result
  35:     0x7fce1b39aa19 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::unsafety_check_result, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  36:     0x7fce1b39735d - rustc_mir_transform[137284fa802fab14]::mir_const
  37:     0x7fce1b395d61 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::mir_const, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  38:     0x7fce1b38e1d9 - rustc_mir_transform[137284fa802fab14]::mir_promoted
  39:     0x7fce1b38c6a4 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::mir_promoted, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  40:     0x7fce1b38af48 - rustc_borrowck[e2111fe20b1902b8]::mir_borrowck
  41:     0x7fce1ad7fd9d - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::mir_borrowck, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  42:     0x7fce1be512cd - <rustc_query_impl[2185a4df21703c4]::Queries as rustc_middle[81963a276c0c8277]::ty::query::QueryEngine>::mir_borrowck
  43:     0x7fce1c57f36a - <rustc_hir_analysis[dc2fdeeecccd2750]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  44:     0x7fce1c57ec57 - rustc_hir_analysis[dc2fdeeecccd2750]::collect::type_of::find_opaque_ty_constraints_for_tait
  45:     0x7fce1bc86af9 - rustc_hir_analysis[dc2fdeeecccd2750]::collect::type_of::type_of
  46:     0x7fce1ad46fd8 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::get_query::<rustc_query_impl[2185a4df21703c4]::queries::type_of, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt, rustc_middle[81963a276c0c8277]::dep_graph::dep_node::DepKind>
  47:     0x7fce1b0101cb - rustc_hir_analysis[dc2fdeeecccd2750]::check::check::check_mod_item_types
  48:     0x7fce1ba0a151 - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::check_mod_item_types, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  49:     0x7fce1be5082d - <rustc_query_impl[2185a4df21703c4]::Queries as rustc_middle[81963a276c0c8277]::ty::query::QueryEngine>::check_mod_item_types
  50:     0x7fce1aa8b097 - <rustc_session[59546dad5498a62e]::session::Session>::time::<(), rustc_hir_analysis[dc2fdeeecccd2750]::check_crate::{closure#6}>
  51:     0x7fce1aa8a8a2 - rustc_hir_analysis[dc2fdeeecccd2750]::check_crate
  52:     0x7fce1aa8a51b - rustc_interface[712fc5ea6eb72e1f]::passes::analysis
  53:     0x7fce1bbc267e - rustc_query_system[485dd4ae9ee084f0]::query::plumbing::try_execute_query::<rustc_query_impl[2185a4df21703c4]::queries::analysis, rustc_query_impl[2185a4df21703c4]::plumbing::QueryCtxt>
  54:     0x7fce1be4d6ba - <rustc_query_impl[2185a4df21703c4]::Queries as rustc_middle[81963a276c0c8277]::ty::query::QueryEngine>::analysis
  55:     0x7fce1b6e4420 - <rustc_interface[712fc5ea6eb72e1f]::passes::QueryContext>::enter::<rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>
  56:     0x7fce1b6e3221 - <rustc_interface[712fc5ea6eb72e1f]::interface::Compiler>::enter::<rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}::{closure#2}, core[dd0ad632f08e6ea1]::result::Result<core[dd0ad632f08e6ea1]::option::Option<rustc_interface[712fc5ea6eb72e1f]::queries::Linker>, rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>
  57:     0x7fce1b6e12f4 - rustc_span[6badc9707177032f]::with_source_map::<core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>, rustc_interface[712fc5ea6eb72e1f]::interface::run_compiler<core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>, rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  58:     0x7fce1b6e0e04 - <scoped_tls[3adb5d9e8b10118b]::ScopedKey<rustc_span[6badc9707177032f]::SessionGlobals>>::set::<rustc_interface[712fc5ea6eb72e1f]::interface::run_compiler<core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>, rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}>::{closure#0}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>
  59:     0x7fce1b6e0502 - std[160d0d017ec6e0b8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[712fc5ea6eb72e1f]::util::run_in_thread_pool_with_globals<rustc_interface[712fc5ea6eb72e1f]::interface::run_compiler<core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>, rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}>::{closure#0}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>
  60:     0x7fce1b6e02aa - <<std[160d0d017ec6e0b8]::thread::Builder>::spawn_unchecked_<rustc_interface[712fc5ea6eb72e1f]::util::run_in_thread_pool_with_globals<rustc_interface[712fc5ea6eb72e1f]::interface::run_compiler<core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>, rustc_driver[639bbb82542a12c4]::run_compiler::{closure#1}>::{closure#0}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dd0ad632f08e6ea1]::result::Result<(), rustc_errors[ab114d7d6097e91e]::ErrorGuaranteed>>::{closure#1} as core[dd0ad632f08e6ea1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  61:     0x7fce19172bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4dd19c0bc3e6367b
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/alloc/src/boxed.rs:1988:9
  62:     0x7fce19172bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h379cba3f119da2fe
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/alloc/src/boxed.rs:1988:9
  63:     0x7fce19172bd3 - std::sys::unix::thread::Thread::new::thread_start::hd739ff786112afe1
                               at /rustc/5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14/library/std/src/sys/unix/thread.rs:108:17
  64:     0x7fce18f048fd - <unknown>
  65:     0x7fce18f86a60 - <unknown>
  66:                0x0 - <unknown>

note: 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.68.0-nightly (5ce39f42b 2023-01-20) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [symbols_for_closure_captures] finding symbols for captures of closure `upvar::{closure#0}` in `upvar::{closure#0}`
#1 [mir_built] building MIR for `upvar::{closure#0}`
#2 [unsafety_check_result] unsafety-checking `upvar::{closure#0}`
#3 [unsafety_check_result] unsafety-checking `upvar`
#4 [mir_const] preparing `upvar` for borrow checking
#5 [mir_promoted] processing MIR for `upvar`
#6 [mir_borrowck] borrow-checking `upvar`
#7 [type_of] computing type of `upvar::T::{opaque#0}`
#8 [check_mod_item_types] checking item types in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 21, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Jul 21, 2023

This is because precise captures (the x field of foo.x instead of foo in || foo.x.thing()) only exists in the 2021 edition. We need to start registering OpaqueCast projections in HIR, too it seems.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…ction, r=cjgillot

Perform OpaqueCast field projection on HIR, too.

fixes rust-lang#105819

This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).

See rust-lang#99806 for when and why we added OpaqueCast to MIR.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…ction, r=cjgillot

Perform OpaqueCast field projection on HIR, too.

fixes rust-lang#105819

This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).

See rust-lang#99806 for when and why we added OpaqueCast to MIR.
@bors bors closed this as completed in 576bf82 Aug 4, 2023
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 11, 2023
…ction, r=cjgillot

Perform OpaqueCast field projection on HIR, too.

fixes rust-lang#105819

This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).

See rust-lang#99806 for when and why we added OpaqueCast to MIR.
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. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
4 participants