diff options
| author | Michael Goulet <michael@errs.io> | 2024-08-09 21:14:07 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-08-09 22:02:23 -0400 |
| commit | 20a16bb3c54ea7523ebd0c933fe5674aea50942e (patch) | |
| tree | 36e7b25046379c5766c2206a911f2b55748e1651 | |
| parent | ed7bdbb17b9c03fe3530e5e3f21b7c6c7879dbca (diff) | |
| download | rust-20a16bb3c54ea7523ebd0c933fe5674aea50942e.tar.gz rust-20a16bb3c54ea7523ebd0c933fe5674aea50942e.zip | |
Add test
Co-authored-by: Georg Semmler <github@weiznich.de>
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.rs b/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.rs new file mode 100644 index 00000000000..5548fa2f52e --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.rs @@ -0,0 +1,21 @@ +#![allow(unknown_or_malformed_diagnostic_attributes)] + +trait Foo {} + +#[diagnostic::do_not_recommend] +impl<A> Foo for (A,) {} + +#[diagnostic::do_not_recommend] +impl<A, B> Foo for (A, B) {} + +#[diagnostic::do_not_recommend] +impl<A, B, C> Foo for (A, B, C) {} + +impl Foo for i32 {} + +fn check(a: impl Foo) {} + +fn main() { + check(()); + //~^ ERROR the trait bound `(): Foo` is not satisfied +} diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.stderr new file mode 100644 index 00000000000..e56af28f3fb --- /dev/null +++ b/tests/ui/diagnostic_namespace/do_not_recommend/do_not_apply_attribute_without_feature_flag.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/do_not_apply_attribute_without_feature_flag.rs:19:11 + | +LL | check(()); + | ----- ^^ the trait `Foo` is not implemented for `()` + | | + | required by a bound introduced by this call + | + = help: the following other types implement trait `Foo`: + (A, B) + (A, B, C) + (A,) +note: required by a bound in `check` + --> $DIR/do_not_apply_attribute_without_feature_flag.rs:16:18 + | +LL | fn check(a: impl Foo) {} + | ^^^ required by this bound in `check` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
