rust/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.rs
Georg Semmler 160b1793b2
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.
2023-10-27 12:42:42 +02:00

19 lines
428 B
Rust

#![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
}