Skip to content

[ICE]: internal compiler error: expected expression, found <eof> #152744

@matthiaskrgr

Description

@matthiaskrgr

Code

trait Foo {}
#[diagnostic::do_not_recommend(if not_accepted)]
impl Foo for (){}

Meta

rustc --version --verbose:

rustc 1.95.0-nightly (3c9faa0d0 2026-02-16)
binary: rustc
commit-hash: 3c9faa0d037b9eecda4a440cc482ff7f960fb8a5
commit-date: 2026-02-16
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Error output

<output>
Backtrace

warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
 --> a.rs:2:1
  |
2 | #[diagnostic::do_not_recommend(if not_accepted)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default

warning: trait `Foo` is never used
 --> a.rs:1:7
  |
1 | trait Foo {}
  |       ^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 2 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: expected expression, found `<eof>`
 --> a.rs:2:35
  |
2 | #[diagnostic::do_not_recommend(if not_accepted)]
  |                                   ^^^^^^^^^^^^ expected expression
  |
note: delayed at /rustc-dev/3c9faa0d037b9eecda4a440cc482ff7f960fb8a5/compiler/rustc_parse/src/parser/diagnostics.rs:2456:34
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::diagnostic::Diag>::delay_as_bug
         4: <rustc_parse::parser::Parser>::error_block_no_opening_brace_msg
         5: <rustc_parse::parser::Parser>::parse_block_common
         6: <rustc_parse::parser::Parser>::parse_block
         7: <rustc_parse::parser::Parser>::parse_if_after_cond
         8: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
         9: <rustc_parse::parser::Parser>::parse_expr_assoc_with
        10: <rustc_parse::parser::Parser>::parse_stmt_without_recovery
        11: <rustc_attr_parsing::parser::MetaItemListParserContext>::expected_lit
        12: <rustc_attr_parsing::parser::MetaItemListParser>::new
        13: <rustc_attr_parsing::interface::AttributeParser>::parse_attribute_list::<<rustc_ast_lowering::LoweringContext>::lower_attrs_vec::{closure#0}, <rustc_ast_lowering::LoweringContext>::lower_attrs_vec::{closure#1}>
        14: <rustc_ast_lowering::item::ItemLowerer>::lower_node
        15: rustc_ast_lowering::lower_to_hir
        16: rustc_query_impl::query_impl::hir_crate::invoke_provider_fn::__rust_begin_short_backtrace
        17: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
        18: rustc_query_impl::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
        19: rustc_query_impl::query_impl::opt_hir_owner_nodes::invoke_provider_fn::__rust_begin_short_backtrace
        20: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: true }}, false>
        21: rustc_query_impl::query_impl::opt_hir_owner_nodes::get_query_non_incr::__rust_end_short_backtrace
        22: <rustc_middle::ty::context::TyCtxt>::hir_owner_node
        23: rustc_middle::hir::map::hir_crate_items
        24: rustc_query_impl::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
        25: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
        26: rustc_query_impl::query_impl::hir_crate_items::get_query_non_incr::__rust_end_short_backtrace
        27: rustc_interface::passes::analysis
        28: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
        29: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        30: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
        31: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        32: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        33: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        34: <std::sys::thread::unix::Thread>::new::thread_start
        35: <unknown>
        36: <unknown>

 --> a.rs:2:35
  |
2 | #[diagnostic::do_not_recommend(if not_accepted)]
  |                                   ^^^^^^^^^^^^

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: please attach the file at `/tmp/im2/rustc-ice-2026-02-17T05_57_01-1348073.txt` to your bug report

note: rustc 1.95.0-nightly (3c9faa0d0 2026-02-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)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

Development

No branches or pull requests

Issue actions