1
Fork 0

Tweak stability attribute diagnostic output

This commit is contained in:
Esteban Küber 2021-02-10 21:35:27 -08:00
parent 4cb089bb54
commit 19806e4514
5 changed files with 55 additions and 39 deletions

View file

@ -770,10 +770,13 @@ impl SyntaxExtension {
.find_by_name(attrs, sym::rustc_builtin_macro)
.map(|a| a.value_str().unwrap_or(name));
let (stability, const_stability) = attr::find_stability(&sess, attrs, span);
if const_stability.is_some() {
if let Some((_, sp)) = const_stability {
sess.parse_sess
.span_diagnostic
.span_err(span, "macros cannot have const stability attributes");
.struct_span_err(sp, "macros cannot have const stability attributes")
.span_label(sp, "invalid stability attribute")
.span_label(span, "in this macro")
.emit();
}
SyntaxExtension {
@ -782,7 +785,7 @@ impl SyntaxExtension {
allow_internal_unstable,
allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe),
local_inner_macros,
stability,
stability: stability.map(|(s, _)| s),
deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d),
helper_attrs,
edition,