|
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}; |
@@ -384,11 +386,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
384 | 386 | | sym::custom_mir, |
385 | 387 | .. |
386 | 388 | ] => {} |
387 | | - [name, ..] => { |
| 389 | + [name, rest@..] => { |
388 | 390 | match BUILTIN_ATTRIBUTE_MAP.get(name) { |
389 | 391 | // checked below |
390 | 392 | Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {} |
391 | 393 | Some(_) => { |
| 394 | + if rest.len() > 0 && AttributeParser::<Late>::is_parsed_attribute(slice::from_ref(name)) { |
| 395 | + // Check if we tried to use a builtin attribute as an attribute namespace, like `#[must_use::skip]`. |
| 396 | + // This check is here to solve https://github.com/rust-lang/rust/issues/137590 |
| 397 | + // An error is already produced for this case elsewhere |
| 398 | + continue |
| 399 | + } |
| 400 | + |
392 | 401 | // FIXME: differentiate between unstable and internal attributes just |
393 | 402 | // like we do with features instead of just accepting `rustc_` |
394 | 403 | // attributes by name. That should allow trimming the above list, too. |
|
0 commit comments