Skip to content

ICE: attrs: error was constructed but not emitted #118575

@matthiaskrgr

Description

@matthiaskrgr
Member

snippet:

fn outer() -> u8 {
    #[cfg(foo)]
    cfg(foo)

    #[]
    fn
}

Version information

rustc 1.76.0-nightly (d5fab3376 2023-12-02)
binary: rustc
commit-hash: d5fab33766917085588d9bb4fb9477776695d98b
commit-date: 2023-12-02
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

but still crashes with

rustc 1.76.0-nightly (8b6a4a93e 2023-12-03)
binary: rustc
commit-hash: 8b6a4a93ed1bf637718e28ed266a5f6d70c2776d
commit-date: 2023-12-03
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

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

Program output

error: internal compiler error: the following error was constructed but not emitted

error: expected identifier, found `]`
 --> /tmp/icemaker_global_tempdir.E5kp2dgcGyxl/rustc_testrunner_tmpdir_reporting.LJKdvhI9GKUw/mvce.rs:5:7
  |
5 |     #[]
  |       ^ expected identifier

thread 'rustc' panicked at compiler/rustc_errors/src/diagnostic_builder.rs:768:21:
error was constructed but not emitted
stack backtrace:
   0:     0x7fb1bd9cb50c - std::backtrace_rs::backtrace::libunwind::trace::h479849121ff49a5d
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb1bd9cb50c - std::backtrace_rs::backtrace::trace_unsynchronized::hc9644f16de94df45
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb1bd9cb50c - std::sys_common::backtrace::_print_fmt::h10290334532192e1
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb1bd9cb50c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3df53d81057b3e
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb1bda1e540 - core::fmt::rt::Argument::fmt::hb8e319fcddae9a31
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb1bda1e540 - core::fmt::write::h80be9ea7045f640f
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb1bd9bf36f - std::io::Write::write_fmt::h0522d22623a1843b
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/io/mod.rs:1810:15
   7:     0x7fb1bd9cb2f4 - std::sys_common::backtrace::_print::h11954509d6d4a59e
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb1bd9cb2f4 - std::sys_common::backtrace::print::h89028ceab4fa2c56
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb1bd9cdf87 - std::panicking::default_hook::{{closure}}::ha828cf6bd2b63731
  10:     0x7fb1bd9cdcef - std::panicking::default_hook::h85bef85bc0f3798a
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:292:9
  11:     0x7fb1ba6f9490 - std[be0bda08bb484463]::panicking::update_hook::<alloc[5e2c4fa57d45c172]::boxed::Box<rustc_driver_impl[7a73365881d43582]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb1bd9ce6c8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he0dee972ea8e9cc9
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2021:9
  13:     0x7fb1bd9ce6c8 - std::panicking::rust_panic_with_hook::he9727088864fdef9
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:783:13
  14:     0x7fb1bd9ce3e9 - std::panicking::begin_panic_handler::{{closure}}::h80b7e677079c8e55
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:649:13
  15:     0x7fb1bd9cb9d6 - std::sys_common::backtrace::__rust_end_short_backtrace::hd9049e8056407812
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fb1bd9ce182 - rust_begin_unwind
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:645:5
  17:     0x7fb1bda1ac15 - core::panicking::panic_fmt::h97f53bcafbf77918
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/panicking.rs:72:14
  18:     0x7fb1bc0129e9 - <rustc_errors[d85cd907ae34f40d]::diagnostic_builder::DiagnosticBuilderInner as core[9199d425737c1d72]::ops::drop::Drop>::drop
  19:     0x7fb1bc012a16 - core[9199d425737c1d72]::ptr::drop_in_place::<rustc_errors[d85cd907ae34f40d]::diagnostic_builder::DiagnosticBuilderInner>
  20:     0x7fb1b9424157 - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::attr_on_non_tail_expr
  21:     0x7fb1bc0c6cb0 - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::parse_block_tail
  22:     0x7fb1bbde159f - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::parse_fn
  23:     0x7fb1bc0b4c2f - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::parse_item_kind
  24:     0x7fb1bbdf993f - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::parse_item_common
  25:     0x7fb1bbdf6fec - <rustc_parse[e3a3cb118eb68122]::parser::Parser>::parse_mod
  26:     0x7fb1bc972350 - rustc_interface[2959b8b48a60afbe]::passes::parse
  27:     0x7fb1bc9720ce - <rustc_interface[2959b8b48a60afbe]::queries::Queries>::parse
  28:     0x7fb1bc968de5 - rustc_interface[2959b8b48a60afbe]::interface::run_compiler::<core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>, rustc_driver_impl[7a73365881d43582]::run_compiler::{closure#0}>::{closure#0}
  29:     0x7fb1bc95c411 - std[be0bda08bb484463]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2959b8b48a60afbe]::util::run_in_thread_with_globals<rustc_interface[2959b8b48a60afbe]::util::run_in_thread_pool_with_globals<rustc_interface[2959b8b48a60afbe]::interface::run_compiler<core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>, rustc_driver_impl[7a73365881d43582]::run_compiler::{closure#0}>::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>
  30:     0x7fb1bc95c23b - <<std[be0bda08bb484463]::thread::Builder>::spawn_unchecked_<rustc_interface[2959b8b48a60afbe]::util::run_in_thread_with_globals<rustc_interface[2959b8b48a60afbe]::util::run_in_thread_pool_with_globals<rustc_interface[2959b8b48a60afbe]::interface::run_compiler<core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>, rustc_driver_impl[7a73365881d43582]::run_compiler::{closure#0}>::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9199d425737c1d72]::result::Result<(), rustc_span[baba122c7922aac3]::ErrorGuaranteed>>::{closure#1} as core[9199d425737c1d72]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7fb1bd9d8555 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h97e5c9d6b1622657
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2007:9
  32:     0x7fb1bd9d8555 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb5f6014336ba501b
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2007:9
  33:     0x7fb1bd9d8555 - std::sys::unix::thread::Thread::new::thread_start::h758e18463c2780d9
                               at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7fb1b78aa9eb - <unknown>
  35:     0x7fb1b792e7cc - <unknown>
  36:                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: rustc 1.76.0-nightly (d5fab3376 2023-12-02) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 2 previous errors


Activity

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Dec 3, 2023
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 3, 2023
sjwang05

sjwang05 commented on Dec 3, 2023

@sjwang05
Contributor

Reduced further:

fn outer() -> u8 {
    #[cfg(foo)]
    cfg(foo)
    #[]
}

searched nightlies: from nightly-2023-11-17 to nightly-2023-12-02
regressed nightly: nightly-2023-11-21
searched commit range: 9a66e44...3a85a5c
regressed commit: 46ecc10

bisected with cargo-bisect-rustc v0.6.7

Host triple: x86_64-pc-windows-msvc
Reproduce with:

cargo bisect-rustc

Looks like #117988

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 4, 2023
sjwang05

sjwang05 commented on Dec 4, 2023

@sjwang05
Contributor

This might be a duplicate of #118164, now that I've taken another look at it

matthiaskrgr

matthiaskrgr commented on Dec 4, 2023

@matthiaskrgr
MemberAuthor

When I checked, 118164 was already fixed but this one wasn't

sjwang05

sjwang05 commented on Dec 4, 2023

@sjwang05
Contributor

You're right--#118164 doesn't reproduce with the latest nightly, but this one does, which I find strange since I thought they have the same root cause, which #118182 should address. (Hence also why I closed #118582--it almost exactly duplicated the work in #118182.)

bend-n

bend-n commented on Dec 14, 2023

@bend-n
Contributor

Can be further reduced to

fn outer() {
    #[cfg(foo)]
    cfg
    #[]
}
added 3 commits that reference this issue on Jan 27, 2024
00f5e09
4d47308
a542c31
added a commit that references this issue on Jan 27, 2024
9a44176
added a commit that references this issue on Jan 27, 2024
c330672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @matthiaskrgr@saethlin@rustbot@sjwang05@bend-n

      Issue actions

        ICE: attrs: `error was constructed but not emitted` · Issue #118575 · rust-lang/rust