forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#88232 - m-ou-se:macro-name-imported-but-not…
…-macro, r=estebank Add notes to macro-not-found diagnostics to point out how things with the same name were not a match. This adds notes like: ``` 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}; | ^^^^^^^^^ ``` Fixes rust-lang#88206 Includes rust-lang#88229 r? `@estebank`
- Loading branch information
Showing
8 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// compile-flags: -Z deduplicate-diagnostics=yes | ||
|
||
#![warn(unused_imports)] | ||
|
||
use std::str::*; | ||
//~^ NOTE `from_utf8` is imported here, but it is a function | ||
//~| NOTE `from_utf8_mut` is imported here, but it is a function | ||
//~| NOTE `from_utf8_unchecked` is imported here, but it is a function | ||
|
||
mod hey { | ||
pub trait Serialize {} | ||
pub trait Deserialize {} | ||
|
||
pub struct X(i32); | ||
} | ||
|
||
use hey::{Serialize, Deserialize, X}; | ||
//~^ NOTE `Serialize` is imported here, but it is only a trait, without a derive macro | ||
//~| NOTE `Deserialize` is imported here, but it is a trait | ||
//~| NOTE `X` is imported here, but it is a struct | ||
|
||
#[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 a struct | ||
|
||
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 | ||
|
||
X!(); | ||
//~^ ERROR cannot find macro `X` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
error: cannot find macro `X` in this scope | ||
--> $DIR/issue-88206.rs:64:5 | ||
| | ||
LL | X!(); | ||
| ^ | ||
| | ||
note: `X` is imported here, but it is a struct, not a macro | ||
--> $DIR/issue-88206.rs:17:35 | ||
| | ||
LL | use hey::{Serialize, Deserialize, X}; | ||
| ^ | ||
|
||
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: `#[test]` | ||
|
||
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: `#[derive(Copy)]` | ||
|
||
error: cannot find macro `Box` in this scope | ||
--> $DIR/issue-88206.rs:52:5 | ||
| | ||
LL | Box!(); | ||
| ^^^ | ||
| | ||
= note: `Box` is in scope, but it is a struct, 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 a function, not a macro | ||
--> $DIR/issue-88206.rs:5: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 a function, not an attribute | ||
--> $DIR/issue-88206.rs:5: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 a trait, not an attribute | ||
--> $DIR/issue-88206.rs:17:22 | ||
| | ||
LL | use hey::{Serialize, Deserialize, X}; | ||
| ^^^^^^^^^^^ | ||
|
||
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 a function, not a derive macro | ||
--> $DIR/issue-88206.rs:5: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 only a trait, without a derive macro | ||
--> $DIR/issue-88206.rs:17:11 | ||
| | ||
LL | use hey::{Serialize, Deserialize, X}; | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 11 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters