Skip to content

[ICE]: Macro captures a list meta item with $m:meta and passes it directly to #[derive] causes must not be empty and have no suggestion #161472

Closed

Description

@KevinA-cpu

Code

extern crate core;

macro_rules! m { ($m:meta) => { #[derive($m)] pub struct S; }; }

m!(a(::b::c));

Not reproducible using the playground
Discovered while adding regression tests for issue: #53048
PR: #161412

Meta

rustc 1.100.0-nightly

Error output

  thread 'rustc' (96729) panicked at compiler/rustc_errors/src/diagnostic.rs:1041:17:
  Span `/checkout/tests/ui/macros/meta-item-global-path-fail-issue-53048.rs:9:5: 9:5 (#0)` must not be empty and have no suggestion
 stack backtrace:
     0: __rustc::rust_begin_unwind
     1: core::panicking::panic_fmt
     2: <core::iter::adapters::map::Map<core::array::iter::IntoIter<alloc::string::String, 1>, <rustc_errors::diagnostic::Diag<()>>::span_suggestions_with_style<rustc_error_messages::DiagMessage, core::array::iter::IntoIter<alloc::string::String, 1>>::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<rustc_errors::Substitution, <alloc::vec::Vec<rustc_errors::Substitution>>::extend_trusted<core::iter::adapters::map::Map<core::array::iter::IntoIter<alloc::string::String, 1>, <rustc_errors::diagnostic::Diag<()>>::span_suggestions_with_style<rustc_error_messages::DiagMessage, core::array::iter::IntoIter<alloc::string::String, 1>>::{closure#0}>>::{closure#0}>::{closure#0}>
     3: <alloc::vec::Vec<rustc_errors::Substitution> as alloc::vec::spec_from_iter::SpecFromIter<rustc_errors::Substitution, core::iter::adapters::map::Map<core::array::iter::IntoIter<alloc::string::String, 1>, <rustc_errors::diagnostic::Diag>::span_suggestions_with_style<rustc_error_messages::DiagMessage, core::array::iter::IntoIter<alloc::string::String, 1>>::{closure#0}>>>::from_iter
     4: <rustc_errors::diagnostic::Diag>::span_suggestions_with_style::<rustc_error_messages::DiagMessage, core::array::iter::IntoIter<alloc::string::String, 1>>
     5: <rustc_builtin_macros::diagnostics::DerivePathArgsList as rustc_errors::diagnostic::Diagnostic>::into_diag
     6: rustc_builtin_macros::derive::report_path_args
     7: <core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::filter_map::FilterMap<core::slice::iter::Iter<rustc_ast::ast::MetaItemInner>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#0}>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#1}>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#2}> as core::iter::traits::iterator::Iterator>::next
     8: <alloc::vec::Vec<rustc_expand::base::DeriveResolution> as alloc::vec::spec_from_iter::SpecFromIter<rustc_expand::base::DeriveResolution, core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::filter_map::FilterMap<core::slice::iter::Iter<rustc_ast::ast::MetaItemInner>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#0}>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#1}>, <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}::{closure#2}>>>::from_iter
     9: <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}
    10: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::resolve_derives
    11: <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand
    12: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
    13: <rustc_expand::expand::MacroExpander>::expand_crate
    14: <rustc_session::session::Session>::time::<rustc_ast::ast::Crate, rustc_interface::passes::configure_and_expand::{closure#1}>
    15: rustc_interface::passes::resolver_for_lowering_raw
        [... omitted 2 frames ...]
    16: <rustc_middle::ty::context::TyCtxt>::resolver_for_lowering
    17: std::panicking::catch_unwind::<core::option::Option<rustc_interface::queries::Linker>, core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>::{closure#2}::{closure#0}>>
    18: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
    19: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>::{closure#2}>
    20: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>
    21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}::{closure#0}>>
    22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
    23: rustc_span::create_session_globals_then::<(), 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#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  
  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: please make sure that you have updated to the latest nightly
  
  note: rustc 1.100.0-nightly (70a12f98c 2026-08-20) running on aarch64-unknown-linux-gnu
  
  note: compiler flags: -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0
  
  query stack during panic:
  #0 [resolver_for_lowering_raw] getting the resolver for lowering
  end of query stack

Activity

  1. 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 Aug 21, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 21, 2026
  3. KevinA-cpu commented on Aug 21, 2026

    @KevinA-cpu
    ContributorAuthor

    @rustbot label +requires-debug-assertions +S-has-mcve +A-diagnostics +A-suggestion-diagnostics +A-macros +A-attributes

  4. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
    requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    on Aug 21, 2026
  5. bb1yd commented on Aug 22, 2026

    @bb1yd
    Contributor

    @rustbot claim

  6. added a commit that references this issue on Sep 4, 2026
    4dfe838
  7. added 5 commits that reference this issue on Sep 4, 2026
    53e9793
    9bf54e1
    75c8b18
    65b634c
    7b7df24
  8. added a commit that references this issue on Sep 4, 2026
    2513462
  9. added a commit that references this issue on Sep 5, 2026
    5aa63be
  10. added a commit that references this issue on Sep 7, 2026
    3fc1dda
  11. added a commit that references this issue on Sep 7, 2026
    eb98cdf
  12. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions