diff options
| author | Michael Goulet <michael@errs.io> | 2025-02-24 20:10:37 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-03-03 23:53:42 +0000 |
| commit | ab31129956869f6dfc25417230061bad72de9081 (patch) | |
| tree | 51012516a247f52d1bcc11c551d55a1951b20923 /tests/ui/methods | |
| parent | e16a049adbf94d610787430b6efdf31d896dc5b6 (diff) | |
| download | rust-ab31129956869f6dfc25417230061bad72de9081.tar.gz rust-ab31129956869f6dfc25417230061bad72de9081.zip | |
Point of macro expansion from call expr if it involves macro var
Diffstat (limited to 'tests/ui/methods')
| -rw-r--r-- | tests/ui/methods/ident-from-macro-expansion.rs | 18 | ||||
| -rw-r--r-- | tests/ui/methods/ident-from-macro-expansion.stderr | 21 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/methods/ident-from-macro-expansion.rs b/tests/ui/methods/ident-from-macro-expansion.rs new file mode 100644 index 00000000000..38d2fee0e53 --- /dev/null +++ b/tests/ui/methods/ident-from-macro-expansion.rs @@ -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 +} diff --git a/tests/ui/methods/ident-from-macro-expansion.stderr b/tests/ui/methods/ident-from-macro-expansion.stderr new file mode 100644 index 00000000000..b596ce29f6f --- /dev/null +++ b/tests/ui/methods/ident-from-macro-expansion.stderr @@ -0,0 +1,21 @@ +error[E0599]: no method named `hello` found for unit type `()` in the current scope + --> $DIR/ident-from-macro-expansion.rs:14:10 + | +LL | ().$id(); + | --- due to this macro variable +... +LL | dot!(hello); + | ^^^^^ method not found in `()` + +error[E0599]: no function or associated item named `hello` found for unit type `()` in the current scope + --> $DIR/ident-from-macro-expansion.rs:16:15 + | +LL | <()>::$id(); + | --- due to this macro variable +... +LL | dispatch!(hello); + | ^^^^^ function or associated item not found in `()` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. |
