diff options
| author | bohan <bohan-zhang@foxmail.com> | 2024-03-12 10:55:17 +0800 |
|---|---|---|
| committer | bohan <bohan-zhang@foxmail.com> | 2024-03-13 16:11:16 +0800 |
| commit | 8fcdf54a6b98c129e951caf3a97cbf20db677ee3 (patch) | |
| tree | f34b8d1a37fdbe0e539f2c38e91b74a4358d98ef /tests | |
| parent | 5a6c1aa2bccfcbfa42f486a54c09bd698378faef (diff) | |
| download | rust-8fcdf54a6b98c129e951caf3a97cbf20db677ee3.tar.gz rust-8fcdf54a6b98c129e951caf3a97cbf20db677ee3.zip | |
delay expand macro bang when there has indeterminate path
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/macros/expand-full-asm.rs | 27 | ||||
| -rw-r--r-- | tests/ui/macros/expand-full-in-format-str.rs | 33 | ||||
| -rw-r--r-- | tests/ui/macros/expand-full-no-resolution.rs | 20 | ||||
| -rw-r--r-- | tests/ui/macros/expand-full-no-resolution.stderr | 30 |
4 files changed, 110 insertions, 0 deletions
diff --git a/tests/ui/macros/expand-full-asm.rs b/tests/ui/macros/expand-full-asm.rs new file mode 100644 index 00000000000..0b61aa718f3 --- /dev/null +++ b/tests/ui/macros/expand-full-asm.rs @@ -0,0 +1,27 @@ +//@only-aarch64 +//@check-pass +//@edition: 2018 + +// https://github.com/rust-lang/rust/issues/98291 + +use std::arch::{asm, global_asm}; + +macro_rules! wrap { + () => { + macro_rules! _a { + () => { + "nop" + }; + } + }; +} + +wrap!(); + +use _a as a; + +fn main() { + unsafe { asm!(a!()); } +} + +global_asm!(a!()); diff --git a/tests/ui/macros/expand-full-in-format-str.rs b/tests/ui/macros/expand-full-in-format-str.rs new file mode 100644 index 00000000000..f47f7651a81 --- /dev/null +++ b/tests/ui/macros/expand-full-in-format-str.rs @@ -0,0 +1,33 @@ +//@check-pass +//@edition: 2018 + +// https://github.com/rust-lang/rust/issues/98291 + +macro_rules! wrap { + () => { + macro_rules! _a { + () => { + "auxiliary/macro-include-items-expr.rs" + }; + } + macro_rules! _env_name { + () => { + "PATH" + } + } + }; +} + +wrap!(); + +use _a as a; +use _env_name as env_name; + +fn main() { + format_args!(a!()); + include!(a!()); + include_str!(a!()); + include_bytes!(a!()); + env!(env_name!()); + option_env!(env_name!()); +} diff --git a/tests/ui/macros/expand-full-no-resolution.rs b/tests/ui/macros/expand-full-no-resolution.rs new file mode 100644 index 00000000000..4d90b8e2a53 --- /dev/null +++ b/tests/ui/macros/expand-full-no-resolution.rs @@ -0,0 +1,20 @@ +//@edition: 2018 + +// https://github.com/rust-lang/rust/issues/98291 + +macro_rules! wrap { + () => { + macro_rules! _a { + () => { + "" + }; + } + }; +} + +wrap!(); + +fn main() { + format_args!(a!()); //~ ERROR: cannot find macro `a` in this scope + env!(a!()); //~ ERROR: cannot find macro `a` in this scope +} diff --git a/tests/ui/macros/expand-full-no-resolution.stderr b/tests/ui/macros/expand-full-no-resolution.stderr new file mode 100644 index 00000000000..2537a5032a9 --- /dev/null +++ b/tests/ui/macros/expand-full-no-resolution.stderr @@ -0,0 +1,30 @@ +error: cannot find macro `a` in this scope + --> $DIR/expand-full-no-resolution.rs:18:18 + | +LL | macro_rules! _a { + | --------------- similarly named macro `_a` defined here +... +LL | format_args!(a!()); + | ^ + | +help: a macro with a similar name exists, consider renaming `_a` into `a` + | +LL | macro_rules! a { + | ~ + +error: cannot find macro `a` in this scope + --> $DIR/expand-full-no-resolution.rs:19:10 + | +LL | macro_rules! _a { + | --------------- similarly named macro `_a` defined here +... +LL | env!(a!()); + | ^ + | +help: a macro with a similar name exists, consider renaming `_a` into `a` + | +LL | macro_rules! a { + | ~ + +error: aborting due to 2 previous errors + |
