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: adding a def'n for node-id NodeId(17) and def kind AnonConst but a previous def'n exists #130321

Closed
matthiaskrgr opened this issue Sep 13, 2024 · 2 comments · Fixed by #130337
Assignees
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

auto-reduced (treereduce-rust):

macro_rules! make_1 {
    () => {
        unused_braces
    };
}

fn make_1() {
    // ok
    let _: A<{ make_1!() }>; // ok
}

original:

//@ check-pass
//@ run-rustfix
#![warn(unused_braces)]

macro_rules! make_1 {
    () => (unused_braces)
}

struct A<const N: usize>;

fn make_1() {
    let _: A<7> // ok
    let _: A<{ 7 }>; //~ WARN unnecessary braces
    let _: A<{
    let _: A<7>; // ok
    let _: A<{ 7 }>; //~ WARN unnecessary braces
    let _: A<{ 3 + 5 }>; // ok
    let _: A<{make_1!()}>; // ok
}>; // ok
    let _: A<{make_1!()}>; // ok
}

Version information

rustc 1.83.0-nightly (0307e401c 2024-09-13)
binary: rustc
commit-hash: 0307e401c26699656ae08e3809e7d272f5c103f4
commit-date: 2024-09-13
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

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

Program output

error[E0412]: cannot find type `A` in this scope
 --> /tmp/icemaker_global_tempdir.20nnTggI11ue/rustc_testrunner_tmpdir_reporting.YvPvHHqLRYEe/mvce.rs:9:12
  |
9 |     let _: A<{ make_1!() }>; // ok
  |            ^ not found in this scope

error[E0425]: cannot find value `unused_braces` in this scope
 --> /tmp/icemaker_global_tempdir.20nnTggI11ue/rustc_testrunner_tmpdir_reporting.YvPvHHqLRYEe/mvce.rs:3:9
  |
3 |         unused_braces
  |         ^^^^^^^^^^^^^ not found in this scope
...
9 |     let _: A<{ make_1!() }>; // ok
  |                --------- in this macro invocation
  |
  = note: this error originates in the macro `make_1` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might be missing a const parameter
  |
7 | fn make_1<const unused_braces: /* Type */>() {
  |          +++++++++++++++++++++++++++++++++

thread 'rustc' panicked at compiler/rustc_ast_lowering/src/lib.rs:503:9:
adding a def'n for node-id NodeId(17) 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:     0x792523c73fba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfb6d8fb4f154a1fc
   1:     0x792524403257 - core::fmt::write::h7808e5e403c5f075
   2:     0x792525357af3 - std::io::Write::write_fmt::h538db9e40c2a2888
   3:     0x792523c73e12 - std::sys::backtrace::BacktraceLock::print::he7092e8746cba8fb
   4:     0x792523c76591 - std::panicking::default_hook::{{closure}}::hb4d26de5c9fcbcdc
   5:     0x792523c763c4 - std::panicking::default_hook::h810d992f1f481ea3
   6:     0x792522d7715f - std[b0815b464da53495]::panicking::update_hook::<alloc[2565d1873fda1868]::boxed::Box<rustc_driver_impl[8162622be99fcd85]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x792523c76cb8 - std::panicking::rust_panic_with_hook::h678fb9ba687f252d
   8:     0x792523c76a87 - std::panicking::begin_panic_handler::{{closure}}::hdf1255a7653694ee
   9:     0x792523c74469 - std::sys::backtrace::__rust_end_short_backtrace::h559381c391964077
  10:     0x792523c76754 - rust_begin_unwind
  11:     0x792520a94743 - core::panicking::panic_fmt::h3dc6c16be86388a1
  12:     0x792525db6c35 - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::create_def.cold
  13:     0x792524ac59a6 - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_anon_const_to_anon_const
  14:     0x792524ac563e - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_anon_const_to_const_arg_direct
  15:     0x792524abb7ee - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_qpath
  16:     0x792524ac7937 - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_ty_direct
  17:     0x792524ad2fc2 - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_block_noalloc
  18:     0x792524a99eec - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_maybe_coroutine_body
  19:     0x792524a8ac06 - <rustc_ast_lowering[8c3fea5c94799a38]::LoweringContext>::lower_item_kind
  20:     0x792524a9c833 - <rustc_ast_lowering[8c3fea5c94799a38]::item::ItemLowerer>::lower_node
  21:     0x792524a9f57f - rustc_ast_lowering[8c3fea5c94799a38]::lower_to_hir
  22:     0x792525308c20 - rustc_query_impl[83f8432e820c675c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[83f8432e820c675c]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 8usize]>>
  23:     0x792525307b39 - rustc_query_system[6df6dc7cefe5b4ac]::query::plumbing::try_execute_query::<rustc_query_impl[83f8432e820c675c]::DynamicConfig<rustc_query_system[6df6dc7cefe5b4ac]::query::caches::SingleCache<rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[83f8432e820c675c]::plumbing::QueryCtxt, false>
  24:     0x79252530775e - rustc_query_impl[83f8432e820c675c]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  25:     0x792524616985 - rustc_query_impl[83f8432e820c675c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[83f8432e820c675c]::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 8usize]>>
  26:     0x792524615f22 - rustc_query_system[6df6dc7cefe5b4ac]::query::plumbing::try_execute_query::<rustc_query_impl[83f8432e820c675c]::DynamicConfig<rustc_query_system[6df6dc7cefe5b4ac]::query::caches::VecCache<rustc_hir[26e18d3688e9fba1]::hir_id::OwnerId, rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[83f8432e820c675c]::plumbing::QueryCtxt, false>
  27:     0x792524615c8f - rustc_query_impl[83f8432e820c675c]::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7925246c3502 - <rustc_middle[759127956bc2125]::hir::map::Map>::attrs
  29:     0x79252531cf01 - rustc_passes[507916cbcf1ee5a8]::entry::entry_fn
  30:     0x79252531ce98 - rustc_query_impl[83f8432e820c675c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[83f8432e820c675c]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 12usize]>>
  31:     0x79252531ce75 - <rustc_query_impl[83f8432e820c675c]::query_impl::entry_fn::dynamic_query::{closure#2} as core[ead5fa394faa3a31]::ops::function::FnOnce<(rustc_middle[759127956bc2125]::ty::context::TyCtxt, ())>>::call_once
  32:     0x79252531c809 - rustc_query_system[6df6dc7cefe5b4ac]::query::plumbing::try_execute_query::<rustc_query_impl[83f8432e820c675c]::DynamicConfig<rustc_query_system[6df6dc7cefe5b4ac]::query::caches::SingleCache<rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[83f8432e820c675c]::plumbing::QueryCtxt, false>
  33:     0x79252531c5a9 - rustc_query_impl[83f8432e820c675c]::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
  34:     0x792524ca4983 - rustc_interface[c4b0133a9ab33d3c]::passes::run_required_analyses
  35:     0x79252518a09e - rustc_interface[c4b0133a9ab33d3c]::passes::analysis
  36:     0x79252518a071 - rustc_query_impl[83f8432e820c675c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[83f8432e820c675c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 1usize]>>
  37:     0x79252530556e - rustc_query_system[6df6dc7cefe5b4ac]::query::plumbing::try_execute_query::<rustc_query_impl[83f8432e820c675c]::DynamicConfig<rustc_query_system[6df6dc7cefe5b4ac]::query::caches::SingleCache<rustc_middle[759127956bc2125]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[83f8432e820c675c]::plumbing::QueryCtxt, false>
  38:     0x7925253052cf - rustc_query_impl[83f8432e820c675c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x79252517bffc - rustc_interface[c4b0133a9ab33d3c]::interface::run_compiler::<core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>, rustc_driver_impl[8162622be99fcd85]::run_compiler::{closure#0}>::{closure#1}
  40:     0x79252526a710 - std[b0815b464da53495]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c4b0133a9ab33d3c]::util::run_in_thread_with_globals<rustc_interface[c4b0133a9ab33d3c]::util::run_in_thread_pool_with_globals<rustc_interface[c4b0133a9ab33d3c]::interface::run_compiler<core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>, rustc_driver_impl[8162622be99fcd85]::run_compiler::{closure#0}>::{closure#1}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>::{closure#0}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>
  41:     0x79252526ad7a - <<std[b0815b464da53495]::thread::Builder>::spawn_unchecked_<rustc_interface[c4b0133a9ab33d3c]::util::run_in_thread_with_globals<rustc_interface[c4b0133a9ab33d3c]::util::run_in_thread_pool_with_globals<rustc_interface[c4b0133a9ab33d3c]::interface::run_compiler<core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>, rustc_driver_impl[8162622be99fcd85]::run_compiler::{closure#0}>::{closure#1}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>::{closure#0}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ead5fa394faa3a31]::result::Result<(), rustc_span[6d3b9e60beb0a608]::ErrorGuaranteed>>::{closure#1} as core[ead5fa394faa3a31]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x79252526b16b - std::sys::pal::unix::thread::Thread::new::thread_start::h5b72917264317154
  43:     0x79252694f39d - <unknown>
  44:     0x7925269d449c - <unknown>
  45:                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.83.0-nightly (0307e401c 2024-09-13) 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 2 previous errors

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

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

#129137 cc @camelid

@matthiaskrgr
Copy link
Member Author

macro_rules! y {
    () => {
        x
    };
}

const _: A<{ y!() }>;

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 18, 2024
@bors bors closed this as completed in 55043f0 Sep 22, 2024
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

Successfully merging a pull request may close this issue.

4 participants