forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#137565 - compiler-errors:macro-ex, r=estebank
Try to point of macro expansion from resolver and method errors if it involves macro var In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error. r? ``````@estebank`````` or reassign
- Loading branch information
Showing
17 changed files
with
225 additions
and
15 deletions.
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
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
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,23 @@ | ||
trait Trait {} | ||
impl Trait for () {} | ||
|
||
macro_rules! fully_qualified { | ||
($id:ident) => { | ||
<() as Trait>::$id | ||
} | ||
} | ||
|
||
macro_rules! type_dependent { | ||
($t:ident, $id:ident) => { | ||
T::$id | ||
} | ||
} | ||
|
||
fn t<T: Trait>() { | ||
let x: fully_qualified!(Assoc); | ||
//~^ ERROR cannot find associated type `Assoc` in trait `Trait` | ||
let x: type_dependent!(T, Assoc); | ||
//~^ ERROR associated type `Assoc` not found for `T` | ||
} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
tests/ui/associated-types/ident-from-macro-expansion.stderr
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,22 @@ | ||
error[E0576]: cannot find associated type `Assoc` in trait `Trait` | ||
--> $DIR/ident-from-macro-expansion.rs:17:29 | ||
| | ||
LL | <() as Trait>::$id | ||
| --- due to this macro variable | ||
... | ||
LL | let x: fully_qualified!(Assoc); | ||
| ^^^^^ not found in `Trait` | ||
|
||
error[E0220]: associated type `Assoc` not found for `T` | ||
--> $DIR/ident-from-macro-expansion.rs:19:31 | ||
| | ||
LL | T::$id | ||
| --- due to this macro variable | ||
... | ||
LL | let x: type_dependent!(T, Assoc); | ||
| ^^^^^ associated type `Assoc` not found | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0220, E0576. | ||
For more information about an error, try `rustc --explain E0220`. |
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
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,18 @@ | ||
macro_rules! dot { | ||
($id:ident) => { | ||
().$id(); | ||
} | ||
} | ||
|
||
macro_rules! dispatch { | ||
($id:ident) => { | ||
<()>::$id(); | ||
} | ||
} | ||
|
||
fn main() { | ||
dot!(hello); | ||
//~^ ERROR no method named `hello` found for unit type `()` in the current scope | ||
dispatch!(hello); | ||
//~^ ERROR no function or associated item named `hello` found for unit type `()` in the current scope | ||
} |
Oops, something went wrong.