forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#117205 - weiznich:multiple_notes_for_on_unimplemented, r=compiler-errors Allows `#[diagnostic::on_unimplemented]` attributes to have multiple notes This commit extends the `#[diagnostic::on_unimplemented]` (and `#[rustc_on_unimplemented]`) attributes to allow multiple `note` options. This enables emitting multiple notes for custom error messages. For now I've opted to not change any of the existing usages of `#[rustc_on_unimplemented]` and just updated the relevant compile tests. r? `@compiler-errors` I'm happy to adjust any of the existing changed location to emit the old error message if that's desired.
- Loading branch information
Showing
9 changed files
with
111 additions
and
23 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
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
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
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/on_unimplemented/multiple_notes.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,18 @@ | ||
#![feature(diagnostic_namespace)] | ||
|
||
#[diagnostic::on_unimplemented(message = "Foo", label = "Bar", note = "Baz", note = "Boom")] | ||
trait Foo {} | ||
|
||
#[diagnostic::on_unimplemented(message = "Bar", label = "Foo", note = "Baz")] | ||
#[diagnostic::on_unimplemented(note = "Baz2")] | ||
trait Bar {} | ||
|
||
fn takes_foo(_: impl Foo) {} | ||
fn takes_bar(_: impl Bar) {} | ||
|
||
fn main() { | ||
takes_foo(()); | ||
//~^ERROR Foo | ||
takes_bar(()); | ||
//~^ERROR Bar | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.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,47 @@ | ||
error[E0277]: Foo | ||
--> $DIR/multiple_notes.rs:14:15 | ||
| | ||
LL | takes_foo(()); | ||
| --------- ^^ Bar | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Foo` is not implemented for `()` | ||
= note: Baz | ||
= note: Boom | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/multiple_notes.rs:4:1 | ||
| | ||
LL | trait Foo {} | ||
| ^^^^^^^^^ | ||
note: required by a bound in `takes_foo` | ||
--> $DIR/multiple_notes.rs:10:22 | ||
| | ||
LL | fn takes_foo(_: impl Foo) {} | ||
| ^^^ required by this bound in `takes_foo` | ||
|
||
error[E0277]: Bar | ||
--> $DIR/multiple_notes.rs:16:15 | ||
| | ||
LL | takes_bar(()); | ||
| --------- ^^ Foo | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Bar` is not implemented for `()` | ||
= note: Baz | ||
= note: Baz2 | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/multiple_notes.rs:8:1 | ||
| | ||
LL | trait Bar {} | ||
| ^^^^^^^^^ | ||
note: required by a bound in `takes_bar` | ||
--> $DIR/multiple_notes.rs:11:22 | ||
| | ||
LL | fn takes_bar(_: impl Bar) {} | ||
| ^^^ required by this bound in `takes_bar` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
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
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