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#116931 - weiznich:improve_diagnostic_on_unimplemented_warnings, r=compiler-errors Improve the warning messages for the `#[diagnostic::on_unimplemented]` This commit improves warnings emitted for malformed on unimplemented attributes by: * Improving the span of the warnings * Adding a label message to them * Separating the messages for missing and unexpected options * Adding a help message that says which options are supported r? `@compiler-errors` I'm happy to work on further improvements, so feel free to make suggestions.
- Loading branch information
Showing
6 changed files
with
139 additions
and
54 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
10 changes: 4 additions & 6 deletions
10
...tic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
#![feature(diagnostic_namespace)] | ||
|
||
#[diagnostic::on_unimplemented( | ||
if(Self = "()"), | ||
//~^WARN malformed `on_unimplemented` attribute | ||
//~|WARN malformed `on_unimplemented` attribute | ||
if(Self = ()), | ||
message = "not used yet", | ||
label = "not used yet", | ||
note = "not used yet" | ||
message = "custom message", | ||
note = "custom note" | ||
)] | ||
#[diagnostic::on_unimplemented(message = "fallback!!")] | ||
#[diagnostic::on_unimplemented(label = "fallback label")] | ||
#[diagnostic::on_unimplemented(note = "fallback note")] | ||
#[diagnostic::on_unimplemented(message = "fallback2!!")] | ||
trait Foo {} | ||
|
||
fn takes_foo(_: impl Foo) {} | ||
|
||
fn main() { | ||
takes_foo(()); | ||
//~^ERROR fallback!! | ||
//~^ERROR custom message | ||
} |
36 changes: 13 additions & 23 deletions
36
...namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.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