Skip to content

Commit 70f78fb

Browse files
committed
Add test for flailing diagnostic spans
1 parent 44f415c commit 70f78fb

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#![crate_type = "lib"]
2+
#![deny(unknown_or_malformed_diagnostic_attributes)]
3+
4+
5+
#[diagnostic::on_unimplemented(message = "here is a big \
6+
multiline string \
7+
{unknown}")]
8+
//~^^ ERROR there is no parameter `unknown` on trait `MultiLine` [unknown_or_malformed_diagnostic_attributes]
9+
pub trait MultiLine {}
10+
11+
#[diagnostic::on_unimplemented(message = "here is a big \
12+
multiline string {unknown}")]
13+
//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [unknown_or_malformed_diagnostic_attributes]
14+
pub trait MultiLine2 {}
15+
16+
#[diagnostic::on_unimplemented(message = "here is a big \
17+
multiline string {unknown}")]
18+
//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [unknown_or_malformed_diagnostic_attributes]
19+
pub trait MultiLine3 {}
20+
21+
22+
#[diagnostic::on_unimplemented(message = "here is a big \
23+
\
24+
\
25+
\
26+
\
27+
multiline string {unknown}")]
28+
//~^^^^ ERROR there is no parameter `unknown` on trait `MultiLine4` [unknown_or_malformed_diagnostic_attributes]
29+
pub trait MultiLine4 {}
30+
31+
#[diagnostic::on_unimplemented(message = "here is a big \
32+
multiline string \
33+
{Self:+}")]
34+
//~^^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
35+
pub trait MultiLineFmt {}
36+
37+
#[diagnostic::on_unimplemented(message = "here is a big \
38+
multiline string {Self:X}")]
39+
pub trait MultiLineFmt2 {}
40+
41+
#[diagnostic::on_unimplemented(message = "here is a big \
42+
multiline string {Self:#}")]
43+
//~^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
44+
pub trait MultiLineFmt3 {}
45+
46+
47+
#[diagnostic::on_unimplemented(message = "here is a big \
48+
\
49+
\
50+
\
51+
\
52+
multiline string {Self:?}")]
53+
pub trait MultiLineFmt4 {}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
error: there is no parameter `unknown` on trait `MultiLine`
2+
--> $DIR/multiline_spans.rs:6:17
3+
|
4+
LL | ... multiline string \
5+
| ^^^^^^^
6+
|
7+
= help: expect either a generic argument name or `{Self}` as format argument
8+
note: the lint level is defined here
9+
--> $DIR/multiline_spans.rs:2:9
10+
|
11+
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: there is no parameter `unknown` on trait `MultiLine2`
15+
--> $DIR/multiline_spans.rs:12:17
16+
|
17+
LL | ... multiline string {unknown}")]
18+
| ^^^^^^^
19+
|
20+
= help: expect either a generic argument name or `{Self}` as format argument
21+
22+
error: there is no parameter `unknown` on trait `MultiLine3`
23+
--> $DIR/multiline_spans.rs:17:17
24+
|
25+
LL | multiline string {unknown}")]
26+
| ^^^^^^^
27+
|
28+
= help: expect either a generic argument name or `{Self}` as format argument
29+
30+
error: there is no parameter `unknown` on trait `MultiLine4`
31+
--> $DIR/multiline_spans.rs:24:15
32+
|
33+
LL | / \
34+
LL | | \
35+
| |___^
36+
|
37+
= help: expect either a generic argument name or `{Self}` as format argument
38+
39+
error: invalid format specifier
40+
--> $DIR/multiline_spans.rs:31:42
41+
|
42+
LL | #[diagnostic::on_unimplemented(message = "here is a big \
43+
| __________________________________________^
44+
LL | | multiline string \
45+
LL | | {Self:+}")]
46+
| |__________________________________________________^
47+
|
48+
= help: no format specifier are supported in this position
49+
50+
error: invalid format specifier
51+
--> $DIR/multiline_spans.rs:41:42
52+
|
53+
LL | #[diagnostic::on_unimplemented(message = "here is a big \
54+
| __________________________________________^
55+
LL | | multiline string {Self:#}")]
56+
| |______________________________^
57+
|
58+
= help: no format specifier are supported in this position
59+
60+
error: aborting due to 6 previous errors
61+

0 commit comments

Comments
 (0)