Add test for flailing diagnostic spans

This commit is contained in:
mejrs 2025-05-23 18:52:18 +02:00
parent 44f415c1d6
commit 70f78fb2ba
2 changed files with 114 additions and 0 deletions

View file

@ -0,0 +1,53 @@
#![crate_type = "lib"]
#![deny(unknown_or_malformed_diagnostic_attributes)]
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string \
{unknown}")]
//~^^ ERROR there is no parameter `unknown` on trait `MultiLine` [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLine {}
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string {unknown}")]
//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLine2 {}
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string {unknown}")]
//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLine3 {}
#[diagnostic::on_unimplemented(message = "here is a big \
\
\
\
\
multiline string {unknown}")]
//~^^^^ ERROR there is no parameter `unknown` on trait `MultiLine4` [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLine4 {}
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string \
{Self:+}")]
//~^^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLineFmt {}
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string {Self:X}")]
pub trait MultiLineFmt2 {}
#[diagnostic::on_unimplemented(message = "here is a big \
multiline string {Self:#}")]
//~^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
pub trait MultiLineFmt3 {}
#[diagnostic::on_unimplemented(message = "here is a big \
\
\
\
\
multiline string {Self:?}")]
pub trait MultiLineFmt4 {}

View file

@ -0,0 +1,61 @@
error: there is no parameter `unknown` on trait `MultiLine`
--> $DIR/multiline_spans.rs:6:17
|
LL | ... multiline string \
| ^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
note: the lint level is defined here
--> $DIR/multiline_spans.rs:2:9
|
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: there is no parameter `unknown` on trait `MultiLine2`
--> $DIR/multiline_spans.rs:12:17
|
LL | ... multiline string {unknown}")]
| ^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
error: there is no parameter `unknown` on trait `MultiLine3`
--> $DIR/multiline_spans.rs:17:17
|
LL | multiline string {unknown}")]
| ^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
error: there is no parameter `unknown` on trait `MultiLine4`
--> $DIR/multiline_spans.rs:24:15
|
LL | / \
LL | | \
| |___^
|
= help: expect either a generic argument name or `{Self}` as format argument
error: invalid format specifier
--> $DIR/multiline_spans.rs:31:42
|
LL | #[diagnostic::on_unimplemented(message = "here is a big \
| __________________________________________^
LL | | multiline string \
LL | | {Self:+}")]
| |__________________________________________________^
|
= help: no format specifier are supported in this position
error: invalid format specifier
--> $DIR/multiline_spans.rs:41:42
|
LL | #[diagnostic::on_unimplemented(message = "here is a big \
| __________________________________________^
LL | | multiline string {Self:#}")]
| |______________________________^
|
= help: no format specifier are supported in this position
error: aborting due to 6 previous errors