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: layout errored yet tail '{type error}' is not a type parameter or a projection #124031

Closed
matthiaskrgr opened this issue Apr 16, 2024 · 4 comments · Fixed by #124057
Closed
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 16, 2024

auto-reduced (treereduce-rust):

trait Trait {
    type RefTarget;
}

impl Trait for () {}

struct Other {
    data: <() as Trait>::RefTarget,
}

fn main() {
    unsafe {
        std::mem::transmute::<Option<()>, Option<&Other>>(None);
    }
}

original:

trait Trait {
    type RefTarget;
}

impl Trait for () where S<{}>: {}

struct Other {
    data: <() as Trait>::RefTarget,
}

fn main() {
    unsafe {
        std::mem::transmute::<Option<()>, Option<&Other>>(None);
    }
}

Version information

rustc 1.79.0-nightly (1dea922ea 2024-04-16)
binary: rustc
commit-hash: 1dea922ea6e74f99a0e97de5cdb8174e4dea0444
commit-date: 2024-04-16
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0046]: not all trait items implemented, missing: `RefTarget`
 --> /tmp/icemaker_global_tempdir.pZhDC78qbnNh/rustc_testrunner_tmpdir_reporting.yD8R6X6DQSXY/mvce.rs:5:1
  |
2 |     type RefTarget;
  |     -------------- `RefTarget` from trait
...
5 | impl Trait for () {}
  | ^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:339:26: SizeSkeleton::compute(&Other): layout errored (Unknown(Alias(Projection, AliasTy { args: [Other], def_id: DefId(2:2049 ~ core[a6f4]::ptr::metadata::Pointee::Metadata) }))), yet tail `{type error}` is not a type parameter or a projection

thread 'rustc' panicked at compiler/rustc_middle/src/ty/layout.rs:339:26:
Box<dyn Any>
stack backtrace:
   0:     0x7ddcbbec1cd5 - std::backtrace_rs::backtrace::libunwind::trace::h4570894ec6e934bd
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7ddcbbec1cd5 - std::backtrace_rs::backtrace::trace_unsynchronized::h8e38265835f5092c
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ddcbbec1cd5 - std::sys_common::backtrace::_print_fmt::hcc100545c13c51ae
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ddcbbec1cd5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h63aa418d14a98965
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ddcbbf10f9b - core::fmt::rt::Argument::fmt::h0e4984b8632d694b
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/core/src/fmt/rt.rs:165:63
   5:     0x7ddcbbf10f9b - core::fmt::write::h666dcbeea4b0bb0e
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/core/src/fmt/mod.rs:1157:21
   6:     0x7ddcbbeb68df - std::io::Write::write_fmt::h28d16f793a75f183
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/io/mod.rs:1832:15
   7:     0x7ddcbbec1aae - std::sys_common::backtrace::_print::he08fa3b3df648c57
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ddcbbec1aae - std::sys_common::backtrace::print::hbc1c6a549ba18d53
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ddcbbec4429 - std::panicking::default_hook::{{closure}}::h452c80da7053da38
  10:     0x7ddcbbec416d - std::panicking::default_hook::hed123a5761019ac1
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/panicking.rs:291:9
  11:     0x7ddcb8887a2b - std[2ce6f5251f47c1eb]::panicking::update_hook::<alloc[b271cfb3f3240113]::boxed::Box<rustc_driver_impl[41cead0f6bccae97]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ddcbbec4b2c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1ebfc40cd82c2169
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/alloc/src/boxed.rs:2032:9
  13:     0x7ddcbbec4b2c - std::panicking::rust_panic_with_hook::hcdf9ea59f53f1733
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/panicking.rs:792:13
  14:     0x7ddcb88b7fa4 - std[2ce6f5251f47c1eb]::panicking::begin_panic::<rustc_errors[a3deda365ad118db]::ExplicitBug>::{closure#0}
  15:     0x7ddcb88b4956 - std[2ce6f5251f47c1eb]::sys_common::backtrace::__rust_end_short_backtrace::<std[2ce6f5251f47c1eb]::panicking::begin_panic<rustc_errors[a3deda365ad118db]::ExplicitBug>::{closure#0}, !>
  16:     0x7ddcb88afee6 - std[2ce6f5251f47c1eb]::panicking::begin_panic::<rustc_errors[a3deda365ad118db]::ExplicitBug>
  17:     0x7ddcb88c0fd1 - <rustc_errors[a3deda365ad118db]::diagnostic::BugAbort as rustc_errors[a3deda365ad118db]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7ddcb8d6996c - rustc_middle[1c73b0b9b5d630bc]::util::bug::opt_span_bug_fmt::<rustc_span[5eb068f1d282c6c3]::span_encoding::Span>::{closure#0}
  19:     0x7ddcb8d50eba - rustc_middle[1c73b0b9b5d630bc]::ty::context::tls::with_opt::<rustc_middle[1c73b0b9b5d630bc]::util::bug::opt_span_bug_fmt<rustc_span[5eb068f1d282c6c3]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7ddcb8d50d5b - rustc_middle[1c73b0b9b5d630bc]::ty::context::tls::with_context_opt::<rustc_middle[1c73b0b9b5d630bc]::ty::context::tls::with_opt<rustc_middle[1c73b0b9b5d630bc]::util::bug::opt_span_bug_fmt<rustc_span[5eb068f1d282c6c3]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7ddcb6950ab0 - rustc_middle[1c73b0b9b5d630bc]::util::bug::bug_fmt
  22:     0x7ddcbb3980df - <rustc_middle[1c73b0b9b5d630bc]::ty::layout::SizeSkeleton>::compute.cold
  23:     0x7ddcb8d3cdf5 - <rustc_middle[1c73b0b9b5d630bc]::ty::layout::SizeSkeleton>::compute::{closure#1}
  24:     0x7ddcbb398416 - <rustc_middle[1c73b0b9b5d630bc]::ty::layout::SizeSkeleton>::compute.cold
  25:     0x7ddcba849d01 - <rustc_hir_typeck[3f614bc6655f91fa]::fn_ctxt::FnCtxt>::check_transmute
  26:     0x7ddcb9e53ec9 - rustc_hir_typeck[3f614bc6655f91fa]::typeck
  27:     0x7ddcb9e51c89 - rustc_query_impl[5bd0ae940d929779]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5bd0ae940d929779]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1c73b0b9b5d630bc]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7ddcb9e3e271 - rustc_query_system[7ae2b61b6d9bea48]::query::plumbing::try_execute_query::<rustc_query_impl[5bd0ae940d929779]::DynamicConfig<rustc_query_system[7ae2b61b6d9bea48]::query::caches::VecCache<rustc_span[5eb068f1d282c6c3]::def_id::LocalDefId, rustc_middle[1c73b0b9b5d630bc]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5bd0ae940d929779]::plumbing::QueryCtxt, false>
  29:     0x7ddcb9e3cb8c - rustc_query_impl[5bd0ae940d929779]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ddcb9e3c758 - <rustc_middle[1c73b0b9b5d630bc]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[55b246c3f202a5fd]::check_crate::{closure#4}>::{closure#0}
  31:     0x7ddcb9e3b441 - rustc_hir_analysis[55b246c3f202a5fd]::check_crate
  32:     0x7ddcba42307a - rustc_interface[e8e8772a2baf35df]::passes::analysis
  33:     0x7ddcba422bd5 - rustc_query_impl[5bd0ae940d929779]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5bd0ae940d929779]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1c73b0b9b5d630bc]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7ddcba9a2a65 - rustc_query_system[7ae2b61b6d9bea48]::query::plumbing::try_execute_query::<rustc_query_impl[5bd0ae940d929779]::DynamicConfig<rustc_query_system[7ae2b61b6d9bea48]::query::caches::SingleCache<rustc_middle[1c73b0b9b5d630bc]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5bd0ae940d929779]::plumbing::QueryCtxt, false>
  35:     0x7ddcba9a27c9 - rustc_query_impl[5bd0ae940d929779]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7ddcba890614 - rustc_interface[e8e8772a2baf35df]::interface::run_compiler::<core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>, rustc_driver_impl[41cead0f6bccae97]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7ddcba95e200 - std[2ce6f5251f47c1eb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e8e8772a2baf35df]::util::run_in_thread_with_globals<rustc_interface[e8e8772a2baf35df]::util::run_in_thread_pool_with_globals<rustc_interface[e8e8772a2baf35df]::interface::run_compiler<core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>, rustc_driver_impl[41cead0f6bccae97]::run_compiler::{closure#0}>::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>
  38:     0x7ddcba95e006 - <<std[2ce6f5251f47c1eb]::thread::Builder>::spawn_unchecked_<rustc_interface[e8e8772a2baf35df]::util::run_in_thread_with_globals<rustc_interface[e8e8772a2baf35df]::util::run_in_thread_pool_with_globals<rustc_interface[e8e8772a2baf35df]::interface::run_compiler<core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>, rustc_driver_impl[41cead0f6bccae97]::run_compiler::{closure#0}>::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a6f449f0b0283003]::result::Result<(), rustc_span[5eb068f1d282c6c3]::ErrorGuaranteed>>::{closure#2} as core[a6f449f0b0283003]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7ddcbbecea1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcc8d2a2ce029e331
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/alloc/src/boxed.rs:2018:9
  40:     0x7ddcbbecea1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h23d36ed0db50e565
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/alloc/src/boxed.rs:2018:9
  41:     0x7ddcbbecea1b - std::sys::pal::unix::thread::Thread::new::thread_start::h6f03de8fdd6d8209
                               at /rustc/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7ddcb56a955a - <unknown>
  43:     0x7ddcb5726a3c - <unknown>
  44:                0x0 - <unknown>

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: please make sure that you have updated to the latest nightly

note: rustc 1.79.0-nightly (1dea922ea 2024-04-16) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0046`.

@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. labels Apr 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 16, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: `layout errored yet tail '{type error}' is not a type parameter or a projection ICE: layout errored yet tail '{type error}' is not a type parameter or a projection Apr 16, 2024
@compiler-errors
Copy link
Member

is not a type parameter or a projection

that's true, it's a type error

(should be a quick fix)

@matthiaskrgr
Copy link
Member Author

you may also enjoy this gem:
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: {const error}: {type error} KeyNil
(found somewhere else)

@matthiaskrgr
Copy link
Member Author

Ah, this ( #123031 ) one bisects to #123491 fyi @gurry ^^

@gurry
Copy link
Contributor

gurry commented Apr 17, 2024

@rustbot claim

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 18, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 21, 2024
…=compiler-errors

Fix ICE when ADT tail has type error

Fixes rust-lang#124031
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 21, 2024
…=compiler-errors

Fix ICE when ADT tail has type error

Fixes rust-lang#124031
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Apr 22, 2024
…=compiler-errors

Fix ICE when ADT tail has type error

Fixes rust-lang#124031
@bors bors closed this as completed in 8859631 Apr 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 23, 2024
Rollup merge of rust-lang#124057 - gurry:124031-ice-layout-errored, r=compiler-errors

Fix ICE when ADT tail has type error

Fixes rust-lang#124031
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

5 participants