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/ui/diagnostic_namespace | |
| 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/ui/diagnostic_namespace')
9 files changed, 148 insertions, 3 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/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.rs b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.rs new file mode 100644 index 00000000000..5a26d28188c --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.rs @@ -0,0 +1,17 @@ +#![feature(do_not_recommend)] + +pub trait Foo {} + +impl Foo for i32 {} + +pub trait Bar {} + +#[diagnostic::do_not_recommend] +impl<T: Foo> Bar for T {} + +fn stuff<T: Bar>(_: T) {} + +fn main() { + stuff(1u8); + //~^ the trait bound `u8: Bar` is not satisfied +} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.stderr new file mode 100644 index 00000000000..3951231fa2e --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/feature-gate-do_not_recommend.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `u8: Bar` is not satisfied + --> $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:12:13 + | +LL | fn stuff<T: Bar>(_: T) {} + | ^^^ required by this bound in `stuff` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. 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 + |
