about summary refs log tree commit diff
path: root/src/test/ui/use
diff options
context:
space:
mode:
authormibac138 <5672750+mibac138@users.noreply.github.com>2020-05-03 18:56:52 +0200
committermibac138 <5672750+mibac138@users.noreply.github.com>2020-05-19 20:40:47 +0200
commitd190e10f74afbe7edb5755bb0e0825450ea6c3bb (patch)
tree9b385884079dd5da02dcace11b49662c32690744 /src/test/ui/use
parent84a44218ad9dd0e278d934a72975dbad4f88c235 (diff)
Add error recovery for `use foo::self`
Diffstat (limited to 'src/test/ui/use')
-rw-r--r--src/test/ui/use/use-mod/use-mod-4.stderr2
-rw-r--r--src/test/ui/use/use-mod/use-mod-5.rs13
-rw-r--r--src/test/ui/use/use-mod/use-mod-5.stderr18
-rw-r--r--src/test/ui/use/use-mod/use-mod-6.rs13
-rw-r--r--src/test/ui/use/use-mod/use-mod-6.stderr18
5 files changed, 63 insertions, 1 deletions
diff --git a/src/test/ui/use/use-mod/use-mod-4.stderr b/src/test/ui/use/use-mod/use-mod-4.stderr
index 9d853296798..e01c2cbf732 100644
--- a/src/test/ui/use/use-mod/use-mod-4.stderr
+++ b/src/test/ui/use/use-mod/use-mod-4.stderr
@@ -32,7 +32,7 @@ error[E0432]: unresolved import `foo`
   --> $DIR/use-mod-4.rs:1:5
    |
 LL | use foo::self;
-   |     ^^^ maybe a missing crate `foo`?
+   |     ^^^^^^^^^ no `foo` in the root
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/use/use-mod/use-mod-5.rs b/src/test/ui/use/use-mod/use-mod-5.rs
new file mode 100644
index 00000000000..df5b423ec57
--- /dev/null
+++ b/src/test/ui/use/use-mod/use-mod-5.rs
@@ -0,0 +1,13 @@
+mod foo {
+    pub mod bar {
+        pub fn drop() {}
+    }
+}
+
+use foo::bar::self;
+//~^ ERROR `self` imports are only allowed within a { } list
+
+fn main() {
+    // Because of error recovery this shouldn't error
+    bar::drop();
+}
diff --git a/src/test/ui/use/use-mod/use-mod-5.stderr b/src/test/ui/use/use-mod/use-mod-5.stderr
new file mode 100644
index 00000000000..859547fbc4d
--- /dev/null
+++ b/src/test/ui/use/use-mod/use-mod-5.stderr
@@ -0,0 +1,18 @@
+error[E0429]: `self` imports are only allowed within a { } list
+  --> $DIR/use-mod-5.rs:7:13
+   |
+LL | use foo::bar::self;
+   |             ^^^^^^
+   |
+help: Remove `::self`..
+   |
+LL | use foo::bar;
+   |            --
+help: ..or add braces around `self`
+   |
+LL | use foo::bar::{self};
+   |               ^    ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0429`.
diff --git a/src/test/ui/use/use-mod/use-mod-6.rs b/src/test/ui/use/use-mod/use-mod-6.rs
new file mode 100644
index 00000000000..1f8777daca4
--- /dev/null
+++ b/src/test/ui/use/use-mod/use-mod-6.rs
@@ -0,0 +1,13 @@
+mod foo {
+    pub mod bar {
+        pub fn drop() {}
+    }
+}
+
+use foo::bar::self as abc;
+//~^ ERROR `self` imports are only allowed within a { } list
+
+fn main() {
+    // Because of error recovery this shouldn't error
+    abc::drop();
+}
diff --git a/src/test/ui/use/use-mod/use-mod-6.stderr b/src/test/ui/use/use-mod/use-mod-6.stderr
new file mode 100644
index 00000000000..0042325229a
--- /dev/null
+++ b/src/test/ui/use/use-mod/use-mod-6.stderr
@@ -0,0 +1,18 @@
+error[E0429]: `self` imports are only allowed within a { } list
+  --> $DIR/use-mod-6.rs:7:13
+   |
+LL | use foo::bar::self as abc;
+   |             ^^^^^^
+   |
+help: Remove `::self`..
+   |
+LL | use foo::bar as abc;
+   |            --
+help: ..or add braces around `self`
+   |
+LL | use foo::bar::{self as abc};
+   |               ^           ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0429`.