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: the following error was constructed but not emitted #118164

Closed
matthiaskrgr opened this issue Nov 22, 2023 · 2 comments · Fixed by #118182
Closed

ICE: the following error was constructed but not emitted #118164

matthiaskrgr opened this issue Nov 22, 2023 · 2 comments · Fixed by #118182
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

snippet:

fn bar() -> String {
    #[cfg(feature = )]
    [1, 2, 3].iter().map().collect::<String>() 
    #[attr]    
}

Version information

rustc 1.76.0-nightly (fec80b447 2023-11-21)
binary: rustc
commit-hash: fec80b4475c871ad3e4d70d29d1781ee771fe631
commit-date: 2023-11-21
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 expression, found `}`
 --> /tmp/icemaker_global_tempdir.UPwrp0vkbZg9/rustc_testrunner_tmpdir_reporting.tTQzfYW6qnY4/mvce.rs:5:1
  |
5 | }
  | ^ expected expression

thread 'rustc' panicked at compiler/rustc_errors/src/diagnostic_builder.rs:776:21:
error was constructed but not emitted
stack backtrace:
   0:     0x7f2b8c7dcafc - std::backtrace_rs::backtrace::libunwind::trace::h96b16453198fbb62
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f2b8c7dcafc - std::backtrace_rs::backtrace::trace_unsynchronized::hc56b894c61e1807b
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2b8c7dcafc - std::sys_common::backtrace::_print_fmt::h73f0b916e316d7f2
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f2b8c7dcafc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3778de479f43f3b9
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2b8c82fc80 - core::fmt::rt::Argument::fmt::ha6fe89fede47cad4
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/core/src/fmt/rt.rs:142:9
   5:     0x7f2b8c82fc80 - core::fmt::write::hb606b88f4e1d28cf
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f2b8c7d09af - std::io::Write::write_fmt::h48fea01dbf6745f5
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/io/mod.rs:1762:15
   7:     0x7f2b8c7dc8e4 - std::sys_common::backtrace::_print::h3c16a46dccc06f9c
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f2b8c7dc8e4 - std::sys_common::backtrace::print::h32043e7308f1fb89
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f2b8c7df577 - std::panicking::default_hook::{{closure}}::h37f83641e07260d5
  10:     0x7f2b8c7df2df - std::panicking::default_hook::hef1de3942981e4d6
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/panicking.rs:292:9
  11:     0x7f2b894f1790 - std[25ee9ea4cf591f91]::panicking::update_hook::<alloc[4ca211c96737eeee]::boxed::Box<rustc_driver_impl[aeb365f712975100]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f2b8c7dfcb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9a7d88e7b7066f69
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/alloc/src/boxed.rs:2021:9
  13:     0x7f2b8c7dfcb8 - std::panicking::rust_panic_with_hook::hb43b782da8bd094e
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/panicking.rs:783:13
  14:     0x7f2b8c7df9d9 - std::panicking::begin_panic_handler::{{closure}}::h8c00fe18b878e8ac
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/panicking.rs:649:13
  15:     0x7f2b8c7dcfc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h41290e67e80fb104
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f2b8c7df772 - rust_begin_unwind
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/panicking.rs:645:5
  17:     0x7f2b8c82c365 - core::panicking::panic_fmt::h6a8caa214b341e91
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/core/src/panicking.rs:72:14
  18:     0x7f2b8ae9f855 - <rustc_errors[cac49771d7b27ae0]::diagnostic_builder::DiagnosticBuilderInner as core[e87d9b99a614643c]::ops::drop::Drop>::drop
  19:     0x7f2b8ae9f894 - core[e87d9b99a614643c]::ptr::drop_in_place::<rustc_errors[cac49771d7b27ae0]::diagnostic_builder::DiagnosticBuilderInner>
  20:     0x7f2b88269249 - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::attr_on_non_tail_expr
  21:     0x7f2b8af3931b - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::parse_block_tail
  22:     0x7f2b8ae9581f - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::parse_fn
  23:     0x7f2b8af493f8 - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::parse_item_kind
  24:     0x7f2b8abec051 - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::parse_item_common
  25:     0x7f2b8abe93ad - <rustc_parse[5f3dd73e9de6daf8]::parser::Parser>::parse_mod
  26:     0x7f2b8b567ed0 - rustc_interface[139416c1630c812c]::passes::parse
  27:     0x7f2b8b567c4e - <rustc_interface[139416c1630c812c]::queries::Queries>::parse
  28:     0x7f2b8b815fdd - rustc_interface[139416c1630c812c]::interface::run_compiler::<core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>, rustc_driver_impl[aeb365f712975100]::run_compiler::{closure#0}>::{closure#0}
  29:     0x7f2b8b7a5fd4 - std[25ee9ea4cf591f91]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[139416c1630c812c]::util::run_in_thread_with_globals<rustc_interface[139416c1630c812c]::util::run_in_thread_pool_with_globals<rustc_interface[139416c1630c812c]::interface::run_compiler<core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>, rustc_driver_impl[aeb365f712975100]::run_compiler::{closure#0}>::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>
  30:     0x7f2b8b7a5dfd - <<std[25ee9ea4cf591f91]::thread::Builder>::spawn_unchecked_<rustc_interface[139416c1630c812c]::util::run_in_thread_with_globals<rustc_interface[139416c1630c812c]::util::run_in_thread_pool_with_globals<rustc_interface[139416c1630c812c]::interface::run_compiler<core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>, rustc_driver_impl[aeb365f712975100]::run_compiler::{closure#0}>::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e87d9b99a614643c]::result::Result<(), rustc_span[1af8165c9baf8c46]::ErrorGuaranteed>>::{closure#1} as core[e87d9b99a614643c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f2b8c7e9b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h190fbc5196ee75af
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/alloc/src/boxed.rs:2007:9
  32:     0x7f2b8c7e9b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h30f996fe36fb3712
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/alloc/src/boxed.rs:2007:9
  33:     0x7f2b8c7e9b75 - std::sys::unix::thread::Thread::new::thread_start::h9437103b9414df7c
                               at /rustc/fec80b4475c871ad3e4d70d29d1781ee771fe631/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7f2b866aa9eb - <unknown>
  35:     0x7f2b8672e7cc - <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 (fec80b447 2023-11-21) 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 Nov 22, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 22, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2023-11-21

#117988 ping @estebank

@estebank estebank self-assigned this Nov 22, 2023
estebank added a commit to estebank/rust that referenced this issue Nov 22, 2023
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.
estebank added a commit to estebank/rust that referenced this issue Nov 22, 2023
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.
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 25, 2023
@cushionbadak
Copy link

I found that the code snippet does not cause ICE anymore.

Meta:

rustc 1.76.0-nightly (f704f3b93 2023-12-19)
binary: rustc
commit-hash: f704f3b93b1543cf504ecca0052f9f8531b1f61f
commit-date: 2023-12-19
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6

Output:

root@807b817c6f65:/asdf# rustc snippet.rs
error: expected `;`, found `#`
 --> snippet.rs:3:47
  |
2 |     #[cfg(feature = )]
  |     ------------------ only `;` terminated statements or tail expressions are allowed after this attribute
3 |     [1, 2, 3].iter().map().collect::<String>() 
  |                                               ^ expected `;` here
4 |     #[attr]    
  |     - unexpected token
  |
help: add `;` here
  |
3 |     [1, 2, 3].iter().map().collect::<String>(); 
  |                                               +
help: alternatively, consider surrounding the expression with a block
  |
3 |     { [1, 2, 3].iter().map().collect::<String>() } 
  |     +                                            +

error: expected statement after outer attribute
 --> snippet.rs:4:5
  |
4 |     #[attr]    
  |     ^^^^^^^

error[E0601]: `main` function not found in crate `snippet`
 --> snippet.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `snippet.rs`

error: aborting due to 3 previous errors

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

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.
matthiaskrgr added a commit to matthiaskrgr/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 a5d9def 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
Development

Successfully merging a pull request may close this issue.

5 participants