about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2022-11-14 17:42:46 +0100
committerlcnr <rust@lcnr.de>2022-11-15 13:34:08 +0100
commit45f441a7b41d09bb78b0ba3e260d2c868ef6add7 (patch)
tree0ab27b9bde513532c7f3b006f74148a246e85ad1 /src/test
parentca92d90b5917e7176d5ff06607a2cd5352c088d3 (diff)
downloadrust-45f441a7b41d09bb78b0ba3e260d2c868ef6add7.tar.gz
rust-45f441a7b41d09bb78b0ba3e260d2c868ef6add7.zip
nll: correctly deal with bivariance
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/mir/important-higher-ranked-regions.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/mir/important-higher-ranked-regions.rs b/src/test/ui/mir/important-higher-ranked-regions.rs
new file mode 100644
index 00000000000..cadfb3b66f2
--- /dev/null
+++ b/src/test/ui/mir/important-higher-ranked-regions.rs
@@ -0,0 +1,26 @@
+// check-pass
+// compile-flags: -Zvalidate-mir
+
+// This test checks that bivariant parameters are handled correctly
+// in the mir.
+#![allow(coherence_leak_check)]
+trait Trait {
+    type Assoc;
+}
+
+struct Foo<T, U>(T)
+where
+    T: Trait<Assoc = U>;
+
+impl Trait for for<'a> fn(&'a ()) {
+    type Assoc = u32;
+}
+impl Trait for fn(&'static ()) {
+    type Assoc = String;
+}
+
+fn foo(x: Foo<for<'a> fn(&'a ()), u32>) -> Foo<fn(&'static ()), String> {
+    x
+}
+
+fn main() {}