Open
Description
Code
#![feature(where_clause_attrs)]
trait Trait {}
fn foo<'a, T>()
where
#[must_use] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
#[must_use] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
{}
Meta
rustc --version --verbose
:
rustc 1.90.0-nightly (71e4c005c 2025-07-01)
binary: rustc
commit-hash: 71e4c005caa812a16fcb08d0bf1e6f1eda7c8381
commit-date: 2025-07-01
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Error output
[jonathan@jonathan rust-test]$ cargo check
Compiling rust-test v0.1.0 (/home/jonathan/Projects/rust-test)
thread 'rustc' panicked at /rustc-dev/71e4c005caa812a16fcb08d0bf1e6f1eda7c8381/compiler/rustc_hir/src/hir.rs:1306:18:
can't get the span of an arbitrary parsed attribute: Parsed(MustUse { span: src/lib.rs:7:1: 7:12 (#0), reason: None })
stack backtrace:
Backtrace
[jonathan@jonathan rust-test]$ RUST_BACKTRACE=1 cargo check
Compiling rust-test v0.1.0 (/home/jonathan/Projects/rust-test)
thread 'rustc' panicked at /rustc-dev/71e4c005caa812a16fcb08d0bf1e6f1eda7c8381/compiler/rustc_hir/src/hir.rs:1306:18:
can't get the span of an arbitrary parsed attribute: Parsed(MustUse { span: src/lib.rs:7:1: 7:12 (#0), reason: None })
stack backtrace:
thread 'rustc' panicked at /rustc-dev/71e4c005caa812a16fcb08d0bf1e6f1eda7c8381/compiler/rustc_hir/src/hir.rs:1306:18:
can't get the span of an arbitrary parsed attribute: Parsed(MustUse { span: src/lib.rs:7:1: 7:12 (#0), reason: None })
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_generics
3: rustc_hir::intravisit::walk_fn::<rustc_passes::check_attr::CheckAttrVisitor>
0: __rustc::rust_begin_unwind
4: <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_item
1: core::panicking::panic_fmt
5: rustc_passes::check_attr::check_mod_attrs
2: <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_generics
3: rustc_hir::intravisit::walk_fn::<rustc_passes::check_attr::CheckAttrVisitor>
4: <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_item
5: rustc_passes::check_attr::check_mod_attrs
[... omitted 1 frame ...]
[... omitted 1 frame ...]
6: <rustc_middle::ty::context::TyCtxt>::par_hir_for_each_module::<rustc_interface::passes::run_required_analyses::{closure#0}::{closure#0}::{closure#1}::{closure#0}>::{closure#0}
6: <rustc_middle::ty::context::TyCtxt>::par_hir_for_each_module::<rustc_interface::passes::run_required_analyses::{closure#0}::{closure#0}::{closure#1}::{closure#0}>::{closure#0}
7: rustc_interface::passes::analysis
7: rustc_interface::passes::analysis
[... omitted 1 frame ...]
[... omitted 1 frame ...]
8: 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}
8: 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}
9: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
9: 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.
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: the compiler unexpectedly panicked. this is a bug.
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: 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 make sure that you have updated to the latest nightly
note: please attach the file at `/home/jonathan/Projects/rust-test/rustc-ice-2025-07-11T10_24_45-2273591.txt` to your bug report
note: please attach the file at `/home/jonathan/Projects/rust-test/rustc-ice-2025-07-11T10_24_45-2273590.txt` to your bug report
note: compiler flags: --crate-type proc-macro -C prefer-dynamic -C embed-bitcode=no -C incremental=[REDACTED]
note: compiler flags: --crate-type proc-macro -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
#1 [analysis] running analysis passes on this crate
end of query stack
end of query stack
error: could not compile `rust-test` (lib)
Caused by:
process didn't exit successfully: `/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rust_test --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=308 --crate-type proc-macro --emit=dep-info,metadata -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=3dbe69161b2221b0 -C extra-filename=-913e2b4cf9be94a1 --out-dir /home/jonathan/Projects/rust-test/target/debug/deps -C incremental=/home/jonathan/Projects/rust-test/target/debug/incremental -L dependency=/home/jonathan/Projects/rust-test/target/debug/deps --extern proc_macro` (exit status: 101)
warning: build failed, waiting for other jobs to finish...
error: could not compile `rust-test` (lib)
Caused by:
process didn't exit successfully: `/home/jonathan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rust_test --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=308 --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=ad6a040adb6c6e86 -C extra-filename=-51f1928c369c6aaf --out-dir /home/jonathan/Projects/rust-test/target/debug/deps -C incremental=/home/jonathan/Projects/rust-test/target/debug/incremental -L dependency=/home/jonathan/Projects/rust-test/target/debug/deps --extern proc_macro` (exit status: 101)
This applies to all new parsed attributes, not only #[must_use]
.