mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
rustc_expand: Mark inner #![test]
attributes as soft-unstable
This commit is contained in:
parent
ae6aa22cf2
commit
993bb072ff
@ -22,7 +22,7 @@ use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
|
|||||||
use rustc_hir::def_id;
|
use rustc_hir::def_id;
|
||||||
use rustc_middle::middle::stability;
|
use rustc_middle::middle::stability;
|
||||||
use rustc_middle::ty;
|
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::parse::feature_err;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::edition::Edition;
|
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.
|
// 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
|
&& !self.session.features_untracked().custom_inner_attributes
|
||||||
&& path != &sym::test
|
|
||||||
&& res != Res::Err
|
|
||||||
{
|
{
|
||||||
feature_err(
|
let msg = match res {
|
||||||
&self.session.parse_sess,
|
Res::Def(..) => "inner macro attributes are unstable",
|
||||||
sym::custom_inner_attributes,
|
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
|
||||||
path.span,
|
_ => unreachable!(),
|
||||||
match res {
|
};
|
||||||
Res::Def(..) => "inner macro attributes are unstable",
|
if path == &sym::test {
|
||||||
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
|
self.session.parse_sess.buffer_lint(SOFT_UNSTABLE, path.span, node_id, msg);
|
||||||
_ => unreachable!(),
|
} else {
|
||||||
},
|
feature_err(&self.session.parse_sess, sym::custom_inner_attributes, path.span, msg)
|
||||||
)
|
.emit();
|
||||||
.emit();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((ext, res))
|
Ok((ext, res))
|
||||||
|
@ -75,8 +75,8 @@ fn test_checked_mul() {
|
|||||||
|
|
||||||
macro_rules! test_is_power_of_two {
|
macro_rules! test_is_power_of_two {
|
||||||
($test_name:ident, $T:ident) => {
|
($test_name:ident, $T:ident) => {
|
||||||
|
#[test]
|
||||||
fn $test_name() {
|
fn $test_name() {
|
||||||
#![test]
|
|
||||||
assert_eq!((0 as $T).is_power_of_two(), false);
|
assert_eq!((0 as $T).is_power_of_two(), false);
|
||||||
assert_eq!((1 as $T).is_power_of_two(), true);
|
assert_eq!((1 as $T).is_power_of_two(), true);
|
||||||
assert_eq!((2 as $T).is_power_of_two(), true);
|
assert_eq!((2 as $T).is_power_of_two(), true);
|
||||||
@ -96,8 +96,8 @@ test_is_power_of_two! { test_is_power_of_two_uint, usize }
|
|||||||
|
|
||||||
macro_rules! test_next_power_of_two {
|
macro_rules! test_next_power_of_two {
|
||||||
($test_name:ident, $T:ident) => {
|
($test_name:ident, $T:ident) => {
|
||||||
|
#[test]
|
||||||
fn $test_name() {
|
fn $test_name() {
|
||||||
#![test]
|
|
||||||
assert_eq!((0 as $T).next_power_of_two(), 1);
|
assert_eq!((0 as $T).next_power_of_two(), 1);
|
||||||
let mut next_power = 1;
|
let mut next_power = 1;
|
||||||
for i in 1 as $T..40 {
|
for i in 1 as $T..40 {
|
||||||
@ -118,8 +118,8 @@ test_next_power_of_two! { test_next_power_of_two_uint, usize }
|
|||||||
|
|
||||||
macro_rules! test_checked_next_power_of_two {
|
macro_rules! test_checked_next_power_of_two {
|
||||||
($test_name:ident, $T:ident) => {
|
($test_name:ident, $T:ident) => {
|
||||||
|
#[test]
|
||||||
fn $test_name() {
|
fn $test_name() {
|
||||||
#![test]
|
|
||||||
assert_eq!((0 as $T).checked_next_power_of_two(), Some(1));
|
assert_eq!((0 as $T).checked_next_power_of_two(), Some(1));
|
||||||
let smax = $T::MAX >> 1;
|
let smax = $T::MAX >> 1;
|
||||||
assert_eq!(smax.checked_next_power_of_two(), Some(smax + 1));
|
assert_eq!(smax.checked_next_power_of_two(), Some(smax + 1));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs.
|
// The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs.
|
||||||
|
|
||||||
|
#![allow(soft_unstable)]
|
||||||
#![test = "4200"]
|
#![test = "4200"]
|
||||||
//~^ ERROR cannot determine resolution for the attribute macro `test`
|
//~^ ERROR cannot determine resolution for the attribute macro `test`
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: cannot determine resolution for the attribute macro `test`
|
error: cannot determine resolution for the attribute macro `test`
|
||||||
--> $DIR/issue-43106-gating-of-test.rs:3:4
|
--> $DIR/issue-43106-gating-of-test.rs:4:4
|
||||||
|
|
|
|
||||||
LL | #![test = "4200"]
|
LL | #![test = "4200"]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
// compile-flags: --test
|
// compile-flags: --test
|
||||||
|
|
||||||
|
#![allow(soft_unstable)]
|
||||||
#![test] //~ ERROR cannot determine resolution for the attribute macro `test`
|
#![test] //~ ERROR cannot determine resolution for the attribute macro `test`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: cannot determine resolution for the attribute macro `test`
|
error: cannot determine resolution for the attribute macro `test`
|
||||||
--> $DIR/issue-28134.rs:3:4
|
--> $DIR/issue-28134.rs:4:4
|
||||||
|
|
|
|
||||||
LL | #![test]
|
LL | #![test]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -45,4 +45,9 @@ fn attrs() {
|
|||||||
//~^ ERROR: custom attributes cannot be applied to expressions
|
//~^ ERROR: custom attributes cannot be applied to expressions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_case() {
|
||||||
|
#![test] //~ ERROR inner macro attributes are unstable
|
||||||
|
//~| WARN this was previously accepted
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -76,6 +76,16 @@ LL | let _x = #[identity_attr] println!();
|
|||||||
= note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
|
= note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
|
||||||
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
|
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: inner macro attributes are unstable
|
||||||
|
--> $DIR/proc-macro-gates.rs:49:8
|
||||||
|
|
|
||||||
|
LL | #![test]
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(soft_unstable)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
|
||||||
|
|
||||||
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
Loading…
Reference in New Issue
Block a user