rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.44k stars 12.73k forks source link

ICE: `still mutable` #125668

Open matthiaskrgr opened 5 months ago

matthiaskrgr commented 5 months ago

auto-reduced (treereduce-rust):

struct Thingu {
    Thingux:  [X; -const {-X}]  match ,
    y: u32
}

original:

struct Thingu {
    Thingux:  [X; -const {-X}]  match ,
    y: u32
}

#[derive(Debug, Copy, Clnne)]struct std<'a, X> {
    X: [X; -const {-}],
    y: [[X; -const  continue {-X}]; -const {-X}]
}struct std {
    Thingx:   y: [[X; -const {-X}]; --X]
}

Version information

rustc 1.80.0-nightly (7717a306b 2024-05-28)
binary: rustc
commit-hash: 7717a306b2678ba9ece19b723c76a6b3a89ba931
commit-date: 2024-05-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

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

Program output

``` error: expected `,`, or `}`, found keyword `match` --> /tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs:2:31 | 2 | Thingux: [X; -const {-X}] match , | ^ help: try adding a comma: `,` error: expected identifier, found keyword `match` --> /tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs:2:33 | 1 | struct Thingu { | ------ while parsing this struct 2 | Thingux: [X; -const {-X}] match , | ^^^^^ expected identifier, found keyword | help: escape `match` to use it as an identifier | 2 | Thingux: [X; -const {-X}] r#match , | ++ error[E0412]: cannot find type `X` in this scope --> /tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs:2:16 | 2 | Thingux: [X; -const {-X}] match , | ^ not found in this scope | help: you might be missing a type parameter | 1 | struct Thingu { | +++ error[E0425]: cannot find value `X` in this scope --> /tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs:2:28 | 2 | Thingux: [X; -const {-X}] match , | ^ not found in this scope | help: you might be missing a const parameter | 1 | struct Thingu { | +++++++++++++++++++++ error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs:4:2 | 4 | } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.RIXVA1mbOiVa/rustc_testrunner_tmpdir_reporting.UhMokt5Os0j1/mvce.rs` thread 'rustc' panicked at compiler/rustc_middle/src/ty/context.rs:1350:49: still mutable stack backtrace: 0: 0x706b05a60ae5 - std::backtrace_rs::backtrace::libunwind::trace::h8e3ec5065424d28b at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x706b05a60ae5 - std::backtrace_rs::backtrace::trace_unsynchronized::h882cf49e59475dbc at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x706b05a60ae5 - std::sys_common::backtrace::_print_fmt::h2c337a2c4b83dc01 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:68:5 3: 0x706b05a60ae5 - ::fmt::h5fad958b7140a660 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:44:22 4: 0x706b05ab15db - core::fmt::rt::Argument::fmt::h9f1efa968e340ff7 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/rt.rs:165:63 5: 0x706b05ab15db - core::fmt::write::hc4341e028d4aa04e at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/mod.rs:1168:21 6: 0x706b05a5586f - std::io::Write::write_fmt::hf3dd4197197b5730 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/io/mod.rs:1835:15 7: 0x706b05a608be - std::sys_common::backtrace::_print::hee589e8f95e333af at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:47:5 8: 0x706b05a608be - std::sys_common::backtrace::print::hc6a85e053c1c7334 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:34:9 9: 0x706b05a632e9 - std::panicking::default_hook::{{closure}}::he62a1676f96fee54 10: 0x706b05a6308a - std::panicking::default_hook::h2ceb904f12dea8be at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:298:9 11: 0x706b0238e6a0 - std[d6c1f98fb4e95ff7]::panicking::update_hook::>::{closure#0} 12: 0x706b05a63a1b - as core::ops::function::Fn>::call::hc5b72f85a4688529 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2077:9 13: 0x706b05a63a1b - std::panicking::rust_panic_with_hook::h0a690364d46daaac at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:799:13 14: 0x706b05a63794 - std::panicking::begin_panic_handler::{{closure}}::h9c10c03249dd0030 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:664:13 15: 0x706b05a60fa9 - std::sys_common::backtrace::__rust_end_short_backtrace::h599802efea5774a9 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:171:18 16: 0x706b05a634c7 - rust_begin_unwind at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:652:5 17: 0x706b05aadb73 - core::panicking::panic_fmt::h16f8f3f4aae78ff5 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/panicking.rs:72:14 18: 0x706b05aad91b - core::panicking::panic_display::hd37bbef51df3a6ae at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/panicking.rs:262:5 19: 0x706b05aad91b - core::option::expect_failed::hded3cd93e8782a18 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/option.rs:1997:5 20: 0x706b0118113e - ::create_def 21: 0x706b00ad25c8 - ::visit_expr 22: 0x706b00ad0df0 - ::visit_expr 23: 0x706b04270447 - ::resolve_type_vars_in_body 24: 0x706b03b836c2 - rustc_hir_typeck[1894e698386f9cd2]::typeck 25: 0x706b03b825d1 - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::> 26: 0x706b039c212e - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false> 27: 0x706b039c0c55 - rustc_query_impl[a43b8a3fae63a645]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 28: 0x706b039c34a1 - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::> 29: 0x706b039c212e - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false> 30: 0x706b039c1acd - rustc_query_impl[a43b8a3fae63a645]::query_impl::used_trait_imports::get_query_non_incr::__rust_end_short_backtrace 31: 0x706b039c14fb - rustc_hir_analysis[4a9f7cb3dd37a3dc]::check_unused::check_unused_traits 32: 0x706b039c1363 - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::> 33: 0x706b04599f01 - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false> 34: 0x706b04599cab - rustc_query_impl[a43b8a3fae63a645]::query_impl::check_unused_traits::get_query_non_incr::__rust_end_short_backtrace 35: 0x706b039bf2fb - rustc_hir_analysis[4a9f7cb3dd37a3dc]::check_crate 36: 0x706b041683fe - rustc_interface[3320d9bec8b3433a]::passes::analysis 37: 0x706b04167f5b - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::> 38: 0x706b0459c225 - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false> 39: 0x706b0459bf8f - rustc_query_impl[a43b8a3fae63a645]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 40: 0x706b043f9f5c - rustc_interface[3320d9bec8b3433a]::interface::run_compiler::, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1} 41: 0x706b043c0609 - std[d6c1f98fb4e95ff7]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>> 42: 0x706b043c03b2 - <::spawn_unchecked_, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#2} as core[5e8023d66ded8339]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 43: 0x706b05a6d9eb - as core::ops::function::FnOnce>::call_once::ha3f12f701ab217ba at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9 44: 0x706b05a6d9eb - as core::ops::function::FnOnce>::call_once::hbabc732018734ba3 at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9 45: 0x706b05a6d9eb - std::sys::pal::unix::thread::Thread::new::thread_start::h25b845304e0b166b at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys/pal/unix/thread.rs:108:17 46: 0x706aff0aa1cf - 47: 0x706aff12b6ec - 48: 0x0 - 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: please make sure that you have updated to the latest nightly note: rustc 1.80.0-nightly (7717a306b 2024-05-28) running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `Thingu::Thingux::{constant#0}` #1 [used_trait_imports] finding used_trait_imports `Thingu::Thingux::{constant#0}` end of query stack error: aborting due to 5 previous errors Some errors have detailed explanations: E0412, E0425, E0601. For more information about an error, try `rustc --explain E0412`. ```

matthiaskrgr commented 5 months ago

mvce: type A = [u32; const { X }];

theemathas commented 5 months ago

The undeclared variable isn't needed for the ICE. This code also causes an ICE: type A = [i32; const { 2 }];