diff options
| author | nils <48135649+Nilstrieb@users.noreply.github.com> | 2023-03-28 12:51:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-28 12:51:14 +0200 |
| commit | 60ce19d848682b10543934229750cf30ef7af8a6 (patch) | |
| tree | 3673b02246250062d04b27623f645df4869dab92 /tests | |
| parent | ef5ef53a6f5cc6d40a45e8041ea9e720b948108b (diff) | |
| parent | 2a3177a8bcc4c5a5285dc2908a0f1ce98e9a6377 (diff) | |
| download | rust-60ce19d848682b10543934229750cf30ef7af8a6.tar.gz rust-60ce19d848682b10543934229750cf30ef7af8a6.zip | |
Rollup merge of #109629 - aliemjay:remove-givens, r=lcnr
remove obsolete `givens` from regionck Revives #107376. The only change is the last commit (https://github.com/rust-lang/rust/pull/109629/commits/2a3177a8bcc4c5a5285dc2908a0f1ce98e9a6377) which should fix the regression. Fixes https://github.com/rust-lang/rust/issues/106567 r? `@lcnr`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/implied-bounds/ice-unbound-region-vars.rs | 24 | ||||
| -rw-r--r-- | tests/ui/implied-bounds/normalization.rs | 58 |
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/ui/implied-bounds/ice-unbound-region-vars.rs b/tests/ui/implied-bounds/ice-unbound-region-vars.rs new file mode 100644 index 00000000000..9e1e3feaeec --- /dev/null +++ b/tests/ui/implied-bounds/ice-unbound-region-vars.rs @@ -0,0 +1,24 @@ +// Because of #109628, we can have unbounded region vars in implied bounds. +// Make sure we don't ICE in this case! +// +// check-pass + +pub trait MapAccess { + type Error; + fn next_key_seed(&mut self) -> Option<Self::Error>; +} + +struct Access<'a> { + _marker: std::marker::PhantomData<&'a ()>, +} + +// implied_bounds(Option<Self::Error>) = ['?1: 'a, ] +// where '?1 is a fresh region var. +impl<'a, 'b: 'a> MapAccess for Access<'a> { + type Error = (); + fn next_key_seed(&mut self) -> Option<Self::Error> { + unimplemented!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/normalization.rs b/tests/ui/implied-bounds/normalization.rs new file mode 100644 index 00000000000..f776fc98a9e --- /dev/null +++ b/tests/ui/implied-bounds/normalization.rs @@ -0,0 +1,58 @@ +// Test that we get implied bounds from complex projections after normalization. + +// check-pass + +// implementations wil ensure that +// WF(<T as Combine<'a>>::Ty) implies T: 'a +trait Combine<'a> { + type Ty; +} + +impl<'a, T: 'a> Combine<'a> for Box<T> { + type Ty = &'a T; +} + +// ======= Wrappers ====== + +// normalizes to a projection +struct WrapA<T>(T); +impl<'a, T> Combine<'a> for WrapA<T> +where + T: Combine<'a>, +{ + type Ty = T::Ty; +} + +// <WrapB<T> as Combine<'a>>::Ty normalizes to a type variable ?X +// with constraint `<T as Combine<'a>>::Ty == ?X` +struct WrapB<T>(T); +impl<'a, X, T> Combine<'a> for WrapB<T> +where + T: Combine<'a, Ty = X>, +{ + type Ty = X; +} + +// <WrapC<T> as Combine<'a>>::Ty normalizes to `&'a &'?x ()` +// with constraint `<T as Combine<'a>>::Ty == &'a &'?x ()` +struct WrapC<T>(T); +impl<'a, 'x: 'a, T> Combine<'a> for WrapC<T> +where + T: Combine<'a, Ty = &'a &'x ()>, +{ + type Ty = &'a &'x (); +} + +//==== Test implied bounds ====== + +fn test_wrap<'a, 'b, 'c1, 'c2, A, B>( + _: <WrapA<Box<A>> as Combine<'a>>::Ty, // normalized: &'a A + _: <WrapB<Box<B>> as Combine<'b>>::Ty, // normalized: &'b B + _: <WrapC<Box<&'c1 ()>> as Combine<'c2>>::Ty, // normalized: &'c2 &'c1 () +) { + None::<&'a A>; + None::<&'b B>; + None::<&'c2 &'c1 ()>; +} + +fn main() {} |
