Skip to content

[ICE]: attribute is missing tokens: Attribute ... #152889

Description

@cushionbadak

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

  • ICE location: compiler/rustc_ast/src/attr/mod.rs Line-335

    pub fn token_trees(&self) -> Vec<TokenTree> {
    match self.kind {
    AttrKind::Normal(ref normal) => normal
    .tokens
    .as_ref()
    .unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
    .to_attr_token_stream()
    .to_token_trees(),
    AttrKind::DocComment(comment_kind, data) => vec![TokenTree::token_alone(
    token::DocComment(comment_kind, self.style, data),
    self.span,
    )],
    }
    }
    }

  • Seems like autodiff is the core part to trigger the ICE, since the combination of autodiff and contracts features also shows the same ICE location (e.g., using both requires attribute & autodiff_reverse attributes).

  • Duplication Check

@rustbot label +F-autodiff

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Feb 20, 2026
  2. added
    needs-triage
    F-autodiff
    on Feb 20, 2026
  3. added
    A-macros
    A-attributes
    on Feb 20, 2026
  4. bb1yd commented on Nov 2, 2026

    @bb1yd
    Contributor

    @rustbot claim

  5. added
    S-found-by-fuzzing
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesA-macrosC-bugF-autodiffI-ICES-found-by-fuzzingT-compilerneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions