Add tests for macro-not-found diagnostics.

This commit is contained in:
Mara Bos 2021-08-22 15:05:13 +02:00
parent 7977cb43b0
commit 11c879d209
4 changed files with 183 additions and 44 deletions

View File

@ -1,18 +0,0 @@
// compile-flags: -Z deduplicate-diagnostics=yes
#![warn(unused_imports)]
//~^ NOTE lint level
mod hey {
pub trait Serialize {}
}
use hey::Serialize;
//~^ WARNING unused import
//~| NOTE `Serialize` is imported here
#[derive(Serialize)]
//~^ ERROR cannot find derive macro `Serialize`
struct A;
fn main() {}

View File

@ -1,26 +0,0 @@
error: cannot find derive macro `Serialize` in this scope
--> $DIR/issue-88206.rs:14:10
|
LL | #[derive(Serialize)]
| ^^^^^^^^^
|
note: `Serialize` is imported here, but it is not a derive macro
--> $DIR/issue-88206.rs:10:5
|
LL | use hey::Serialize;
| ^^^^^^^^^^^^^^
warning: unused import: `hey::Serialize`
--> $DIR/issue-88206.rs:10:5
|
LL | use hey::Serialize;
| ^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-88206.rs:3:9
|
LL | #![warn(unused_imports)]
| ^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted

View File

@ -0,0 +1,63 @@
// compile-flags: -Z deduplicate-diagnostics=yes
#![warn(unused_imports)]
//~^ NOTE lint level
use std::str::*;
//~^ WARNING unused import
//~| NOTE `from_utf8` is imported here, but it is not a macro
//~| NOTE `from_utf8_mut` is imported here, but it is not a derive macro
//~| NOTE `from_utf8_unchecked` is imported here, but it is not an attribute
mod hey {
pub trait Serialize {}
pub trait Deserialize {}
}
use hey::{Serialize, Deserialize};
//~^ WARNING unused import
//~| NOTE `Serialize` is imported here, but it is not a derive macro
//~| NOTE `Deserialize` is imported here, but it is not an attribute
#[derive(Serialize)]
//~^ ERROR cannot find derive macro `Serialize`
struct A;
#[derive(from_utf8_mut)]
//~^ ERROR cannot find derive macro `from_utf8_mut`
struct B;
#[derive(println)]
//~^ ERROR cannot find derive macro `println`
//~| NOTE `println` is in scope, but it is a function-like macro
struct C;
#[Deserialize]
//~^ ERROR cannot find attribute `Deserialize`
struct D;
#[from_utf8_unchecked]
//~^ ERROR cannot find attribute `from_utf8_unchecked`
struct E;
#[println]
//~^ ERROR cannot find attribute `println`
//~| NOTE `println` is in scope, but it is a function-like macro
struct F;
fn main() {
from_utf8!();
//~^ ERROR cannot find macro `from_utf8`
Box!();
//~^ ERROR cannot find macro `Box`
//~| NOTE `Box` is in scope, but it is not a macro
Copy!();
//~^ ERROR cannot find macro `Copy`
//~| NOTE `Copy` is in scope, but it is a derive macro
test!();
//~^ ERROR cannot find macro `test`
//~| NOTE `test` is in scope, but it is an attribute
}

View File

@ -0,0 +1,120 @@
error: cannot find macro `test` in this scope
--> $DIR/issue-88206.rs:60:5
|
LL | test!();
| ^^^^
|
= note: `test` is in scope, but it is an attribute
error: cannot find macro `Copy` in this scope
--> $DIR/issue-88206.rs:56:5
|
LL | Copy!();
| ^^^^
|
= note: `Copy` is in scope, but it is a derive macro
error: cannot find macro `Box` in this scope
--> $DIR/issue-88206.rs:52:5
|
LL | Box!();
| ^^^
|
= note: `Box` is in scope, but it is not a macro
error: cannot find macro `from_utf8` in this scope
--> $DIR/issue-88206.rs:49:5
|
LL | from_utf8!();
| ^^^^^^^^^
|
note: `from_utf8` is imported here, but it is not a macro
--> $DIR/issue-88206.rs:6:5
|
LL | use std::str::*;
| ^^^^^^^^^^^
error: cannot find attribute `println` in this scope
--> $DIR/issue-88206.rs:43:3
|
LL | #[println]
| ^^^^^^^
|
= note: `println` is in scope, but it is a function-like macro
error: cannot find attribute `from_utf8_unchecked` in this scope
--> $DIR/issue-88206.rs:39:3
|
LL | #[from_utf8_unchecked]
| ^^^^^^^^^^^^^^^^^^^
|
note: `from_utf8_unchecked` is imported here, but it is not an attribute
--> $DIR/issue-88206.rs:6:5
|
LL | use std::str::*;
| ^^^^^^^^^^^
error: cannot find attribute `Deserialize` in this scope
--> $DIR/issue-88206.rs:35:3
|
LL | #[Deserialize]
| ^^^^^^^^^^^
|
note: `Deserialize` is imported here, but it is not an attribute
--> $DIR/issue-88206.rs:17:22
|
LL | use hey::{Serialize, Deserialize};
| ^^^^^^^^^^^
error: cannot find derive macro `println` in this scope
--> $DIR/issue-88206.rs:30:10
|
LL | #[derive(println)]
| ^^^^^^^
|
= note: `println` is in scope, but it is a function-like macro
error: cannot find derive macro `from_utf8_mut` in this scope
--> $DIR/issue-88206.rs:26:10
|
LL | #[derive(from_utf8_mut)]
| ^^^^^^^^^^^^^
|
note: `from_utf8_mut` is imported here, but it is not a derive macro
--> $DIR/issue-88206.rs:6:5
|
LL | use std::str::*;
| ^^^^^^^^^^^
error: cannot find derive macro `Serialize` in this scope
--> $DIR/issue-88206.rs:22:10
|
LL | #[derive(Serialize)]
| ^^^^^^^^^
|
note: `Serialize` is imported here, but it is not a derive macro
--> $DIR/issue-88206.rs:17:11
|
LL | use hey::{Serialize, Deserialize};
| ^^^^^^^^^
warning: unused import: `std::str::*`
--> $DIR/issue-88206.rs:6:5
|
LL | use std::str::*;
| ^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-88206.rs:3:9
|
LL | #![warn(unused_imports)]
| ^^^^^^^^^^^^^^
warning: unused imports: `Deserialize`, `Serialize`
--> $DIR/issue-88206.rs:17:11
|
LL | use hey::{Serialize, Deserialize};
| ^^^^^^^^^ ^^^^^^^^^^^
error: aborting due to 10 previous errors; 2 warnings emitted