about summary refs log tree commit diff
path: root/tests/ui/blind
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/blind
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/blind')
-rw-r--r--tests/ui/blind/blind-item-block-item-shadow.rs9
-rw-r--r--tests/ui/blind/blind-item-block-item-shadow.stderr17
-rw-r--r--tests/ui/blind/blind-item-block-middle.rs9
-rw-r--r--tests/ui/blind/blind-item-block-middle.stderr16
-rw-r--r--tests/ui/blind/blind-item-item-shadow.rs7
-rw-r--r--tests/ui/blind/blind-item-item-shadow.stderr18
6 files changed, 76 insertions, 0 deletions
diff --git a/tests/ui/blind/blind-item-block-item-shadow.rs b/tests/ui/blind/blind-item-block-item-shadow.rs
new file mode 100644
index 00000000000..d90ef77e299
--- /dev/null
+++ b/tests/ui/blind/blind-item-block-item-shadow.rs
@@ -0,0 +1,9 @@
+mod foo { pub struct Bar; }
+
+fn main() {
+    {
+        struct Bar;
+        use foo::Bar;
+        //~^ ERROR the name `Bar` is defined multiple times
+    }
+}
diff --git a/tests/ui/blind/blind-item-block-item-shadow.stderr b/tests/ui/blind/blind-item-block-item-shadow.stderr
new file mode 100644
index 00000000000..68b3f4c1ae2
--- /dev/null
+++ b/tests/ui/blind/blind-item-block-item-shadow.stderr
@@ -0,0 +1,17 @@
+error[E0255]: the name `Bar` is defined multiple times
+  --> $DIR/blind-item-block-item-shadow.rs:6:13
+   |
+LL |         struct Bar;
+   |         ----------- previous definition of the type `Bar` here
+LL |         use foo::Bar;
+   |             ^^^^^^^^ `Bar` reimported here
+   |
+   = note: `Bar` must be defined only once in the type namespace of this block
+help: you can use `as` to change the binding name of the import
+   |
+LL |         use foo::Bar as OtherBar;
+   |             ~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/tests/ui/blind/blind-item-block-middle.rs b/tests/ui/blind/blind-item-block-middle.rs
new file mode 100644
index 00000000000..6cd3f3bd412
--- /dev/null
+++ b/tests/ui/blind/blind-item-block-middle.rs
@@ -0,0 +1,9 @@
+#![allow(non_camel_case_types)]
+
+mod foo { pub struct bar; }
+
+fn main() {
+    let bar = 5;
+    //~^ ERROR mismatched types
+    use foo::bar;
+}
diff --git a/tests/ui/blind/blind-item-block-middle.stderr b/tests/ui/blind/blind-item-block-middle.stderr
new file mode 100644
index 00000000000..eb64fea9433
--- /dev/null
+++ b/tests/ui/blind/blind-item-block-middle.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+  --> $DIR/blind-item-block-middle.rs:6:9
+   |
+LL | mod foo { pub struct bar; }
+   |           -------------- unit struct defined here
+...
+LL |     let bar = 5;
+   |         ^^^   - this expression has type `{integer}`
+   |         |
+   |         expected integer, found struct `bar`
+   |         `bar` is interpreted as a unit struct, not a new binding
+   |         help: introduce a new binding instead: `other_bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/blind/blind-item-item-shadow.rs b/tests/ui/blind/blind-item-item-shadow.rs
new file mode 100644
index 00000000000..82d07ea7091
--- /dev/null
+++ b/tests/ui/blind/blind-item-item-shadow.rs
@@ -0,0 +1,7 @@
+mod foo { pub mod foo {  } }
+
+use foo::foo;
+//~^ ERROR the name `foo` is defined multiple times
+//~| `foo` reimported here
+
+fn main() {}
diff --git a/tests/ui/blind/blind-item-item-shadow.stderr b/tests/ui/blind/blind-item-item-shadow.stderr
new file mode 100644
index 00000000000..7f9e8008929
--- /dev/null
+++ b/tests/ui/blind/blind-item-item-shadow.stderr
@@ -0,0 +1,18 @@
+error[E0255]: the name `foo` is defined multiple times
+  --> $DIR/blind-item-item-shadow.rs:3:5
+   |
+LL | mod foo { pub mod foo {  } }
+   | ------- previous definition of the module `foo` here
+LL |
+LL | use foo::foo;
+   |     ^^^^^^^^ `foo` reimported here
+   |
+   = note: `foo` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+   |
+LL | use foo::foo as other_foo;
+   |     ~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.