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: attrs: error was constructed but not emitted #118575

Closed
matthiaskrgr opened this issue Dec 3, 2023 · 5 comments · Fixed by #118182
Closed

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

matthiaskrgr opened this issue Dec 3, 2023 · 5 comments · Fixed by #118182
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:

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


@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 Dec 3, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2023
@sjwang05
Copy link
Contributor

sjwang05 commented Dec 3, 2023

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

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@sjwang05
Copy link
Contributor

sjwang05 commented Dec 4, 2023

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

@matthiaskrgr
Copy link
Member Author

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

@sjwang05
Copy link
Contributor

sjwang05 commented Dec 4, 2023

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.)

@matthiaskrgr matthiaskrgr mentioned this issue Dec 14, 2023
@bend-n
Copy link
Contributor

bend-n commented Dec 14, 2023

Can be further reduced to

fn outer() {
    #[cfg(foo)]
    cfg
    #[]
}

Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 27, 2024
Properly recover from trailing attr in body

When encountering an attribute in a body, we try to recover from an attribute on an expression (as opposed to a statement). We need to properly clean up when the attribute is at the end of the body where a tail expression would be.

Fix rust-lang#118164, fix rust-lang#118575.
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 27, 2024
Properly recover from trailing attr in body

When encountering an attribute in a body, we try to recover from an attribute on an expression (as opposed to a statement). We need to properly clean up when the attribute is at the end of the body where a tail expression would be.

Fix rust-lang#118164, fix rust-lang#118575.
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 27, 2024
Properly recover from trailing attr in body

When encountering an attribute in a body, we try to recover from an attribute on an expression (as opposed to a statement). We need to properly clean up when the attribute is at the end of the body where a tail expression would be.

Fix rust-lang#118164, fix rust-lang#118575.
@bors bors closed this as completed in 9a44176 Jan 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 27, 2024
Rollup merge of rust-lang#118182 - estebank:issue-118164, r=davidtwco

Properly recover from trailing attr in body

When encountering an attribute in a body, we try to recover from an attribute on an expression (as opposed to a statement). We need to properly clean up when the attribute is at the end of the body where a tail expression would be.

Fix rust-lang#118164, fix rust-lang#118575.
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
5 participants