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: ty: .. should not have user provided type Canonical { .. } recorded #138210

Closed
matthiaskrgr opened this issue Mar 8, 2025 · 1 comment
Closed
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

snippet:

struct A<B>
where
    [(); std::mem::offset_of!((xmm_reg), 2u32)]:;

impl<'i> Foo {
    fn bar<const V: u8>() {
        let V;
    }
}

Version information

rustc 1.87.0-nightly (20f0108ad 2025-03-08)
binary: rustc
commit-hash: 20f0108ada90e37c2350ad68fdc6afe56f51539d
commit-date: 2025-03-08
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/20f0108ada90e37c2350ad68fdc6afe56f51539d/compiler/rustc_mir_build/src/thir/util.rs#L19-L31

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir --edition=2024

Program output

warning: suffixes on a tuple index are invalid
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:3:42
  |
3 |     [(); std::mem::offset_of!((xmm_reg), 2u32)]:;
  |                                          ^^^^ invalid suffix `u32`
  |
  = help: `u32` is *temporarily* accepted on tuple index fields as it was incorrectly accepted on stable for a few releases
  = help: on proc macros, you'll want to use `syn::Index::from` or `proc_macro::Literal::*_unsuffixed` for code that will desugar to tuple field access
  = help: see issue #60210 <https://github.com/rust-lang/rust/issues/60210> for more information

error[E0412]: cannot find type `xmm_reg` in this scope
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:3:32
  |
3 |     [(); std::mem::offset_of!((xmm_reg), 2u32)]:;
  |                                ^^^^^^^ not found in this scope

error[E0412]: cannot find type `Foo` in this scope
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:5:10
  |
5 | impl<'i> Foo {
  |          ^^^ not found in this scope

warning: unnecessary parentheses around type
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:3:31
  |
3 |     [(); std::mem::offset_of!((xmm_reg), 2u32)]:;
  |                               ^       ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
3 -     [(); std::mem::offset_of!((xmm_reg), 2u32)]:;
3 +     [(); std::mem::offset_of!(xmm_reg, 2u32)]:;
  |

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs`

error[E0392]: type parameter `B` is never used
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:1:10
  |
1 | struct A<B>
  |          ^ unused type parameter
  |
  = help: consider removing `B`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `B` to be a const parameter, use `const B: /* Type */` instead

error[E0158]: constant parameters cannot be referenced in patterns
 --> /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:7:13
  |
6 |     fn bar<const V: u8>() {
  |            ----------- constant defined here
7 |         let V;
  |             ^ can't be used in patterns

error: internal compiler error: compiler/rustc_mir_build/src/thir/util.rs:25:14: ty: u8 should not have user provided type Canonical { value: UserType { kind: TypeOf(DefId(0:10 ~ mvce[a2ab]::{impl#0}::bar::V), UserArgs { args: ['i/#0, V/#1], user_self_ty: None }), bounds: [] }, max_universe: U0, variables: [] } recorded 


thread 'rustc' panicked at compiler/rustc_mir_build/src/thir/util.rs:25:14:
Box<dyn Any>
stack backtrace:
   0:     0x737726dc6f34 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h07b2089c80742ed5
   1:     0x737727605aa2 - core::fmt::write::h332ae571ae4a9cc4
   2:     0x7377289e3a11 - std::io::Write::write_fmt::h0c761025205b813c
   3:     0x737726dc6d92 - std::sys::backtrace::BacktraceLock::print::hbba93a9383b9fa8a
   4:     0x737726dc9672 - std::panicking::default_hook::{{closure}}::h00e63950a63732af
   5:     0x737726dc9264 - std::panicking::default_hook::h400dc9bc1b724c37
   6:     0x737725f204e7 - std[c20316ad899fcaf5]::panicking::update_hook::<alloc[2db8fd01bd7ea837]::boxed::Box<rustc_driver_impl[153d3eccf0c7c750]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x737726dc9ee3 - std::panicking::rust_panic_with_hook::he428532615a29ae4
   8:     0x737725f5c8b1 - std[c20316ad899fcaf5]::panicking::begin_panic::<rustc_errors[223b1fcbe704e7fc]::ExplicitBug>::{closure#0}
   9:     0x737725f50de6 - std[c20316ad899fcaf5]::sys::backtrace::__rust_end_short_backtrace::<std[c20316ad899fcaf5]::panicking::begin_panic<rustc_errors[223b1fcbe704e7fc]::ExplicitBug>::{closure#0}, !>
  10:     0x737725f50dd3 - std[c20316ad899fcaf5]::panicking::begin_panic::<rustc_errors[223b1fcbe704e7fc]::ExplicitBug>
  11:     0x737725f663d1 - <rustc_errors[223b1fcbe704e7fc]::diagnostic::BugAbort as rustc_errors[223b1fcbe704e7fc]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x73772653bf16 - rustc_middle[b1dca1d1b343b3c]::util::bug::opt_span_bug_fmt::<rustc_span[268b27c29cacb432]::span_encoding::Span>::{closure#0}
  13:     0x737726523a3a - rustc_middle[b1dca1d1b343b3c]::ty::context::tls::with_opt::<rustc_middle[b1dca1d1b343b3c]::util::bug::opt_span_bug_fmt<rustc_span[268b27c29cacb432]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7377265238ab - rustc_middle[b1dca1d1b343b3c]::ty::context::tls::with_context_opt::<rustc_middle[b1dca1d1b343b3c]::ty::context::tls::with_opt<rustc_middle[b1dca1d1b343b3c]::util::bug::opt_span_bug_fmt<rustc_span[268b27c29cacb432]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x737724727f10 - rustc_middle[b1dca1d1b343b3c]::util::bug::bug_fmt
  16:     0x73772900ac37 - rustc_mir_build[8209410d05607d89]::thir::util::user_args_applied_to_ty_of_hir_id.cold
  17:     0x737727ff5ed8 - <rustc_mir_build[8209410d05607d89]::thir::pattern::PatCtxt>::lower_variant_or_leaf
  18:     0x737727ff67f2 - <rustc_mir_build[8209410d05607d89]::thir::pattern::PatCtxt>::lower_pat_expr
  19:     0x737727ff2aa8 - <rustc_mir_build[8209410d05607d89]::thir::pattern::PatCtxt>::lower_pattern
  20:     0x737727ff16cc - <rustc_mir_build[8209410d05607d89]::thir::cx::ThirBuildCx>::pattern_from_hir
  21:     0x737727fe7245 - <rustc_mir_build[8209410d05607d89]::thir::cx::ThirBuildCx>::mirror_stmts::{closure#0}
  22:     0x737727feac2d - <rustc_mir_build[8209410d05607d89]::thir::cx::ThirBuildCx>::mirror_expr
  23:     0x737727fffcb9 - rustc_mir_build[8209410d05607d89]::thir::cx::thir_body
  24:     0x737727fff6dc - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::thir_body::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 16usize]>>
  25:     0x7377282abc4e - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_data_structures[59c1b7daa758d1f8]::vec_cache::VecCache<rustc_span[268b27c29cacb432]::def_id::LocalDefId, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[75007086aa92bf3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, true>
  26:     0x7377282ab404 - rustc_query_impl[824584145395502d]::query_impl::thir_body::get_query_incr::__rust_end_short_backtrace
  27:     0x7377242ed85f - rustc_mir_build[8209410d05607d89]::check_unsafety::check_unsafety
  28:     0x737727b2aceb - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>>
  29:     0x737727b2ce02 - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_data_structures[59c1b7daa758d1f8]::vec_cache::VecCache<rustc_span[268b27c29cacb432]::def_id::LocalDefId, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[75007086aa92bf3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, true>
  30:     0x737727b2c8f8 - rustc_query_impl[824584145395502d]::query_impl::check_unsafety::get_query_incr::__rust_end_short_backtrace
  31:     0x737727b286a6 - rustc_interface[7e29b5e2b62c504d]::passes::run_required_analyses
  32:     0x7377285c1b7a - rustc_interface[7e29b5e2b62c504d]::passes::analysis
  33:     0x7377285c1b59 - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>>
  34:     0x7377285bcf2a - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_query_system[75007086aa92bf3]::query::caches::SingleCache<rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, true>
  35:     0x7377285bca36 - rustc_query_impl[824584145395502d]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  36:     0x73772871577d - rustc_interface[7e29b5e2b62c504d]::passes::create_and_enter_global_ctxt::<core[8e02e1de5014891c]::option::Option<rustc_interface[7e29b5e2b62c504d]::queries::Linker>, rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  37:     0x7377287056a0 - rustc_interface[7e29b5e2b62c504d]::interface::run_compiler::<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7377285abe48 - std[c20316ad899fcaf5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_with_globals<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_pool_with_globals<rustc_interface[7e29b5e2b62c504d]::interface::run_compiler<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x7377285ac734 - <<std[c20316ad899fcaf5]::thread::Builder>::spawn_unchecked_<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_with_globals<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_pool_with_globals<rustc_interface[7e29b5e2b62c504d]::interface::run_compiler<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8e02e1de5014891c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7377285adb2b - std::sys::pal::unix::thread::Thread::new::thread_start::h63137a35d539f669
  41:     0x7377226a370a - <unknown>
  42:     0x737722727aac - <unknown>
  43:                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.87.0-nightly (20f0108ad 2025-03-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir

query stack during panic:
#0 [thir_body] building THIR for `<impl at /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:5:1: 5:13>::bar`
#1 [check_unsafety] unsafety-checking `<impl at /tmp/icemaker_global_tempdir.Y33gc0WHlrYi/rustc_testrunner_tmpdir_reporting.G7FyDAXJdj3I/mvce.rs:5:1: 5:13>::bar`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0158, E0392, E0412, E0601.
For more information about an error, try `rustc --explain E0158`.

@matthiaskrgr matthiaskrgr 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 Mar 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
@matthiaskrgr
Copy link
Member Author

seems to bisect to #137617

smaller

impl<'a> b {
    fn bar<const c: u8>() {
        let c;
    }
}

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants