about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/lub-glb/old-lub-glb-hr.rs36
-rw-r--r--src/test/ui/lub-glb/old-lub-glb-hr.stderr22
-rw-r--r--src/test/ui/lub-glb/old-lub-glb-object.rs38
-rw-r--r--src/test/ui/lub-glb/old-lub-glb-object.stderr22
4 files changed, 118 insertions, 0 deletions
diff --git a/src/test/ui/lub-glb/old-lub-glb-hr.rs b/src/test/ui/lub-glb/old-lub-glb-hr.rs
new file mode 100644
index 00000000000..85c90bb375f
--- /dev/null
+++ b/src/test/ui/lub-glb/old-lub-glb-hr.rs
@@ -0,0 +1,36 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we give a note when the old LUB/GLB algorithm would have
+// succeeded but the new code (which is stricter) gives an error.
+
+fn foo(
+    x: fn(&u8, &u8),
+    y: for<'a> fn(&'a u8, &'a u8),
+) {
+    let z = match 22 {
+        0 => x,
+        _ => y,
+    };
+}
+
+fn bar(
+    x: fn(&u8, &u8),
+    y: for<'a> fn(&'a u8, &'a u8),
+) {
+    let z = match 22 {
+        // No error with an explicit cast:
+        0 => x as for<'a> fn(&'a u8, &'a u8),
+        _ => y,
+    };
+}
+
+fn main() {
+}
diff --git a/src/test/ui/lub-glb/old-lub-glb-hr.stderr b/src/test/ui/lub-glb/old-lub-glb-hr.stderr
new file mode 100644
index 00000000000..4a310a5e6b2
--- /dev/null
+++ b/src/test/ui/lub-glb/old-lub-glb-hr.stderr
@@ -0,0 +1,22 @@
+error[E0308]: match arms have incompatible types
+  --> $DIR/old-lub-glb-hr.rs:18:13
+   |
+18 |       let z = match 22 {
+   |  _____________^
+19 | |         0 => x,
+20 | |         _ => y,
+21 | |     };
+   | |_____^ expected bound lifetime parameter, found concrete lifetime
+   |
+   = note: expected type `for<'r, 's> fn(&'r u8, &'s u8)`
+              found type `for<'a> fn(&'a u8, &'a u8)`
+   = note: this was previously accepted by the compiler but has been phased out
+   = note: for more information, see https://github.com/rust-lang/rust/issues/45852
+note: match arm with an incompatible type
+  --> $DIR/old-lub-glb-hr.rs:20:14
+   |
+20 |         _ => y,
+   |              ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/lub-glb/old-lub-glb-object.rs b/src/test/ui/lub-glb/old-lub-glb-object.rs
new file mode 100644
index 00000000000..7cf89b68be1
--- /dev/null
+++ b/src/test/ui/lub-glb/old-lub-glb-object.rs
@@ -0,0 +1,38 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we give a note when the old LUB/GLB algorithm would have
+// succeeded but the new code (which is stricter) gives an error.
+
+trait Foo<T, U> { }
+
+fn foo(
+    x: &for<'a, 'b> Foo<&'a u8, &'b u8>,
+    y: &for<'a> Foo<&'a u8, &'a u8>,
+) {
+    let z = match 22 {
+        0 => x,
+        _ => y,
+    };
+}
+
+fn bar(
+    x: &for<'a, 'b> Foo<&'a u8, &'b u8>,
+    y: &for<'a> Foo<&'a u8, &'a u8>,
+) {
+    // Accepted with explicit case:
+    let z = match 22 {
+        0 => x as &for<'a> Foo<&'a u8, &'a u8>,
+        _ => y,
+    };
+}
+
+fn main() {
+}
diff --git a/src/test/ui/lub-glb/old-lub-glb-object.stderr b/src/test/ui/lub-glb/old-lub-glb-object.stderr
new file mode 100644
index 00000000000..a1077f40bf5
--- /dev/null
+++ b/src/test/ui/lub-glb/old-lub-glb-object.stderr
@@ -0,0 +1,22 @@
+error[E0308]: match arms have incompatible types
+  --> $DIR/old-lub-glb-object.rs:20:13
+   |
+20 |       let z = match 22 {
+   |  _____________^
+21 | |         0 => x,
+22 | |         _ => y,
+23 | |     };
+   | |_____^ expected bound lifetime parameter 'a, found concrete lifetime
+   |
+   = note: expected type `&for<'a, 'b> Foo<&'a u8, &'b u8>`
+              found type `&for<'a> Foo<&'a u8, &'a u8>`
+   = note: this was previously accepted by the compiler but has been phased out
+   = note: for more information, see https://github.com/rust-lang/rust/issues/45852
+note: match arm with an incompatible type
+  --> $DIR/old-lub-glb-object.rs:22:14
+   |
+22 |         _ => y,
+   |              ^
+
+error: aborting due to previous error
+