diff options
| author | Eric Huss <eric@huss.org> | 2021-09-17 13:08:56 -0700 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2021-09-25 09:03:15 -0700 |
| commit | 75f058dbfd1c02daa191efb6eb53dc91fda8add6 (patch) | |
| tree | 8348ab28c41ab996e2b534c28aa6d3a79d21d6b0 /compiler/rustc_parse/src/validate_attr.rs | |
| parent | 5f8c571e50f1e0e98bb225e1dc909e73251a69be (diff) | |
| download | rust-75f058dbfd1c02daa191efb6eb53dc91fda8add6.tar.gz rust-75f058dbfd1c02daa191efb6eb53dc91fda8add6.zip | |
Check for macros in built-in attributes that don't support them.
Diffstat (limited to 'compiler/rustc_parse/src/validate_attr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/validate_attr.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 6e798fc5c20..2aa20d02c88 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -4,7 +4,7 @@ use crate::parse_in; use rustc_ast::tokenstream::{DelimSpan, TokenTree}; use rustc_ast::{self as ast, Attribute, MacArgs, MacDelimiter, MetaItem, MetaItemKind}; -use rustc_errors::{Applicability, PResult}; +use rustc_errors::{Applicability, FatalError, PResult}; use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP}; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; use rustc_session::parse::ParseSess; @@ -162,3 +162,15 @@ fn emit_malformed_attribute( .emit(); } } + +pub fn emit_fatal_malformed_builtin_attribute( + sess: &ParseSess, + attr: &Attribute, + name: Symbol, +) -> ! { + let template = BUILTIN_ATTRIBUTE_MAP.get(&name).expect("builtin attr defined").2; + emit_malformed_attribute(sess, attr, name, template); + // This is fatal, otherwise it will likely cause a cascade of other errors + // (and an error here is expected to be very rare). + FatalError.raise() +} |
