about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-05 09:31:36 +0000
committerbors <bors@rust-lang.org>2019-11-05 09:31:36 +0000
commitd1fff4a4b213b3341c1ff994061b7965a5932c70 (patch)
tree092a1579b1c3ddeccf48280bbf1d0a0294eaa716 /src/test/ui
parent2e4da3caadc61fab2cfcffebcbfdd72fbcee62b7 (diff)
parent1ffa93e5f8229c34286f50d1d79dd410324a7d9d (diff)
Auto merge of #66109 - pietroalbini:rollup-2npidna, r=pietroalbini
Rollup of 10 pull requests

Successful merges:

 - #65136 (Update codegen option documentation.)
 - #65574 (docs: improve disclaimer regarding LinkedList)
 - #65720 (Add FFI bindings for LLVM's Module::getInstructionCount())
 - #65905 ([doc] fixes for unix/vxworks `OpenOptionsExt::mode`)
 - #65962 (Fix logic in example.)
 - #66019 (Improved std::iter::Chain documentation)
 - #66038 (doc(str): show example of chars().count() under len())
 - #66042 (Suggest correct code when encountering an incorrect trait bound referencing the current trait)
 - #66073 (Do not needlessly write-lock)
 - #66096 (Add a failing UI test for multiple loops of all kinds in a `const`)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/associated-types/associated-types-in-ambiguous-context.rs10
-rw-r--r--src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr18
-rw-r--r--src/test/ui/consts/const-loop.rs58
-rw-r--r--src/test/ui/consts/const-loop.stderr60
4 files changed, 143 insertions, 3 deletions
diff --git a/src/test/ui/associated-types/associated-types-in-ambiguous-context.rs b/src/test/ui/associated-types/associated-types-in-ambiguous-context.rs
index 1b1ea9d52a9..51b53908f98 100644
--- a/src/test/ui/associated-types/associated-types-in-ambiguous-context.rs
+++ b/src/test/ui/associated-types/associated-types-in-ambiguous-context.rs
@@ -10,6 +10,16 @@ trait Grab {
     type Value;
     fn grab(&self) -> Grab::Value;
     //~^ ERROR ambiguous associated type
+
+    fn get(&self) -> Get::Value;
+    //~^ ERROR ambiguous associated type
+}
+
+trait Bar {}
+
+trait Foo where Foo::Assoc: Bar {
+//~^ ERROR ambiguous associated type
+    type Assoc;
 }
 
 type X = std::ops::Deref::Target;
diff --git a/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr b/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr
index 83667b54807..77835c5f676 100644
--- a/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr
+++ b/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr
@@ -5,7 +5,13 @@ LL | fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
    |                                    ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Get>::Value`
 
 error[E0223]: ambiguous associated type
-  --> $DIR/associated-types-in-ambiguous-context.rs:15:10
+  --> $DIR/associated-types-in-ambiguous-context.rs:20:17
+   |
+LL | trait Foo where Foo::Assoc: Bar {
+   |                 ^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Foo>::Assoc`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/associated-types-in-ambiguous-context.rs:25:10
    |
 LL | type X = std::ops::Deref::Target;
    |          ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as std::ops::Deref>::Target`
@@ -14,8 +20,14 @@ error[E0223]: ambiguous associated type
   --> $DIR/associated-types-in-ambiguous-context.rs:11:23
    |
 LL |     fn grab(&self) -> Grab::Value;
-   |                       ^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Grab>::Value`
+   |                       ^^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Grab>::Value`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/associated-types-in-ambiguous-context.rs:14:22
+   |
+LL |     fn get(&self) -> Get::Value;
+   |                      ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Get>::Value`
 
-error: aborting due to 3 previous errors
+error: aborting due to 5 previous errors
 
 For more information about this error, try `rustc --explain E0223`.
diff --git a/src/test/ui/consts/const-loop.rs b/src/test/ui/consts/const-loop.rs
new file mode 100644
index 00000000000..954f269d30e
--- /dev/null
+++ b/src/test/ui/consts/const-loop.rs
@@ -0,0 +1,58 @@
+const _: i32 = {
+    let mut x = 0;
+
+    while x < 4 {
+        //~^ ERROR constant contains unimplemented expression type
+        //~| ERROR constant contains unimplemented expression type
+        x += 1;
+    }
+
+    while x < 8 {
+        x += 1;
+    }
+
+    x
+};
+
+const _: i32 = {
+    let mut x = 0;
+
+    for i in 0..4 {
+        //~^ ERROR constant contains unimplemented expression type
+        //~| ERROR constant contains unimplemented expression type
+        //~| ERROR references in constants may only refer to immutable values
+        //~| ERROR calls in constants are limited to constant functions, tuple
+        //         structs and tuple variants
+        x += i;
+    }
+
+    for i in 0..4 {
+        x += i;
+    }
+
+    x
+};
+
+const _: i32 = {
+    let mut x = 0;
+
+    loop {
+        x += 1;
+        if x == 4 {
+            //~^ ERROR constant contains unimplemented expression type
+            //~| ERROR constant contains unimplemented expression type
+            break;
+        }
+    }
+
+    loop {
+        x += 1;
+        if x == 8 {
+            break;
+        }
+    }
+
+    x
+};
+
+fn main() {}
diff --git a/src/test/ui/consts/const-loop.stderr b/src/test/ui/consts/const-loop.stderr
new file mode 100644
index 00000000000..e6e4e2f5bb8
--- /dev/null
+++ b/src/test/ui/consts/const-loop.stderr
@@ -0,0 +1,60 @@
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:4:11
+   |
+LL |     while x < 4 {
+   |           ^^^^^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:4:5
+   |
+LL | /     while x < 4 {
+LL | |
+LL | |
+LL | |         x += 1;
+LL | |     }
+   | |_____^
+
+error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
+  --> $DIR/const-loop.rs:20:14
+   |
+LL |     for i in 0..4 {
+   |              ^^^^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:20:14
+   |
+LL |     for i in 0..4 {
+   |              ^^^^
+
+error[E0017]: references in constants may only refer to immutable values
+  --> $DIR/const-loop.rs:20:14
+   |
+LL |     for i in 0..4 {
+   |              ^^^^ constants require immutable values
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:20:9
+   |
+LL |     for i in 0..4 {
+   |         ^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:41:12
+   |
+LL |         if x == 4 {
+   |            ^^^^^^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const-loop.rs:41:9
+   |
+LL | /         if x == 4 {
+LL | |
+LL | |
+LL | |             break;
+LL | |         }
+   | |_________^
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0015, E0017, E0019.
+For more information about an error, try `rustc --explain E0015`.