Skip to content

Commit aa3f8a5

Browse files
committed
Add test for coalescing of diagnostic attribute duplicates
1 parent dab8d9d commit aa3f8a5

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0277]: this message
2+
--> $DIR/duplicate_coalescing.rs:16:17
3+
|
4+
LL | takes_trait(());
5+
| ----------- ^^ this label
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Trait` is not implemented for `()`
10+
= note: this note
11+
help: this trait has no implementations, consider adding one
12+
--> $DIR/duplicate_coalescing.rs:11:1
13+
|
14+
LL | trait Trait {}
15+
| ^^^^^^^^^^^
16+
note: required by a bound in `takes_trait`
17+
--> $DIR/duplicate_coalescing.rs:13:24
18+
|
19+
LL | fn takes_trait(_: impl Trait) {}
20+
| ^^^^^ required by this bound in `takes_trait`
21+
22+
error: aborting due to 1 previous error
23+
24+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0277]: this message
2+
--> $DIR/duplicate_coalescing.rs:16:17
3+
|
4+
LL | takes_trait(());
5+
| ----------- ^^ this label
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the trait `Trait` is not implemented for `()`
10+
help: this trait has no implementations, consider adding one
11+
--> $DIR/duplicate_coalescing.rs:11:1
12+
|
13+
LL | trait Trait {}
14+
| ^^^^^^^^^^^
15+
note: required by a bound in `takes_trait`
16+
--> $DIR/duplicate_coalescing.rs:13:24
17+
|
18+
LL | fn takes_trait(_: impl Trait) {}
19+
| ^^^^^ required by this bound in `takes_trait`
20+
21+
error: aborting due to 1 previous error
22+
23+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0277]: this message
2+
--> $DIR/duplicate_coalescing.rs:16:17
3+
|
4+
LL | takes_trait(());
5+
| ----------- ^^ the trait `Trait` is not implemented for `()`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= note: this note
10+
help: this trait has no implementations, consider adding one
11+
--> $DIR/duplicate_coalescing.rs:11:1
12+
|
13+
LL | trait Trait {}
14+
| ^^^^^^^^^^^
15+
note: required by a bound in `takes_trait`
16+
--> $DIR/duplicate_coalescing.rs:13:24
17+
|
18+
LL | fn takes_trait(_: impl Trait) {}
19+
| ^^^^^ required by this bound in `takes_trait`
20+
21+
error: aborting due to 1 previous error
22+
23+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ reference: attributes.diagnostic.on_unimplemented.duplicates
2+
//@ revisions: label note both
3+
//@[both] compile-flags: --cfg label --cfg note
4+
//@ dont-require-annotations: NOTE
5+
6+
//! Example and test of multiple diagnostic attributes coalescing together.
7+
8+
#[diagnostic::on_unimplemented(message = "this message")]
9+
#[cfg_attr(label, diagnostic::on_unimplemented(label = "this label"))]
10+
#[cfg_attr(note, diagnostic::on_unimplemented(note = "this note"))]
11+
trait Trait {}
12+
13+
fn takes_trait(_: impl Trait) {}
14+
15+
fn main() {
16+
takes_trait(());
17+
//~^ERROR this message
18+
//[label]~|NOTE this label
19+
//[both]~|NOTE this label
20+
//[note]~|NOTE this note
21+
//[both]~|NOTE this note
22+
}

0 commit comments

Comments
 (0)