summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/issue-57280-1-flipped.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/nll/issue-57280-1-flipped.rs')
-rw-r--r--tests/ui/nll/issue-57280-1-flipped.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/nll/issue-57280-1-flipped.rs b/tests/ui/nll/issue-57280-1-flipped.rs
new file mode 100644
index 000000000..ad4b8dcfd
--- /dev/null
+++ b/tests/ui/nll/issue-57280-1-flipped.rs
@@ -0,0 +1,23 @@
+// This test should compile, as the lifetimes
+// in matches don't really matter.
+//
+// We currently use contravariance when checking the
+// type of match arms.
+
+trait Foo<'a> {
+ const C: &'a u32;
+}
+
+impl<'a, T> Foo<'a> for T {
+ const C: &'a u32 = &22;
+}
+
+fn foo<'a>(x: &'static u32) {
+ match x {
+ <() as Foo<'a>>::C => { }
+ //~^ ERROR lifetime may not live long enough
+ &_ => { }
+ }
+}
+
+fn main() {}