-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows
#[diagnostic::do_not_recommend]
to supress trait impls in su…
…ggestions as well This commit changes the error reporting mechanism for not implemented traits to skip impl marked as `#[diagnostic::do_not_recommend]` in the help part of the error message ("the following other types implement trait `Foo`:"). The main use case here is to allow crate authors to skip non-meaningful confusing suggestions. A common example for this are fully generic impls on tuples.
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0277]: the trait bound `(): Foo` is not satisfied | ||
--> $DIR/supress_suggestions_in_help.rs:23:11 | ||
| | ||
LL | check(()); | ||
| ----- ^^ the trait `Foo` is not implemented for `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Foo` is implemented for `i32` | ||
note: required by a bound in `check` | ||
--> $DIR/supress_suggestions_in_help.rs:20: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`. |
18 changes: 18 additions & 0 deletions
18
tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.next.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0277]: the trait bound `(): Foo` is not satisfied | ||
--> $DIR/supress_suggestions_in_help.rs:23:11 | ||
| | ||
LL | check(()); | ||
| ----- ^^ the trait `Foo` is not implemented for `()` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Foo` is implemented for `i32` | ||
note: required by a bound in `check` | ||
--> $DIR/supress_suggestions_in_help.rs:20: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`. |
25 changes: 25 additions & 0 deletions
25
tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(do_not_recommend)] | ||
|
||
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 | ||
} |