Skip to content

Commit 11c879d

Browse files
committed
Add tests for macro-not-found diagnostics.
1 parent 7977cb4 commit 11c879d

File tree

4 files changed

+183
-44
lines changed

4 files changed

+183
-44
lines changed

src/test/ui/derives/issue-88206.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/test/ui/derives/issue-88206.stderr

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/test/ui/macros/issue-88206.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// compile-flags: -Z deduplicate-diagnostics=yes
2+
3+
#![warn(unused_imports)]
4+
//~^ NOTE lint level
5+
6+
use std::str::*;
7+
//~^ WARNING unused import
8+
//~| NOTE `from_utf8` is imported here, but it is not a macro
9+
//~| NOTE `from_utf8_mut` is imported here, but it is not a derive macro
10+
//~| NOTE `from_utf8_unchecked` is imported here, but it is not an attribute
11+
12+
mod hey {
13+
pub trait Serialize {}
14+
pub trait Deserialize {}
15+
}
16+
17+
use hey::{Serialize, Deserialize};
18+
//~^ WARNING unused import
19+
//~| NOTE `Serialize` is imported here, but it is not a derive macro
20+
//~| NOTE `Deserialize` is imported here, but it is not an attribute
21+
22+
#[derive(Serialize)]
23+
//~^ ERROR cannot find derive macro `Serialize`
24+
struct A;
25+
26+
#[derive(from_utf8_mut)]
27+
//~^ ERROR cannot find derive macro `from_utf8_mut`
28+
struct B;
29+
30+
#[derive(println)]
31+
//~^ ERROR cannot find derive macro `println`
32+
//~| NOTE `println` is in scope, but it is a function-like macro
33+
struct C;
34+
35+
#[Deserialize]
36+
//~^ ERROR cannot find attribute `Deserialize`
37+
struct D;
38+
39+
#[from_utf8_unchecked]
40+
//~^ ERROR cannot find attribute `from_utf8_unchecked`
41+
struct E;
42+
43+
#[println]
44+
//~^ ERROR cannot find attribute `println`
45+
//~| NOTE `println` is in scope, but it is a function-like macro
46+
struct F;
47+
48+
fn main() {
49+
from_utf8!();
50+
//~^ ERROR cannot find macro `from_utf8`
51+
52+
Box!();
53+
//~^ ERROR cannot find macro `Box`
54+
//~| NOTE `Box` is in scope, but it is not a macro
55+
56+
Copy!();
57+
//~^ ERROR cannot find macro `Copy`
58+
//~| NOTE `Copy` is in scope, but it is a derive macro
59+
60+
test!();
61+
//~^ ERROR cannot find macro `test`
62+
//~| NOTE `test` is in scope, but it is an attribute
63+
}

src/test/ui/macros/issue-88206.stderr

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
error: cannot find macro `test` in this scope
2+
--> $DIR/issue-88206.rs:60:5
3+
|
4+
LL | test!();
5+
| ^^^^
6+
|
7+
= note: `test` is in scope, but it is an attribute
8+
9+
error: cannot find macro `Copy` in this scope
10+
--> $DIR/issue-88206.rs:56:5
11+
|
12+
LL | Copy!();
13+
| ^^^^
14+
|
15+
= note: `Copy` is in scope, but it is a derive macro
16+
17+
error: cannot find macro `Box` in this scope
18+
--> $DIR/issue-88206.rs:52:5
19+
|
20+
LL | Box!();
21+
| ^^^
22+
|
23+
= note: `Box` is in scope, but it is not a macro
24+
25+
error: cannot find macro `from_utf8` in this scope
26+
--> $DIR/issue-88206.rs:49:5
27+
|
28+
LL | from_utf8!();
29+
| ^^^^^^^^^
30+
|
31+
note: `from_utf8` is imported here, but it is not a macro
32+
--> $DIR/issue-88206.rs:6:5
33+
|
34+
LL | use std::str::*;
35+
| ^^^^^^^^^^^
36+
37+
error: cannot find attribute `println` in this scope
38+
--> $DIR/issue-88206.rs:43:3
39+
|
40+
LL | #[println]
41+
| ^^^^^^^
42+
|
43+
= note: `println` is in scope, but it is a function-like macro
44+
45+
error: cannot find attribute `from_utf8_unchecked` in this scope
46+
--> $DIR/issue-88206.rs:39:3
47+
|
48+
LL | #[from_utf8_unchecked]
49+
| ^^^^^^^^^^^^^^^^^^^
50+
|
51+
note: `from_utf8_unchecked` is imported here, but it is not an attribute
52+
--> $DIR/issue-88206.rs:6:5
53+
|
54+
LL | use std::str::*;
55+
| ^^^^^^^^^^^
56+
57+
error: cannot find attribute `Deserialize` in this scope
58+
--> $DIR/issue-88206.rs:35:3
59+
|
60+
LL | #[Deserialize]
61+
| ^^^^^^^^^^^
62+
|
63+
note: `Deserialize` is imported here, but it is not an attribute
64+
--> $DIR/issue-88206.rs:17:22
65+
|
66+
LL | use hey::{Serialize, Deserialize};
67+
| ^^^^^^^^^^^
68+
69+
error: cannot find derive macro `println` in this scope
70+
--> $DIR/issue-88206.rs:30:10
71+
|
72+
LL | #[derive(println)]
73+
| ^^^^^^^
74+
|
75+
= note: `println` is in scope, but it is a function-like macro
76+
77+
error: cannot find derive macro `from_utf8_mut` in this scope
78+
--> $DIR/issue-88206.rs:26:10
79+
|
80+
LL | #[derive(from_utf8_mut)]
81+
| ^^^^^^^^^^^^^
82+
|
83+
note: `from_utf8_mut` is imported here, but it is not a derive macro
84+
--> $DIR/issue-88206.rs:6:5
85+
|
86+
LL | use std::str::*;
87+
| ^^^^^^^^^^^
88+
89+
error: cannot find derive macro `Serialize` in this scope
90+
--> $DIR/issue-88206.rs:22:10
91+
|
92+
LL | #[derive(Serialize)]
93+
| ^^^^^^^^^
94+
|
95+
note: `Serialize` is imported here, but it is not a derive macro
96+
--> $DIR/issue-88206.rs:17:11
97+
|
98+
LL | use hey::{Serialize, Deserialize};
99+
| ^^^^^^^^^
100+
101+
warning: unused import: `std::str::*`
102+
--> $DIR/issue-88206.rs:6:5
103+
|
104+
LL | use std::str::*;
105+
| ^^^^^^^^^^^
106+
|
107+
note: the lint level is defined here
108+
--> $DIR/issue-88206.rs:3:9
109+
|
110+
LL | #![warn(unused_imports)]
111+
| ^^^^^^^^^^^^^^
112+
113+
warning: unused imports: `Deserialize`, `Serialize`
114+
--> $DIR/issue-88206.rs:17:11
115+
|
116+
LL | use hey::{Serialize, Deserialize};
117+
| ^^^^^^^^^ ^^^^^^^^^^^
118+
119+
error: aborting due to 10 previous errors; 2 warnings emitted
120+

0 commit comments

Comments
 (0)