about summary refs log tree commit diff
path: root/tests/ui/macros/nested-use-as.rs
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-03-19 20:12:57 +0800
committerbohan <bohan-zhang@foxmail.com>2023-03-19 20:18:45 +0800
commit177572241076e4885c5c12e407d3ea10d3b2363f (patch)
tree0fdba88d34411b8c4fbce558a94ade60daacf582 /tests/ui/macros/nested-use-as.rs
parentab9bb3ea368b2412531a3e8c07ba73d1dd690134 (diff)
downloadrust-177572241076e4885c5c12e407d3ea10d3b2363f.tar.gz
rust-177572241076e4885c5c12e407d3ea10d3b2363f.zip
fix: modify the condition that `resolve_imports` stops
Diffstat (limited to 'tests/ui/macros/nested-use-as.rs')
-rw-r--r--tests/ui/macros/nested-use-as.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/ui/macros/nested-use-as.rs b/tests/ui/macros/nested-use-as.rs
new file mode 100644
index 00000000000..21aa81e8092
--- /dev/null
+++ b/tests/ui/macros/nested-use-as.rs
@@ -0,0 +1,83 @@
+// check-pass
+// edition:2018
+// issue: https://github.com/rust-lang/rust/issues/97534
+
+macro_rules! m {
+    () => {
+        macro_rules! foo {
+            () => {}
+        }
+        use foo as bar;
+    }
+}
+
+m!{}
+
+use bar as baz;
+
+baz!{}
+
+macro_rules! foo2 {
+    () => {};
+}
+
+macro_rules! m2 {
+    () => {
+        use foo2 as bar2;
+    };
+}
+
+m2! {}
+
+use bar2 as baz2;
+
+baz2! {}
+
+macro_rules! n1 {
+    () => {
+        macro_rules! n2 {
+            () => {
+                macro_rules! n3 {
+                    () => {
+                        macro_rules! n4 {
+                            () => {}
+                        }
+                        use n4 as c4;
+                    }
+                }
+                use n3 as c3;
+            }
+        }
+        use n2 as c2;
+    }
+}
+
+use n1 as c1;
+c1!{}
+use c2 as a2;
+a2!{}
+use c3 as a3;
+a3!{}
+use c4 as a4;
+a4!{}
+
+// https://github.com/rust-lang/rust/pull/108729#issuecomment-1474750675
+// reversed
+use d5 as d6;
+use d4 as d5;
+use d3 as d4;
+use d2 as d3;
+use d1 as d2;
+use foo2 as d1;
+d6! {}
+
+// mess
+use f3 as f4;
+f5! {}
+use f1 as f2;
+use f4 as f5;
+use f2 as f3;
+use foo2 as f1;
+
+fn main() {
+}