|
7 | 7 |
|
8 | 8 | use std::cell::Cell; |
9 | 9 | use std::collections::hash_map::Entry; |
| 10 | +use std::slice; |
10 | 11 |
|
11 | 12 | use rustc_abi::{Align, ExternAbi, Size}; |
12 | 13 | use rustc_ast::{AttrStyle, LitKind, MetaItemInner, MetaItemKind, ast}; |
13 | 14 | use rustc_attr_data_structures::{AttributeKind, InlineAttr, ReprAttr, find_attr}; |
| 15 | +use rustc_attr_parsing::{AttributeParser, Late}; |
14 | 16 | use rustc_data_structures::fx::FxHashMap; |
15 | 17 | use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey}; |
16 | 18 | use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute}; |
@@ -373,11 +375,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
373 | 375 | | sym::custom_mir, |
374 | 376 | .. |
375 | 377 | ] => {} |
376 | | - [name, ..] => { |
| 378 | + [name, rest@..] => { |
377 | 379 | match BUILTIN_ATTRIBUTE_MAP.get(name) { |
378 | 380 | // checked below |
379 | 381 | Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {} |
380 | 382 | Some(_) => { |
| 383 | + if rest.len() > 0 && AttributeParser::<Late>::is_parsed_attribute(slice::from_ref(name)) { |
| 384 | + // Check if we tried to use a builtin attribute as an attribute namespace, like `#[must_use::skip]`. |
| 385 | + // This check is here to solve https://github.com/rust-lang/rust/issues/137590 |
| 386 | + // An error is already produced for this case elsewhere |
| 387 | + continue |
| 388 | + } |
| 389 | + |
381 | 390 | // FIXME: differentiate between unstable and internal attributes just |
382 | 391 | // like we do with features instead of just accepting `rustc_` |
383 | 392 | // attributes by name. That should allow trimming the above list, too. |
|
0 commit comments