Skip to content

ICE: adding a def'n for node-id NodeId(18) and def kind AnonConst but a previous def'n exists #128016

Description

auto-reduced (treereduce-rust):

macro_rules! len {
    () => {
        target
    };
}

fn main() {
    let val: [str; len!()] = [];
}

original:

#![deny("{}", equal(&1, &2))]

macro_rules! len {
    () => (target) //~  ERROR trailing semicolon
                  //~| WARN this was previously accepted
}

fn main() {
    let val: [str; len!()] = [];
}

Version information

rustc 1.81.0-nightly (2e6fc4254 2024-07-20)
binary: rustc
commit-hash: 2e6fc425411280c658d852813de01c5157255088
commit-date: 2024-07-20
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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

Program output

error[E0425]: cannot find value `target` in this scope
 --> /tmp/icemaker_global_tempdir.1khAqktZak0k/rustc_testrunner_tmpdir_reporting.F2c9o1Y4kXrG/mvce.rs:3:9
  |
3 |         target
  |         ^^^^^^ not found in this scope
...
8 |     let val: [str; len!()] = [];
  |                    ------ in this macro invocation
  |
  = note: this error originates in the macro `len` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at compiler/rustc_ast_lowering/src/lib.rs:503:9:
adding a def'n for node-id NodeId(18) and def kind AnonConst but a previous def'n exists: DefKey { parent: Some(DefIndex(4)), disambiguated_data: DisambiguatedDefPathData { data: AnonConst, disambiguator: 0 } }
stack backtrace:
   0:     0x7e8412c083a5 - std::backtrace_rs::backtrace::libunwind::trace::h160e615c518ecb01
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7e8412c083a5 - std::backtrace_rs::backtrace::trace_unsynchronized::he30c6d2f98d2efdc
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7e8412c083a5 - std::sys::backtrace::_print_fmt::hb87cad28f2e90a0b
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/sys/backtrace.rs:65:5
   3:     0x7e8412c083a5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h362429114acc76fb
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/sys/backtrace.rs:40:26
   4:     0x7e8412c57eab - core::fmt::rt::Argument::fmt::h2dd3e5813b018ccc
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/core/src/fmt/rt.rs:173:76
   5:     0x7e8412c57eab - core::fmt::write::haceebbcd70688c9b
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/core/src/fmt/mod.rs:1182:21
   6:     0x7e8412bfce7f - std::io::Write::write_fmt::h7c7b83fdf5105f1d
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/io/mod.rs:1827:15
   7:     0x7e8412c0ab91 - std::sys::backtrace::BacktraceLock::print::hd97590b35fdf3d35
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/sys/backtrace.rs:43:9
   8:     0x7e8412c0ab91 - std::panicking::default_hook::{{closure}}::h587635c60073753d
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/panicking.rs:269:22
   9:     0x7e8412c0a86c - std::panicking::default_hook::h41bedcdd5e6a0e44
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/panicking.rs:296:9
  10:     0x7e840f024e1a - std[f9e60369e5bdbf77]::panicking::update_hook::<alloc[f72c5bad8b9f51f]::boxed::Box<rustc_driver_impl[23129d3f9f762646]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7e8412c0b55f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7651476b4c558d70
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/alloc/src/boxed.rs:2084:9
  12:     0x7e8412c0b55f - std::panicking::rust_panic_with_hook::heee9f152ffb5d0c8
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/panicking.rs:808:13
  13:     0x7e8412c0b187 - std::panicking::begin_panic_handler::{{closure}}::h808b135ae5150977
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/panicking.rs:674:13
  14:     0x7e8412c08869 - std::sys::backtrace::__rust_end_short_backtrace::h3c8a02e9918c1a26
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/sys/backtrace.rs:168:18
  15:     0x7e8412c0ae14 - rust_begin_unwind
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/panicking.rs:665:5
  16:     0x7e8412c54463 - core::panicking::panic_fmt::h124ff2929e2b97c8
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/core/src/panicking.rs:74:14
  17:     0x7e8412045276 - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::create_def.cold
  18:     0x7e8410ccdfdd - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_anon_const_to_anon_const
  19:     0x7e8410ccdc72 - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_anon_const_to_const_arg_direct
  20:     0x7e8410ccd9f3 - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_array_length
  21:     0x7e8410cf9b8f - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_ty_direct
  22:     0x7e8410cae238 - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_block_noalloc
  23:     0x7e8410cd4d10 - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_maybe_coroutine_body
  24:     0x7e8410cee69f - <rustc_ast_lowering[d5c02056e301041c]::LoweringContext>::lower_item_kind
  25:     0x7e8410cd215f - <rustc_ast_lowering[d5c02056e301041c]::item::ItemLowerer>::lower_node
  26:     0x7e8410ccfb79 - rustc_ast_lowering[d5c02056e301041c]::lower_to_hir
  27:     0x7e84114c5260 - rustc_query_impl[7076d3a069d488ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7076d3a069d488ea]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7e84114c2302 - rustc_query_system[eb2b374bcd8a9022]::query::plumbing::try_execute_query::<rustc_query_impl[7076d3a069d488ea]::DynamicConfig<rustc_query_system[eb2b374bcd8a9022]::query::caches::SingleCache<rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7076d3a069d488ea]::plumbing::QueryCtxt, false>
  29:     0x7e84114c1f1e - rustc_query_impl[7076d3a069d488ea]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7e8410e9a064 - rustc_query_impl[7076d3a069d488ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7076d3a069d488ea]::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 8usize]>>
  31:     0x7e8410e9961f - rustc_query_system[eb2b374bcd8a9022]::query::plumbing::try_execute_query::<rustc_query_impl[7076d3a069d488ea]::DynamicConfig<rustc_query_system[eb2b374bcd8a9022]::query::caches::VecCache<rustc_hir[2699c16870db6088]::hir_id::OwnerId, rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7076d3a069d488ea]::plumbing::QueryCtxt, false>
  32:     0x7e8410e9938f - rustc_query_impl[7076d3a069d488ea]::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7e8410878006 - <rustc_middle[f5371164b7025427]::hir::map::Map>::attrs
  34:     0x7e84117af401 - rustc_passes[141401c4575c1f66]::entry::entry_fn
  35:     0x7e84117af398 - rustc_query_impl[7076d3a069d488ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7076d3a069d488ea]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 12usize]>>
  36:     0x7e84117af36f - <rustc_query_impl[7076d3a069d488ea]::query_impl::entry_fn::dynamic_query::{closure#2} as core[c927cdc4da4eb0de]::ops::function::FnOnce<(rustc_middle[f5371164b7025427]::ty::context::TyCtxt, ())>>::call_once
  37:     0x7e84117aec88 - rustc_query_system[eb2b374bcd8a9022]::query::plumbing::try_execute_query::<rustc_query_impl[7076d3a069d488ea]::DynamicConfig<rustc_query_system[eb2b374bcd8a9022]::query::caches::SingleCache<rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[7076d3a069d488ea]::plumbing::QueryCtxt, false>
  38:     0x7e84117aea29 - rustc_query_impl[7076d3a069d488ea]::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7e8410b0ffb2 - rustc_interface[635a4d36e766d1e0]::passes::analysis
  40:     0x7e8410b0fdc7 - rustc_query_impl[7076d3a069d488ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7076d3a069d488ea]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7e84114c3725 - rustc_query_system[eb2b374bcd8a9022]::query::plumbing::try_execute_query::<rustc_query_impl[7076d3a069d488ea]::DynamicConfig<rustc_query_system[eb2b374bcd8a9022]::query::caches::SingleCache<rustc_middle[f5371164b7025427]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7076d3a069d488ea]::plumbing::QueryCtxt, false>
  42:     0x7e84114c348f - rustc_query_impl[7076d3a069d488ea]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7e84114002c5 - rustc_interface[635a4d36e766d1e0]::interface::run_compiler::<core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>, rustc_driver_impl[23129d3f9f762646]::run_compiler::{closure#0}>::{closure#1}
  44:     0x7e8411394189 - std[f9e60369e5bdbf77]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[635a4d36e766d1e0]::util::run_in_thread_with_globals<rustc_interface[635a4d36e766d1e0]::util::run_in_thread_pool_with_globals<rustc_interface[635a4d36e766d1e0]::interface::run_compiler<core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>, rustc_driver_impl[23129d3f9f762646]::run_compiler::{closure#0}>::{closure#1}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>::{closure#0}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>
  45:     0x7e8411393f3a - <<std[f9e60369e5bdbf77]::thread::Builder>::spawn_unchecked_<rustc_interface[635a4d36e766d1e0]::util::run_in_thread_with_globals<rustc_interface[635a4d36e766d1e0]::util::run_in_thread_pool_with_globals<rustc_interface[635a4d36e766d1e0]::interface::run_compiler<core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>, rustc_driver_impl[23129d3f9f762646]::run_compiler::{closure#0}>::{closure#1}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>::{closure#0}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c927cdc4da4eb0de]::result::Result<(), rustc_span[8f3a5487dfe29266]::ErrorGuaranteed>>::{closure#1} as core[c927cdc4da4eb0de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7e8412c155bb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haeea406f77e87cac
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/alloc/src/boxed.rs:2070:9
  47:     0x7e8412c155bb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h024bb75f9bcc5dfb
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/alloc/src/boxed.rs:2070:9
  48:     0x7e8412c155bb - std::sys::pal::unix::thread::Thread::new::thread_start::h106d07b62ccda4e0
                               at /rustc/2e6fc425411280c658d852813de01c5157255088/library/std/src/sys/pal/unix/thread.rs:108:17
  49:     0x7e84129a9ded - <unknown>
  50:     0x7e8412a2d0dc - <unknown>
  51:                0x0 - <unknown>

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.81.0-nightly (2e6fc4254 2024-07-20) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [hir_crate] getting the crate HIR
#1 [hir_attrs] getting HIR owner attributes in ``
end of query stack
error: aborting due to 1 previous error

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityCritical priorityS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions