Skip to content

ICE: expr in place where literal is expected (builtin attr parsing) #137687

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --crate-type=lib
#[crate_name = concat!("Cloneb")]

macro_rules! inline {
    () => {};
}

original:

#[crate_name = concat!("Cloneb")]
macro_rules! mac {
    ($ident:ident) => { let $ident = 42; }
}

#[macro_export]
macro_rules! inline {
    () => ()
}

Version information

rustc 1.87.0-nightly (ac91805f3 2025-02-26)
binary: rustc
commit-hash: ac91805f3179fc2225c60e8ccf5a1daa09d43f3d
commit-date: 2025-02-26
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: unused macro definition: `inline`
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:3:14
  |
3 | macro_rules! inline {
  |              ^^^^^^
  |
  = note: `#[warn(unused_macros)]` on by default

warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:1:1
  |
1 | #[crate_name = concat!("Cloneb")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` 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: expr in place where literal is expected (builtin attr parsing)
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:1:14
  |
1 | #[crate_name = concat!("Cloneb")]
  |              ^
  |
note: delayed at compiler/rustc_attr_parsing/src/parser.rs:359:24
         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::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_attr_parsing::parser::MetaItemParser>::from_attr
         5: <rustc_resolve::def_collector::DefCollector as rustc_ast::visit::Visitor>::visit_item
         6: <rustc_resolve::def_collector::DefCollector as rustc_ast::visit::Visitor>::visit_crate
         7: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::visit_ast_fragment_with_placeholders
         8: <rustc_expand::expand::MacroExpander>::collect_invocations
         9: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
        10: <rustc_expand::expand::MacroExpander>::expand_crate
        11: rustc_interface::passes::resolver_for_lowering_raw
        12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
        13: <rustc_query_impl::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
        16: 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}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: 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}, ()>
        19: <<std::thread::Builder>::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}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: <unknown>
        22: <unknown>
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:1:14
  |
1 | #[crate_name = concat!("Cloneb")]
  |              ^

error: internal compiler error: expr in place where literal is expected (builtin attr parsing)
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:1:1
  |
1 | #[crate_name = concat!("Cloneb")]
  | ^^^^^^^^^^^^^^
  |
note: delayed at /rustc/ac91805f3179fc2225c60e8ccf5a1daa09d43f3d/compiler/rustc_attr_parsing/src/context.rs:336:43
         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::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_resolve::def_collector::DefCollector as rustc_ast::visit::Visitor>::visit_item
         5: <rustc_resolve::def_collector::DefCollector as rustc_ast::visit::Visitor>::visit_crate
         6: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::visit_ast_fragment_with_placeholders
         7: <rustc_expand::expand::MacroExpander>::collect_invocations
         8: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
         9: <rustc_expand::expand::MacroExpander>::expand_crate
        10: rustc_interface::passes::resolver_for_lowering_raw
        11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
        12: <rustc_query_impl::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        14: rustc_query_impl::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
        15: 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}::{closure#0}
        16: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        17: 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}, ()>
        18: <<std::thread::Builder>::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}
        19: std::sys::pal::unix::thread::Thread::new::thread_start
        20: <unknown>
        21: <unknown>
 --> /tmp/icemaker_global_tempdir.o4pBxOKZHwPg/rustc_testrunner_tmpdir_reporting.DGIJGRHWWShI/mvce.rs:1:1
  |
1 | #[crate_name = concat!("Cloneb")]
  | ^^^^^^^^^^^^^^

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.87.0-nightly (ac91805f3 2025-02-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

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) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy