rust-lang / rust-lang/rust

[ICE]: `attribute is missing tokens: Attribute ...`

Open
#152,889 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-attributes A-macros C-bug F-autodiff I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![feature(macro_attr)]
#![feature(autodiff)]

macro_rules! forward_referenced_attr {
    attr() {} => {}
}

use std::autodiff::autodiff_reverse;

#[autodiff_reverse(Active)]
#[forward_referenced_attr]
fn main() {}

Mutant of tests/codegen-llvm/autodiff/identical_fnc.rs
and tests/ui/macros/macro-rules-attr-error.rs.

Meta

rustc --version --verbose:

rustc 1.95.0-nightly (7f99507f5 2026-02-19)
binary: rustc
commit-hash: 7f99507f57e6c4aa0dce3daf6a13cca8cd4dd312
commit-date: 2026-02-19
host: x86_64-apple-darwin
release: 1.95.0-nightly
LLVM version: 22.1.0
Error output

Command: rustc

thread 'rustc' (15497734) panicked at /rustc-dev/7f99507f57e6c4aa0dce3daf6a13cca8cd4dd312/compiler/rustc_ast/src/attr/mod.rs:335:36:
attribute is missing tokens: Attribute { kind: Normal(NormalAttr { item: AttrItem { unsafety: Default, path: Path { span: no-location (#0), segments: [PathSegment { ident: rustc_autodiff#0, id: NodeId(4294967040), args: None }], tokens: None }, args: Unparsed(Empty), tokens: None }, tokens: None }), id: AttrId(5), style: Outer, span: iter1_f4c11fd339fddc5a.rs:10:1: 10:28 (#4) }
Backtrace

stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_ast::ast::Attribute>::token_trees
   3: rustc_ast::tokenstream::attrs_and_tokens_to_token_trees
   4: <rustc_ast::tokenstream::TokenStream>::from_ast::<alloc::boxed::Box<rustc_ast::ast::Item>>
   5: <rustc_expand::expand::MacroExpander>::expand_invoc
   6: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
   7: <rustc_expand::expand::MacroExpander>::expand_crate
   8: rustc_interface::passes::configure_and_expand
   9: rustc_interface::passes::resolver_for_lowering_raw
      [... omitted 1 frame ...]
  10: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  11: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
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: please attach the file at `/Volumes/T7/workspace/out-260219/scratch/rustc-ice-2026-02-20T08_03_58-60492.txt` to your bug report

note: rustc 1.95.0-nightly (7f99507f5 2026-02-19) running on x86_64-apple-darwin

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

Notes

@rustbot label +F-autodiff

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the provided autodiff and macro attribute example, then start at compiler/rustc_ast/src/attr/mod.rs line 335. Follow the reported expansion path through rustc_expand and compare the related tests tests/codegen-llvm/autodiff/identical_fnc.rs and tests/ui/macros/macro-rules-attr-error.rs. Done means this input no longer panics and has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.