Improve testing coverage for #[diagnostic::do_not_recommend]
This PR aims to improve the testing coverage for `#[diagnostic::do_not_recommend]`. It ensures that all tests are run for the old and new solver to verify that the behaviour is the same for both variants. It also adds two new tests: * A test with 4 traits having wild card impl for each other, with alternating `#[diagnostic::do_not_recommend]` attributse * A test with a lifetime dependend wild card impl, which is something that's not supported yet
This commit is contained in:
parent
a89ca2c85e
commit
bfd02d8b36
18 changed files with 230 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `(): Foo` is not satisfied
|
||||
--> $DIR/do_not_apply_attribute_without_feature_flag.rs:19:11
|
||||
--> $DIR/do_not_apply_attribute_without_feature_flag.rs:22:11
|
||||
|
|
||||
LL | check(());
|
||||
| ----- ^^ the trait `Foo` is not implemented for `()`
|
||||
|
@ -11,7 +11,7 @@ LL | check(());
|
|||
(A, B, C)
|
||||
(A,)
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/do_not_apply_attribute_without_feature_flag.rs:16:18
|
||||
--> $DIR/do_not_apply_attribute_without_feature_flag.rs:19:18
|
||||
|
|
||||
LL | fn check(a: impl Foo) {}
|
||||
| ^^^ required by this bound in `check`
|
|
@ -0,0 +1,21 @@
|
|||
error[E0277]: the trait bound `(): Foo` is not satisfied
|
||||
--> $DIR/do_not_apply_attribute_without_feature_flag.rs:22: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:19: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`.
|
|
@ -1,3 +1,6 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
#![allow(unknown_or_malformed_diagnostic_attributes)]
|
||||
|
||||
trait Foo {}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `u8: Bar` is not satisfied
|
||||
--> $DIR/feature-gate-do_not_recommend.rs:15:11
|
||||
--> $DIR/feature-gate-do_not_recommend.rs:18: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
|
||||
--> $DIR/feature-gate-do_not_recommend.rs:15:13
|
||||
|
|
||||
LL | fn stuff<T: Bar>(_: T) {}
|
||||
| ^^^ required by this bound in `stuff`
|
|
@ -0,0 +1,17 @@
|
|||
error[E0277]: the trait bound `u8: Bar` is not satisfied
|
||||
--> $DIR/feature-gate-do_not_recommend.rs:18:11
|
||||
|
|
||||
LL | stuff(1u8);
|
||||
| ----- ^^^ the trait `Bar` is not implemented for `u8`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `stuff`
|
||||
--> $DIR/feature-gate-do_not_recommend.rs:15: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`.
|
|
@ -1,3 +1,6 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
#![feature(do_not_recommend)]
|
||||
|
||||
pub trait Foo {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:4:1
|
||||
--> $DIR/incorrect-locations.rs:7:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -7,43 +7,43 @@ 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
|
||||
--> $DIR/incorrect-locations.rs:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:12:1
|
||||
--> $DIR/incorrect-locations.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:16:1
|
||||
--> $DIR/incorrect-locations.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:20:1
|
||||
--> $DIR/incorrect-locations.rs:23:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:24:1
|
||||
--> $DIR/incorrect-locations.rs:27:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:28:1
|
||||
--> $DIR/incorrect-locations.rs:31:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:32:1
|
||||
--> $DIR/incorrect-locations.rs:35:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@ -0,0 +1,52 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:7: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:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:23:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:27:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:31:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:35:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 8 warnings emitted
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
//@ check-pass
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
#![feature(do_not_recommend)]
|
||||
|
||||
#[diagnostic::do_not_recommend]
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/nested.rs:23:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/nested.rs:20:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
|
@ -0,0 +1,15 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/nested.rs:23:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/nested.rs:20:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
25
tests/ui/diagnostic_namespace/do_not_recommend/nested.rs
Normal file
25
tests/ui/diagnostic_namespace/do_not_recommend/nested.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
#![feature(do_not_recommend)]
|
||||
|
||||
trait Root {}
|
||||
trait DontRecommend {}
|
||||
trait Other {}
|
||||
trait Child {}
|
||||
|
||||
#[diagnostic::do_not_recommend]
|
||||
impl<T> Root for T where T: DontRecommend {}
|
||||
|
||||
impl<T> DontRecommend for T where T: Other {}
|
||||
|
||||
#[diagnostic::do_not_recommend]
|
||||
impl<T> Other for T where T: Child {}
|
||||
|
||||
fn needs_root<T: Root>() {}
|
||||
|
||||
fn main() {
|
||||
needs_root::<()>();
|
||||
//~^ ERROR the trait bound `(): Root` is not satisfied
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
error: unknown diagnostic attribute
|
||||
--> $DIR/unstable-feature.rs:4:15
|
||||
--> $DIR/unstable-feature.rs:7:15
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unstable-feature.rs:1:9
|
||||
--> $DIR/unstable-feature.rs:4:9
|
||||
|
|
||||
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@ -0,0 +1,14 @@
|
|||
error: unknown diagnostic attribute
|
||||
--> $DIR/unstable-feature.rs:7:15
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unstable-feature.rs:4:9
|
||||
|
|
||||
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
#![deny(unknown_or_malformed_diagnostic_attributes)]
|
||||
trait Foo {}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/with_lifetime.rs:19:5
|
||||
|
|
||||
LL | fn foo<'a>(a: &'a ()) {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | needs_root::<&'a ()>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/with_lifetime.rs:19:5
|
||||
|
|
||||
LL | fn foo<'a>(a: &'a ()) {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | needs_root::<&'a ()>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
#![feature(do_not_recommend)]
|
||||
|
||||
trait Root {}
|
||||
trait DontRecommend {}
|
||||
|
||||
impl<T> Root for T where T: DontRecommend {}
|
||||
|
||||
// this has no effect yet for resolving the trait error below
|
||||
#[diagnostic::do_not_recommend]
|
||||
impl<T> DontRecommend for &'static T {}
|
||||
|
||||
fn needs_root<T: Root>() {}
|
||||
|
||||
fn foo<'a>(a: &'a ()) {
|
||||
needs_root::<&'a ()>();
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo(&());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue