From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../assoc-ty-wf-used-to-get-assoc-ty.rs | 27 ---------- .../assoc-ty-wf-used-to-get-assoc-ty.stderr | 15 ------ .../hrlt-implied-trait-bounds-guard.rs | 61 ---------------------- .../hrlt-implied-trait-bounds-guard.stderr | 30 ----------- .../hrlt-implied-trait-bounds-roundtrip.rs | 35 ------------- .../impl-header-unnormalized-types.rs | 28 ---------- .../impl-header-unnormalized-types.stderr | 20 ------- ...pl-implied-bounds-compatibility-unnormalized.rs | 22 -------- ...mplied-bounds-compatibility-unnormalized.stderr | 16 ------ .../impl-implied-bounds-compatibility.rs | 21 -------- .../impl-implied-bounds-compatibility.stderr | 16 ------ src/test/ui/implied-bounds/issue-100690.rs | 45 ---------------- src/test/ui/implied-bounds/issue-100690.stderr | 22 -------- src/test/ui/implied-bounds/issue-101951.rs | 50 ------------------ 14 files changed, 408 deletions(-) delete mode 100644 src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.rs delete mode 100644 src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr delete mode 100644 src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs delete mode 100644 src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr delete mode 100644 src/test/ui/implied-bounds/hrlt-implied-trait-bounds-roundtrip.rs delete mode 100644 src/test/ui/implied-bounds/impl-header-unnormalized-types.rs delete mode 100644 src/test/ui/implied-bounds/impl-header-unnormalized-types.stderr delete mode 100644 src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs delete mode 100644 src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr delete mode 100644 src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs delete mode 100644 src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr delete mode 100644 src/test/ui/implied-bounds/issue-100690.rs delete mode 100644 src/test/ui/implied-bounds/issue-100690.stderr delete mode 100644 src/test/ui/implied-bounds/issue-101951.rs (limited to 'src/test/ui/implied-bounds') diff --git a/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.rs b/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.rs deleted file mode 100644 index 33b746c5e..000000000 --- a/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Test for a less than ideal interaction of implied bounds and normalization. -trait Tr { - type Ty; -} - -impl Tr for T { - type Ty = &'static T; -} - -// `<&'a u8 as Tr>::Ty` should cause an error because `&'a u8: Tr` doesn't hold for -// all possible 'a. However, we consider normalized types for implied bounds. -// -// We normalize this projection to `&'static &'a u8` and add a nested `&'a u8: 'static` -// bound. This bound is then proven using the implied bounds for `&'static &'a u8` which -// we only get by normalizing in the first place. -fn test<'a>(x: &'a u8, _wf: <&'a u8 as Tr>::Ty) -> &'static u8 { x } - -fn main() { - // This works as we have 'static references due to promotion. - let _: &'static u8 = test(&3, &&3); - // This causes an error because the projection requires 'a to be 'static. - // It would be unsound if this compiled. - let x: u8 = 3; - let _: &'static u8 = test(&x, &&3); - //~^ ERROR `x` does not live long enough - -} diff --git a/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr b/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr deleted file mode 100644 index d0249e74f..000000000 --- a/src/test/ui/implied-bounds/assoc-ty-wf-used-to-get-assoc-ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/assoc-ty-wf-used-to-get-assoc-ty.rs:24:31 - | -LL | let _: &'static u8 = test(&x, &&3); - | -----^^------ - | | | - | | borrowed value does not live long enough - | argument requires that `x` is borrowed for `'static` -... -LL | } - | - `x` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs deleted file mode 100644 index 79844dcbd..000000000 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs +++ /dev/null @@ -1,61 +0,0 @@ -// A test exploiting the bug behind #25860 except with -// implied trait bounds which currently don't exist without `-Zchalk`. -use std::marker::PhantomData; -struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) -where - T: Convert<'a, 'b>; - -trait Convert<'a, 'b>: Sized { - fn cast(&'a self) -> &'b Self; -} -impl<'long: 'short, 'short, T> Convert<'long, 'short> for T { - fn cast(&'long self) -> &'short T { - self - } -} - -// This function will compile once we add implied trait bounds. -// -// If we're not careful with our impl, the transformations -// in `bad` would succeed, which is unsound ✨ -// -// FIXME: the error is pretty bad, this should say -// -// `T: Convert<'in_, 'out>` is not implemented -// -// help: needed by `Foo<'in_, 'out, T>` -// -// Please ping @lcnr if your changes end up causing `badboi` to compile. -fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T { - //~^ ERROR lifetime mismatch - sadness.cast() -} - -fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) { - //~^ ERROR lifetime mismatch - let _: &'out T = sadness.cast(); -} - -fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) { - //~^ ERROR lifetime mismatch - let _: &'out T = sadness.cast(); -} - -fn bad<'short, T>(value: &'short T) -> &'static T { - let x: for<'in_, 'out> fn(Foo<'in_, 'out, T>, &'in_ T) -> &'out T = badboi; - let x: for<'out> fn(Foo<'short, 'out, T>, &'short T) -> &'out T = x; - let x: for<'out> fn(Foo<'static, 'out, T>, &'short T) -> &'out T = x; - let x: fn(Foo<'static, 'static, T>, &'short T) -> &'static T = x; - x(Foo(PhantomData), value) -} - -// Use `bad` to cause a segfault. -fn main() { - let mut outer: Option<&'static u32> = Some(&3); - let static_ref: &'static &'static u32 = match outer { - Some(ref reference) => bad(reference), - None => unreachable!(), - }; - outer = None; - println!("{}", static_ref); -} diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr deleted file mode 100644 index 0c00bbc38..000000000 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-guard.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/hrlt-implied-trait-bounds-guard.rs:29:29 - | -LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T { - | ^^^^^^^^^^^^^^^^^^ ------- - | | - | this parameter and the return type are declared with different lifetimes... - | ...but data from `x` is returned here - -error[E0623]: lifetime mismatch - --> $DIR/hrlt-implied-trait-bounds-guard.rs:34:30 - | -LL | fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) { - | ^^^^^^^^^^^^^^^^^^ - | | - | this type is declared with multiple lifetimes... - | ...but data with one lifetime flows into the other here - -error[E0623]: lifetime mismatch - --> $DIR/hrlt-implied-trait-bounds-guard.rs:39:30 - | -LL | fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) { - | ^^^^^^^^^^^^^^^^^-------^^-------^^ - | | | - | | these two types are declared with different lifetimes... - | ...but data from `a` flows into `a` here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-roundtrip.rs b/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-roundtrip.rs deleted file mode 100644 index 69847d6a8..000000000 --- a/src/test/ui/implied-bounds/hrlt-implied-trait-bounds-roundtrip.rs +++ /dev/null @@ -1,35 +0,0 @@ -// check-pass -struct Foo<'a>(&'a ()) -where - (): Trait<'a>; - -trait Trait<'a> { - fn id(value: &'a T) -> &'static T; -} - -impl Trait<'static> for () { - fn id(value: &'static T) -> &'static T { - value - } -} - -fn could_use_implied_bounds<'a, T>(_: Foo<'a>, x: &'a T) -> &'static T -where - (): Trait<'a>, // This could be an implied bound -{ - <()>::id(x) -} - -fn main() { - let bar: for<'a, 'b> fn(Foo<'a>, &'b ()) = |_, _| {}; - - // If `could_use_implied_bounds` were to use implied bounds, - // keeping 'a late-bound, then we could assign that function - // to this variable. - let bar: for<'a> fn(Foo<'a>, &'a ()) = bar; - - // In this case, the subtyping relation here would be unsound, - // allowing us to transmute lifetimes. This currently compiles - // because we incorrectly deal with implied bounds inside of binders. - let _bar: for<'a, 'b> fn(Foo<'a>, &'b ()) = bar; -} diff --git a/src/test/ui/implied-bounds/impl-header-unnormalized-types.rs b/src/test/ui/implied-bounds/impl-header-unnormalized-types.rs deleted file mode 100644 index d84539f8a..000000000 --- a/src/test/ui/implied-bounds/impl-header-unnormalized-types.rs +++ /dev/null @@ -1,28 +0,0 @@ -struct Foo(T); - -trait GoodBye { - type Forget; -} -impl GoodBye for T { - type Forget = (); -} - -trait NeedsWf<'a, 'b> { - type Assoc; -} - -impl<'a, 'b> NeedsWf<'a, 'b> for Foo<<&'a &'b () as GoodBye>::Forget> { - type Assoc = &'a &'b (); - //~^ ERROR in type `&'a &'b ()`, reference has a longer lifetime than the data it references -} - -fn needs_wf<'a, 'b, T: NeedsWf<'a, 'b>>() {} - -fn foo<'a: 'a, 'b: 'b>(_: &'b String) { - needs_wf::<'a, 'b, Foo<()>>(); -} - -fn main() { - let x = String::from("hello"); - foo::<'static, '_>(&x); -} diff --git a/src/test/ui/implied-bounds/impl-header-unnormalized-types.stderr b/src/test/ui/implied-bounds/impl-header-unnormalized-types.stderr deleted file mode 100644 index 88abd5f54..000000000 --- a/src/test/ui/implied-bounds/impl-header-unnormalized-types.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references - --> $DIR/impl-header-unnormalized-types.rs:15:18 - | -LL | type Assoc = &'a &'b (); - | ^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/impl-header-unnormalized-types.rs:14:6 - | -LL | impl<'a, 'b> NeedsWf<'a, 'b> for Foo<<&'a &'b () as GoodBye>::Forget> { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/impl-header-unnormalized-types.rs:14:10 - | -LL | impl<'a, 'b> NeedsWf<'a, 'b> for Foo<<&'a &'b () as GoodBye>::Forget> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs deleted file mode 100644 index 6ccbb5bb2..000000000 --- a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![deny(implied_bounds_entailment)] - -trait Project { - type Ty; -} -impl Project for &'_ &'_ () { - type Ty = (); -} -trait Trait { - fn get<'s>(s: &'s str, _: ()) -> &'static str; -} -impl Trait for () { - fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { - //~^ ERROR impl method assumes more implied bounds than the corresponding trait method - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - s - } -} -fn main() { - let val = <() as Trait>::get(&String::from("blah blah blah"), ()); - println!("{}", val); -} diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr deleted file mode 100644 index 0ac31c642..000000000 --- a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:13:5 - | -LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:1:9 - | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs deleted file mode 100644 index d097bc16a..000000000 --- a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![deny(implied_bounds_entailment)] - -use std::cell::RefCell; - -pub struct MessageListeners<'a> { - listeners: RefCell>>, -} - -pub trait MessageListenersInterface { - fn listeners<'c>(&'c self) -> &'c MessageListeners<'c>; -} - -impl<'a> MessageListenersInterface for MessageListeners<'a> { - fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { - //~^ ERROR impl method assumes more implied bounds than the corresponding trait method - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - self - } -} - -fn main() {} diff --git a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr b/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr deleted file mode 100644 index 0dfa8167a..000000000 --- a/src/test/ui/implied-bounds/impl-implied-bounds-compatibility.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility.rs:14:5 - | -LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility.rs:1:9 - | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/implied-bounds/issue-100690.rs b/src/test/ui/implied-bounds/issue-100690.rs deleted file mode 100644 index 5599cd410..000000000 --- a/src/test/ui/implied-bounds/issue-100690.rs +++ /dev/null @@ -1,45 +0,0 @@ -// This code (probably) _should_ compile, but it currently does not because we -// are not smart enough about implied bounds. - -use std::io; - -fn real_dispatch(f: F) -> Result<(), io::Error> -//~^ NOTE required by a bound in this -where - F: FnOnce(&mut UIView) -> Result<(), io::Error> + Send + 'static, - //~^ NOTE required by this bound in `real_dispatch` - //~| NOTE required by a bound in `real_dispatch` -{ - todo!() -} - -#[derive(Debug)] -struct UIView<'a, T: 'a> { - _phantom: std::marker::PhantomData<&'a mut T>, -} - -trait Handle<'a, T: 'a, V, R> { - fn dispatch(&self, f: F) -> Result<(), io::Error> - where - F: FnOnce(&mut V) -> R + Send + 'static; -} - -#[derive(Debug, Clone)] -struct TUIHandle { - _phantom: std::marker::PhantomData, -} - -impl<'a, T: 'a> Handle<'a, T, UIView<'a, T>, Result<(), io::Error>> for TUIHandle { - fn dispatch(&self, f: F) -> Result<(), io::Error> - where - F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static, - { - real_dispatch(f) - //~^ ERROR expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` - //~| NOTE expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` - //~| NOTE expected a closure with arguments - //~| NOTE required by a bound introduced by this call - } -} - -fn main() {} diff --git a/src/test/ui/implied-bounds/issue-100690.stderr b/src/test/ui/implied-bounds/issue-100690.stderr deleted file mode 100644 index 3f6af70d8..000000000 --- a/src/test/ui/implied-bounds/issue-100690.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` - --> $DIR/issue-100690.rs:37:23 - | -LL | real_dispatch(f) - | ------------- ^ expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` - | | - | required by a bound introduced by this call - | - = note: expected a closure with arguments `(&mut UIView<'a, T>,)` - found a closure with arguments `(&mut UIView<'_, T>,)` -note: required by a bound in `real_dispatch` - --> $DIR/issue-100690.rs:9:8 - | -LL | fn real_dispatch(f: F) -> Result<(), io::Error> - | ------------- required by a bound in this -... -LL | F: FnOnce(&mut UIView) -> Result<(), io::Error> + Send + 'static, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `real_dispatch` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/implied-bounds/issue-101951.rs b/src/test/ui/implied-bounds/issue-101951.rs deleted file mode 100644 index 108fef8a1..000000000 --- a/src/test/ui/implied-bounds/issue-101951.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Taken directly from that issue. -// -// This test detected that we didn't correctly resolve -// inference variables when computing implied bounds. -// -// check-pass -pub trait BuilderFn<'a> { - type Output; -} - -impl<'a, F, Out> BuilderFn<'a> for F -where - F: FnOnce(&'a mut ()) -> Out, -{ - type Output = Out; -} - -pub trait ConstructionFirm { - type Builder: for<'a> BuilderFn<'a>; -} - -pub trait Campus -where - T: ConstructionFirm, -{ - fn add_building( - &mut self, - building: &mut <::Builder as BuilderFn<'_>>::Output, - ); -} - -struct ArchitectsInc {} - -impl ConstructionFirm for ArchitectsInc { - type Builder = fn(&mut ()) -> PrettyCondo<'_>; -} - -struct PrettyCondo<'a> { - _marker: &'a mut (), -} - -struct CondoEstate {} - -impl Campus for CondoEstate { - fn add_building(&mut self, _building: &mut PrettyCondo<'_>) { - todo!() - } -} - -fn main() {} -- cgit v1.2.3