diff options
| author | bors <bors@rust-lang.org> | 2022-09-16 16:46:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-16 16:46:14 +0000 |
| commit | 4d4e51e428ba7b1ece3c67d1c114e2b486dc85dd (patch) | |
| tree | ba9e276a337aeac2af09c2212709314f5e534c26 /src/test | |
| parent | 54f20bbb8a7aeab93da17c0019c1aaa10329245a (diff) | |
| parent | d97fdf16d96a1bf36d024074877a132802fd5843 (diff) | |
| download | rust-4d4e51e428ba7b1ece3c67d1c114e2b486dc85dd.tar.gz rust-4d4e51e428ba7b1ece3c67d1c114e2b486dc85dd.zip | |
Auto merge of #101902 - jackh726:revert-static-hrtb-error, r=nikomatsakis
Partially revert #101433 reverts #101433 to fix #101844 We should get this into the beta cut, since the ICE is getting hit quite a bit.
Diffstat (limited to 'src/test')
13 files changed, 73 insertions, 200 deletions
diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs deleted file mode 100644 index 719d1bd5a4c..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.rs +++ /dev/null @@ -1,35 +0,0 @@ -// check-fail -// known-bug - -// This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for -// all 'a where I::Item<'a> is WF", but really means "for all 'a possible" - -use std::fmt::Debug; - -pub trait LendingIterator { - type Item<'this> - where - Self: 'this; -} - -pub struct WindowsMut<'x> { - slice: &'x (), -} - -impl<'y> LendingIterator for WindowsMut<'y> { - type Item<'this> = &'this mut () where 'y: 'this; -} - -fn print_items<I>(_iter: I) -where - I: LendingIterator, - for<'a> I::Item<'a>: Debug, -{ -} - -fn main() { - let slice = &mut (); - //~^ temporary value dropped while borrowed - let windows = WindowsMut { slice }; - print_items::<WindowsMut<'_>>(windows); -} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr deleted file mode 100644 index 414999881d4..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-1.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/hrtb-implied-1.rs:31:22 - | -LL | let slice = &mut (); - | ^^ creates a temporary which is freed while still in use -... -LL | print_items::<WindowsMut<'_>>(windows); - | -------------------------------------- argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-implied-1.rs:26:26 - | -LL | for<'a> I::Item<'a>: Debug, - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs deleted file mode 100644 index 8e6c5348e71..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs +++ /dev/null @@ -1,40 +0,0 @@ -// check-fail -// known-bug - -// This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for -// all 'a where I::Item<'a> is WF", but really means "for all 'a possible" - -trait LendingIterator: Sized { - type Item<'a> - where - Self: 'a; - fn next(&mut self) -> Self::Item<'_>; -} -fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool -where - F: FnMut(I::Item<'_>), -{ - let mut iter2 = Eat(iter, f); - let _next = iter2.next(); - //~^ borrowed data escapes - true -} -impl<I: LendingIterator> LendingIterator for &mut I { - type Item<'a> = I::Item<'a> where Self:'a; - fn next(&mut self) -> Self::Item<'_> { - (**self).next() - } -} - -struct Eat<I, F>(I, F); -impl<I: LendingIterator, F> Iterator for Eat<I, F> -where - F: FnMut(I::Item<'_>), -{ - type Item = (); - fn next(&mut self) -> Option<Self::Item> { - None - } -} - -fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr deleted file mode 100644 index 1ee270398de..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/hrtb-implied-2.rs:18:17 - | -LL | fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool - | ---- - let's call the lifetime of this reference `'1` - | | - | `iter` is a reference that is only valid in the function body -... -LL | let _next = iter2.next(); - | ^^^^^^^^^^^^ - | | - | `iter` escapes the function body here - | argument requires that `'1` must outlive `'static` - | - = note: requirement occurs because of a mutable reference to `Eat<&mut I, F>` - = note: mutable references are invariant over their type parameter - = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance - = note: due to current limitations in the borrow checker, this implies a `'static` lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs deleted file mode 100644 index bc9e6c8aea8..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs +++ /dev/null @@ -1,23 +0,0 @@ -trait LendingIterator { - type Item<'a> - where - Self: 'a; -} - -impl LendingIterator for &str { - type Item<'a> = () where Self:'a; -} - -fn trivial_bound<I>(_: I) -where - I: LendingIterator, - for<'a> I::Item<'a>: Sized, -{ -} - -fn fails(iter: &str) { - trivial_bound(iter); - //~^ borrowed data escapes -} - -fn main() {} diff --git a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr b/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr deleted file mode 100644 index c67e02437cd..00000000000 --- a/src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/hrtb-implied-3.rs:19:5 - | -LL | fn fails(iter: &str) { - | ---- - let's call the lifetime of this reference `'1` - | | - | `iter` is a reference that is only valid in the function body -LL | trivial_bound(iter); - | ^^^^^^^^^^^^^^^^^^^ - | | - | `iter` escapes the function body here - | argument requires that `'1` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-implied-3.rs:14:26 - | -LL | for<'a> I::Item<'a>: Sized, - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.stderr index 45b64d2b024..086177cc106 100644 --- a/src/test/ui/generic-associated-types/trait-objects.extended.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.extended.stderr @@ -11,8 +11,6 @@ LL | x.size_hint().0 | | | `x` escapes the function body here | argument requires that `'1` must outlive `'static` - | - = note: due to current limitations in the borrow checker, this implies a `'static` lifetime error: aborting due to previous error diff --git a/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr index 31e11e12835..b4312091edb 100644 --- a/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr @@ -14,12 +14,6 @@ LL | fn give_some<'a>() { | -- lifetime `'a` defined here LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-just-for-static.rs:9:15 - | -LL | where T : for<'a> Foo<&'a isize> - | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:30:5 diff --git a/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr index 5e75a4cc8af..1461e7fd2dd 100644 --- a/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr @@ -46,12 +46,6 @@ LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) ... LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-perfect-forwarding.rs:37:8 - | -LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, - | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Bar` is not general enough --> $DIR/hrtb-perfect-forwarding.rs:43:5 diff --git a/src/test/ui/issues/issue-26217.stderr b/src/test/ui/issues/issue-26217.stderr index 73c772205c3..c7601caacdc 100644 --- a/src/test/ui/issues/issue-26217.stderr +++ b/src/test/ui/issues/issue-26217.stderr @@ -5,12 +5,6 @@ LL | fn bar<'a>() { | -- lifetime `'a` defined here LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/issue-26217.rs:1:30 - | -LL | fn foo<T>() where for<'a> T: 'a {} - | ^^ error: aborting due to previous error diff --git a/src/test/ui/mir/issue-101844.rs b/src/test/ui/mir/issue-101844.rs new file mode 100644 index 00000000000..da8a25f5f82 --- /dev/null +++ b/src/test/ui/mir/issue-101844.rs @@ -0,0 +1,73 @@ +// check-pass + +pub trait FirstTrait { + type Item; + type Extra: Extra<(), Error = Self::Item>; +} + +trait SecondTrait { + type Item2; +} + +trait ThirdTrait: SecondTrait { + type Item3; +} + +trait FourthTrait { + type Item4; +} + +impl<First> SecondTrait for First +where + First: FirstTrait, +{ + type Item2 = First::Extra; +} + +impl<Second, T> ThirdTrait for Second +where + Second: SecondTrait<Item2 = T>, +{ + type Item3 = T; +} + +impl<S, Third: ?Sized> FourthTrait for Third +where + Third: ThirdTrait<Item3 = S>, +{ + type Item4 = S; +} + +pub trait Extra<Request> { + type Error; +} + +struct ImplShoulExist<D, Req> { + _gen: (D, Req), +} + +impl<D, Req> ImplShoulExist<D, Req> +where + D: FourthTrait, + D::Item4: Extra<Req>, + <D::Item4 as Extra<Req>>::Error: Into<()>, +{ + fn access_fn(_: D) { + todo!() + } +} + +impl<D, Req> Extra<Req> for ImplShoulExist<D, Req> { + type Error = (); +} + +pub fn broken<MS>(ms: MS) +where + MS: FirstTrait, + MS::Item: Into<()>, +{ + // Error: Apparently Balance::new doesn't exist during MIR validation + let _ = ImplShoulExist::<MS, ()>::access_fn(ms); +} + +fn main() {} diff --git a/src/test/ui/nll/local-outlives-static-via-hrtb.stderr b/src/test/ui/nll/local-outlives-static-via-hrtb.stderr index f5c10f3ddea..61009da49ff 100644 --- a/src/test/ui/nll/local-outlives-static-via-hrtb.stderr +++ b/src/test/ui/nll/local-outlives-static-via-hrtb.stderr @@ -9,12 +9,6 @@ LL | assert_static_via_hrtb(&local); LL | assert_static_via_hrtb_with_assoc_type(&&local); LL | } | - `local` dropped here while still borrowed - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/local-outlives-static-via-hrtb.rs:15:53 - | -LL | fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {} - | ^^^^^^^^^^^^ error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:25:45 @@ -26,12 +20,6 @@ LL | assert_static_via_hrtb_with_assoc_type(&&local); | argument requires that `local` is borrowed for `'static` LL | } | - `local` dropped here while still borrowed - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/local-outlives-static-via-hrtb.rs:19:20 - | -LL | for<'a> &'a T: Reference<AssociatedType = &'a ()>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/type-test-universe.stderr b/src/test/ui/nll/type-test-universe.stderr index 31e17d64b8c..242486c360a 100644 --- a/src/test/ui/nll/type-test-universe.stderr +++ b/src/test/ui/nll/type-test-universe.stderr @@ -11,12 +11,6 @@ LL | fn test2<'a>() { | -- lifetime `'a` defined here LL | outlives_forall::<Value<'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/type-test-universe.rs:6:16 - | -LL | for<'u> T: 'u, - | ^^ error: aborting due to 2 previous errors |
