diff options
| author | Georg Semmler <github@weiznich.de> | 2024-05-10 14:12:30 +0200 |
|---|---|---|
| committer | Georg Semmler <github@weiznich.de> | 2024-05-21 13:14:41 +0200 |
| commit | 2cff3e90bcd162964546ca9936c209aa952c1af4 (patch) | |
| tree | 78e26281013d0cdc5d9c4403729c082938b6adf6 /tests | |
| parent | e8ada6ab253b510ac88edda131021d9878f2984f (diff) | |
| download | rust-2cff3e90bcd162964546ca9936c209aa952c1af4.tar.gz rust-2cff3e90bcd162964546ca9936c209aa952c1af4.zip | |
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace
This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work.
Diffstat (limited to 'tests')
13 files changed, 123 insertions, 132 deletions
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs index 9cdc193d386..5fd5cc54400 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs @@ -26,7 +26,7 @@ impl<T> Expression for Bound<T> { type SqlType = T; } -#[do_not_recommend] +#[diagnostic::do_not_recommend] impl<T, ST> AsExpression<ST> for T where T: Expression<SqlType = ST>, diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.rs index c9dc1c6e649..5a26d28188c 100644 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.rs @@ -1,17 +1,13 @@ #![feature(do_not_recommend)] -pub trait Foo { -} +pub trait Foo {} -impl Foo for i32 { -} +impl Foo for i32 {} -pub trait Bar { -} +pub trait Bar {} -#[do_not_recommend] -impl<T: Foo> Bar for T { -} +#[diagnostic::do_not_recommend] +impl<T: Foo> Bar for T {} fn stuff<T: Bar>(_: T) {} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.stderr index e6f199445bf..3951231fa2e 100644 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `u8: Bar` is not satisfied - --> $DIR/feature-gate-do_not_recommend.rs:19:11 + --> $DIR/feature-gate-do_not_recommend.rs:15:11 | LL | stuff(1u8); | ^^^ the trait `Bar` is not implemented for `u8` | note: required by a bound in `stuff` - --> $DIR/feature-gate-do_not_recommend.rs:16:13 + --> $DIR/feature-gate-do_not_recommend.rs:12:13 | LL | fn stuff<T: Bar>(_: T) {} | ^^^ required by this bound in `stuff` diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.rs b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.rs new file mode 100644 index 00000000000..400ef83873e --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.rs @@ -0,0 +1,39 @@ +//@ check-pass +#![feature(do_not_recommend)] + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +const CONST: () = (); + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +static STATIC: () = (); + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +type Type = (); + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +enum Enum {} + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +extern "C" {} + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +fn fun() {} + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +struct Struct {} + +#[diagnostic::do_not_recommend] +//~^WARN `#[diagnostic::do_not_recommend]` can only be placed +trait Trait {} + +#[diagnostic::do_not_recommend] +impl Trait for i32 {} + +fn main() {} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.stderr new file mode 100644 index 00000000000..c83fd46db58 --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/incorrect-locations.stderr @@ -0,0 +1,52 @@ +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:4:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:8:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:12:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:16:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:20:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:24:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:28:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:32:1 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 8 warnings emitted + diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/simple.rs b/tests/ui/diagnostic_namespace/do_not_recommend/simple.rs index 6fb15b90138..780649b009c 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/simple.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/simple.rs @@ -6,7 +6,7 @@ trait Foo {} -#[do_not_recommend] +#[diagnostic::do_not_recommend] impl<T> Foo for T where T: Send {} fn needs_foo<T: Foo>() {} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/stacked.rs b/tests/ui/diagnostic_namespace/do_not_recommend/stacked.rs index 695660d3596..fc355bdc4e2 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/stacked.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/stacked.rs @@ -8,7 +8,7 @@ trait Root {} trait DontRecommend {} trait Other {} -#[do_not_recommend] +#[diagnostic::do_not_recommend] impl<T> Root for T where T: DontRecommend {} impl<T> DontRecommend for T where T: Other {} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.rs b/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.rs new file mode 100644 index 00000000000..ccc687aa5b3 --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.rs @@ -0,0 +1,8 @@ +#![deny(unknown_or_malformed_diagnostic_attributes)] +trait Foo {} + +#[diagnostic::do_not_recommend] +//~^ ERROR unknown diagnostic attribute [unknown_or_malformed_diagnostic_attributes] +impl Foo for i32 {} + +fn main() {} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.stderr new file mode 100644 index 00000000000..d8332229d4f --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/unstable-feature.stderr @@ -0,0 +1,14 @@ +error: unknown diagnostic attribute + --> $DIR/unstable-feature.rs:4:15 + | +LL | #[diagnostic::do_not_recommend] + | ^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/unstable-feature.rs:1:9 + | +LL | #![deny(unknown_or_malformed_diagnostic_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs deleted file mode 100644 index 91863f5e497..00000000000 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature(do_not_recommend)] - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -const CONST: () = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -static Static: () = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -type Type = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -enum Enum { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -extern { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -fn fun() { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -struct Struct { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -trait Trait { -} - -#[do_not_recommend] -impl Trait for i32 { -} - -fn main() { -} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr deleted file mode 100644 index 01ebc23c86e..00000000000 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:3:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:7:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:11:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:15:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:20:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:25:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:30:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:35:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 8 previous errors - diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs deleted file mode 100644 index f0c5c222e78..00000000000 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs +++ /dev/null @@ -1,10 +0,0 @@ -trait Foo { -} - -#[do_not_recommend] -//~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature -impl Foo for i32 { -} - -fn main() { -} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr deleted file mode 100644 index 02bc51ccd3f..00000000000 --- a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature - --> $DIR/unstable-feature.rs:4:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51992 <https://github.com/rust-lang/rust/issues/51992> for more information - = help: add `#![feature(do_not_recommend)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. |
