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

TAIT ICE "extracting field of non-tuple non-adt" #104551

Closed
jruderman opened this issue Nov 17, 2022 · 0 comments · Fixed by #105897
Closed

TAIT ICE "extracting field of non-tuple non-adt" #104551

jruderman opened this issue Nov 17, 2022 · 0 comments · Fixed by #105897
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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.

Comments

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

#![feature(type_alias_impl_trait)]

fn main() {
    type T = impl Sized;
    let (_a, _b): T = (1u32, 2u32);
}

Error output

error: internal compiler error: compiler/rustc_middle/src/mir/tcx.rs:49:18: extracting field of non-tuple non-adt: PlaceTy { ty: main::T, variant_index: None }
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/compiler/rustc_errors/src/lib.rs:1555:9
stack backtrace:
   0:        0x106fb8f22 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc8a49f87ce17062a
   1:        0x10701785a - core::fmt::write::h8a1a7abc727fe6d0
   2:        0x106fab2ec - std::io::Write::write_fmt::h784a2d3ee2ee8639
   3:        0x106fb8cea - std::sys_common::backtrace::print::hb4003780820818b1
   4:        0x106fbc016 - std::panicking::default_hook::{{closure}}::ha4bb64ed2ba8f281
   5:        0x106fbbd67 - std::panicking::default_hook::haa41a49d8ba42d3b
   6:        0x115b619bd - rustc_driver[3dbfeae94bbb450c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x106fbc7fd - std::panicking::rust_panic_with_hook::h0ec6182f72894cd1
   8:        0x11a316d77 - std[b7fc25f664aa2c42]::panicking::begin_panic::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>::{closure#0}
   9:        0x11a3165f9 - std[b7fc25f664aa2c42]::sys_common::backtrace::__rust_end_short_backtrace::<std[b7fc25f664aa2c42]::panicking::begin_panic<rustc_errors[3e76822466e0ccc2]::ExplicitBug>::{closure#0}, !>
  10:        0x11a91bff9 - std[b7fc25f664aa2c42]::panicking::begin_panic::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>
  11:        0x11a316589 - std[b7fc25f664aa2c42]::panic::panic_any::<rustc_errors[3e76822466e0ccc2]::ExplicitBug>
  12:        0x11a313ecd - <rustc_errors[3e76822466e0ccc2]::HandlerInner>::bug::<&alloc[f3b087a993ab1fcd]::string::String>
  13:        0x11a313997 - <rustc_errors[3e76822466e0ccc2]::Handler>::bug::<&alloc[f3b087a993ab1fcd]::string::String>
  14:        0x11a3c2e52 - rustc_middle[e2305deeabdd0cca]::ty::context::tls::with_context_opt::<rustc_middle[e2305deeabdd0cca]::ty::context::tls::with_opt<rustc_middle[e2305deeabdd0cca]::util::bug::opt_span_bug_fmt<rustc_span[663101514bc5927d]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  15:        0x11a3c3251 - rustc_middle[e2305deeabdd0cca]::util::bug::opt_span_bug_fmt::<rustc_span[663101514bc5927d]::span_encoding::Span>
  16:        0x11a91d9ae - rustc_middle[e2305deeabdd0cca]::util::bug::bug_fmt
  17:        0x11a325665 - <rustc_middle[e2305deeabdd0cca]::mir::tcx::PlaceTy>::field_ty
  18:        0x118ecd151 - <rustc_middle[e2305deeabdd0cca]::mir::tcx::PlaceTy>::projection_ty_core::<(), (), <rustc_borrowck[d2407f5e24f18162]::type_check::TypeChecker>::relate_type_and_user_type::{closure#0}, <rustc_borrowck[d2407f5e24f18162]::type_check::TypeChecker>::relate_type_and_user_type::{closure#1}>
  19:        0x118d8a1ad - <rustc_borrowck[d2407f5e24f18162]::type_check::TypeChecker>::relate_type_and_user_type
  20:        0x118d84e84 - <rustc_borrowck[d2407f5e24f18162]::type_check::TypeVerifier as rustc_middle[e2305deeabdd0cca]::mir::visit::Visitor>::visit_local_decl
  21:        0x118d85bd3 - <rustc_borrowck[d2407f5e24f18162]::type_check::TypeVerifier as rustc_middle[e2305deeabdd0cca]::mir::visit::Visitor>::visit_body
  22:        0x118d7ee38 - rustc_borrowck[d2407f5e24f18162]::type_check::type_check
  23:        0x118e8e8f2 - rustc_borrowck[d2407f5e24f18162]::nll::compute_regions
  24:        0x118ec9c90 - rustc_borrowck[d2407f5e24f18162]::do_mir_borrowck
  25:        0x118ebb75d - rustc_borrowck[d2407f5e24f18162]::mir_borrowck
  26:        0x118e9c505 - <rustc_borrowck[d2407f5e24f18162]::provide::{closure#0} as core[67cd3202410ff936]::ops::function::FnOnce<(rustc_middle[e2305deeabdd0cca]::ty::context::TyCtxt, rustc_span[663101514bc5927d]::def_id::LocalDefId)>>::call_once
  27:        0x119345c19 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<rustc_span[663101514bc5927d]::def_id::LocalDefId, &rustc_middle[e2305deeabdd0cca]::mir::query::BorrowCheckResult>>
  28:        0x11942dad3 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::mir_borrowck, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
  29:        0x1185a3ba4 - <rustc_hir_analysis[34bd11cda90a81cf]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  30:        0x1185a2fb1 - rustc_hir_analysis[34bd11cda90a81cf]::collect::type_of::find_opaque_ty_constraints_for_tait
  31:        0x11859a846 - rustc_hir_analysis[34bd11cda90a81cf]::collect::type_of::type_of
  32:        0x119369df5 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<rustc_span[663101514bc5927d]::def_id::DefId, rustc_middle[e2305deeabdd0cca]::ty::Ty>>
  33:        0x119441184 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::type_of, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
  34:        0x11854cb76 - rustc_hir_analysis[34bd11cda90a81cf]::check::check::check_item_type
  35:        0x1185535ee - rustc_hir_analysis[34bd11cda90a81cf]::check::check::check_mod_item_types
  36:        0x119349295 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<rustc_span[663101514bc5927d]::def_id::LocalDefId, ()>>
  37:        0x1194371a5 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::check_mod_item_types, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
  38:        0x11857bb58 - <rustc_middle[e2305deeabdd0cca]::hir::map::Map>::for_each_module::<rustc_hir_analysis[34bd11cda90a81cf]::check_crate::{closure#6}::{closure#0}>
  39:        0x118569f79 - <rustc_session[e61d3bba1e132503]::session::Session>::time::<(), rustc_hir_analysis[34bd11cda90a81cf]::check_crate::{closure#6}>
  40:        0x11863cecf - rustc_hir_analysis[34bd11cda90a81cf]::check_crate
  41:        0x115c2481a - rustc_interface[57c9fce0e0c2ba2]::passes::analysis
  42:        0x1193c6ffc - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::try_execute_query::<rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt, rustc_query_system[3b5dd79aa171f2d6]::query::caches::DefaultCache<(), core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>>
  43:        0x119441299 - rustc_query_system[3b5dd79aa171f2d6]::query::plumbing::get_query::<rustc_query_impl[b50f402e55213e8a]::queries::analysis, rustc_query_impl[b50f402e55213e8a]::plumbing::QueryCtxt>
  44:        0x115af0dd6 - <rustc_interface[57c9fce0e0c2ba2]::passes::QueryContext>::enter::<rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
  45:        0x115b34ecd - rustc_span[663101514bc5927d]::with_source_map::<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  46:        0x115b24f2c - <scoped_tls[6bbd84b04dbf1568]::ScopedKey<rustc_span[663101514bc5927d]::SessionGlobals>>::set::<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
  47:        0x115af431a - std[b7fc25f664aa2c42]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[57c9fce0e0c2ba2]::util::run_in_thread_pool_with_globals<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>
  48:        0x115ada3ab - <<std[b7fc25f664aa2c42]::thread::Builder>::spawn_unchecked_<rustc_interface[57c9fce0e0c2ba2]::util::run_in_thread_pool_with_globals<rustc_interface[57c9fce0e0c2ba2]::interface::run_compiler<core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>, rustc_driver[3dbfeae94bbb450c]::run_compiler::{closure#1}>::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[67cd3202410ff936]::result::Result<(), rustc_errors[3e76822466e0ccc2]::ErrorGuaranteed>>::{closure#1} as core[67cd3202410ff936]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:        0x106fc5bb7 - std::sys::unix::thread::Thread::new::thread_start::h0a480c6421a176eb
  50:     0x7ff80d84d4e1 - __pthread_start

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.67.0-nightly (a00f8ba7f 2022-11-15) running on x86_64-apple-darwin

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [type_of] computing type of `main::T::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Regression

Regression in nightly-2022-05-23, perhaps from #96515

Version

rustc 1.67.0-nightly (a00f8ba7f 2022-11-15)
binary: rustc
commit-hash: a00f8ba7fcac1b27341679c51bf5a3271fa82df3
commit-date: 2022-11-15
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +F-type_alias_impl_trait

@jruderman jruderman 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 Nov 17, 2022
@rustbot rustbot added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Nov 17, 2022
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this issue Dec 21, 2022
Fix an opaque type ICE

fixes rust-lang#104551

The issue is that if you have

```rust
type T = impl Sized;
let (_a, _b): T = ..
```

we have only the type annotation `T`, but want to use that ascription for `_a` and `_b`, so what we generate is a type ascription plus a field projection saying `_a`'s type is `T::0`. Of course `T` has no fields. Of course we could also not generate type annotations for projections into opaque types at all, but that's more fragile, as we now have to make sure that https://github.com/rust-lang/rust/blob/12bbdbdb440119a0b86d2ee742ec1460cdb2c5b9/compiler/rustc_mir_build/src/build/matches/mod.rs#L709 doesn't have any arm that introduces a user type annotation except for `PatKind::Binding`.
@bors bors closed this as completed in a4ef47d Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants