about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-05 00:24:48 +0000
committerbors <bors@rust-lang.org>2022-05-05 00:24:48 +0000
commitbdcb6a99e853732f8ec050ae4986aa3af51d44c5 (patch)
tree98442fbffdeb4ce5fe2b88dba21709d1565c733f /src
parent4c60a0ea5b2385d7400df9db1ad04e96f2a4c154 (diff)
parent8e31cdefc42682e495a22c6a08b95526aea8a94e (diff)
Auto merge of #96593 - jackh726:issue-93262, r=compiler-errors
Revert "Prefer projection candidates instead of param_env candidates for Sized predicates"

Fixes #93262
Reopens #89352

This was a hack that seemed to have no negative side-effects at the time. Given that the latter has a workaround and likely less common than the former, it makes sense to revert this change.

r? `@compiler-errors`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-89352.base.stderr22
-rw-r--r--src/test/ui/generic-associated-types/bugs/issue-89352.rs (renamed from src/test/ui/generic-associated-types/issue-89352.rs)14
-rw-r--r--src/test/ui/generic-associated-types/issue-93262.rs21
3 files changed, 56 insertions, 1 deletions
diff --git a/src/test/ui/generic-associated-types/bugs/issue-89352.base.stderr b/src/test/ui/generic-associated-types/bugs/issue-89352.base.stderr
new file mode 100644
index 00000000000..81125a7d6f3
--- /dev/null
+++ b/src/test/ui/generic-associated-types/bugs/issue-89352.base.stderr
@@ -0,0 +1,22 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-89352.rs:36:13
+   |
+LL |         let a = A::reborrow::<'ai, 's>(self.a.clone());
+   |             ^ lifetime mismatch
+   |
+   = note: expected type `<<A as GenAssoc<T>>::Iter<'s> as Sized>`
+              found type `<<A as GenAssoc<T>>::Iter<'ai> as Sized>`
+note: the lifetime `'s` as defined here...
+  --> $DIR/issue-89352.rs:35:13
+   |
+LL |     fn iter<'s>(&'s self) -> Self::Iter<'s> {
+   |             ^^
+note: ...does not necessarily outlive the lifetime `'ai` as defined here
+  --> $DIR/issue-89352.rs:30:6
+   |
+LL | impl<'ai, T: 'ai, A: GenAssoc<T>> GenAssoc<T> for Wrapper<'ai, T, A>
+   |      ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/generic-associated-types/issue-89352.rs b/src/test/ui/generic-associated-types/bugs/issue-89352.rs
index d9c656d5f58..a9f0dd0a0b4 100644
--- a/src/test/ui/generic-associated-types/issue-89352.rs
+++ b/src/test/ui/generic-associated-types/bugs/issue-89352.rs
@@ -1,4 +1,16 @@
-// check-pass
+// revisions: base nll
+// ignore-compare-mode-nll
+//[nll] compile-flags: -Z borrowck=mir
+
+//[base] check-fail
+//[nll] check-pass
+// known-bug
+
+// This should pass, but we end up with `A::Iter<'ai>: Sized` for some specific
+// `'ai`. We also know that `for<'at> A::Iter<'at>: Sized` from the definition,
+// but we prefer param env candidates. We changed this to preference in #92191,
+// but this led to unintended consequences (#93262). Suprisingly, this passes
+// under NLL. So only a bug in migrate mode.
 
 #![feature(generic_associated_types)]
 
diff --git a/src/test/ui/generic-associated-types/issue-93262.rs b/src/test/ui/generic-associated-types/issue-93262.rs
new file mode 100644
index 00000000000..adc6aa8fa1a
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-93262.rs
@@ -0,0 +1,21 @@
+// check-pass
+
+#![feature(generic_associated_types)]
+
+pub trait Trait {
+    type Assoc<'a> where Self: 'a;
+}
+
+pub trait Foo<T: Trait>
+where
+    for<'a> T::Assoc<'a>: Clone
+{}
+
+pub struct Type;
+
+impl<T: Trait> Foo<T> for Type
+where
+    for<'a> T::Assoc<'a>: Clone
+{}
+
+fn main() {}