Auto merge of #79003 - petrochenkov:innertest, r=estebank

rustc_expand: Mark inner `#![test]` attributes as soft-unstable

Custom inner attributes are feature gated (https://github.com/rust-lang/rust/issues/54726) except for attributes having name `test` literally, which are not gated for historical reasons.

`#![test]` is an inner proc macro attribute, so it has all the issues described in https://github.com/rust-lang/rust/issues/54726 too.
This PR gates it with the `soft_unstable` lint.
This commit is contained in:
bors
2020-11-21 05:52:16 +00:00
8 changed files with 37 additions and 21 deletions

View File

@@ -22,7 +22,7 @@ use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def_id;
use rustc_middle::middle::stability;
use rustc_middle::ty;
use rustc_session::lint::builtin::UNUSED_MACROS;
use rustc_session::lint::builtin::{SOFT_UNSTABLE, UNUSED_MACROS};
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::edition::Edition;
@@ -459,22 +459,21 @@ impl<'a> Resolver<'a> {
}
// We are trying to avoid reporting this error if other related errors were reported.
if inner_attr
if res != Res::Err
&& inner_attr
&& !self.session.features_untracked().custom_inner_attributes
&& path != &sym::test
&& res != Res::Err
{
feature_err(
&self.session.parse_sess,
sym::custom_inner_attributes,
path.span,
match res {
Res::Def(..) => "inner macro attributes are unstable",
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
_ => unreachable!(),
},
)
.emit();
let msg = match res {
Res::Def(..) => "inner macro attributes are unstable",
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
_ => unreachable!(),
};
if path == &sym::test {
self.session.parse_sess.buffer_lint(SOFT_UNSTABLE, path.span, node_id, msg);
} else {
feature_err(&self.session.parse_sess, sym::custom_inner_attributes, path.span, msg)
.emit();
}
}
Ok((ext, res))