summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs')
-rw-r--r--tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs
new file mode 100644
index 000000000..05e2ea047
--- /dev/null
+++ b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs
@@ -0,0 +1,34 @@
+// Test that the NLL solver cannot find a solution
+// for `exists<R1> { forall<R1> { R2: R1 } }`.
+//
+// In this test, the impl should match `fn(T)` for some `T`,
+// but we ask it to match `for<'a> fn(&'a ())`. Due to argument
+// contravariance, this effectively requires a `T = &'b ()` where
+// `forall<'a> { 'a: 'b }`. Therefore, we get an error.
+//
+// Note the use of `-Zno-leak-check` here. This is presently required in order
+// to skip the leak-check errors.
+//
+// c.f. Issue #57642.
+//
+// compile-flags:-Zno-leak-check
+
+trait Y {
+ type F;
+ fn make_f() -> Self::F;
+}
+
+impl<T> Y for fn(T) {
+ type F = fn(T);
+
+ fn make_f() -> Self::F {
+ |_| {}
+ }
+}
+
+fn main() {
+ let _x = <fn(&())>::make_f();
+ //~^ ERROR implementation of `Y` is not general enough
+ //~| ERROR implementation of `Y` is not general enough
+ //~| ERROR implementation of `Y` is not general enough
+}