diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 38cdaddc1e707..9a0dbbd9abae0 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2512,7 +2512,20 @@ impl<'tcx> SelectionContext<'_, 'tcx> { debug!(?impl_trait_ref); - let Normalized { value: impl_trait_ref, obligations: mut nested_obligations } = + let Normalized { + value: placeholder_obligation_trait_ref, + obligations: mut nested_obligations, + } = ensure_sufficient_stack(|| { + project::normalize_with_depth( + self, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth + 1, + placeholder_obligation_trait_ref, + ) + }); + + let Normalized { value: impl_trait_ref, obligations: more_nested_obligations } = ensure_sufficient_stack(|| { project::normalize_with_depth( self, @@ -2522,6 +2535,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { impl_trait_ref, ) }); + nested_obligations.extend(more_nested_obligations); debug!(?impl_trait_ref, ?placeholder_obligation_trait_ref); diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.stderr b/tests/ui/associated-types/hr-associated-type-bound-object.stderr index a0a6f76a58371..915677f0697eb 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-object.stderr @@ -12,6 +12,10 @@ LL | trait X<'a> LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` +help: consider further restricting the associated type + | +LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { + | ++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/bugs/issue-88460.rs b/tests/ui/generic-associated-types/bugs/issue-88460.rs index 224e696ad2c9c..d0470bca021b4 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88460.rs +++ b/tests/ui/generic-associated-types/bugs/issue-88460.rs @@ -1,7 +1,6 @@ -// check-fail -// known-bug: #88460 +// check-pass -// This should pass, but has a missed normalization due to HRTB. +// Used to fail due to a missed normalization due to HRTB. pub trait Marker {} diff --git a/tests/ui/generic-associated-types/bugs/issue-88460.stderr b/tests/ui/generic-associated-types/bugs/issue-88460.stderr deleted file mode 100644 index a2047f103d488..0000000000000 --- a/tests/ui/generic-associated-types/bugs/issue-88460.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied - --> $DIR/issue-88460.rs:28:10 - | -LL | test(Foo); - | ---- ^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>` - | | - | required by a bound introduced by this call - | - = help: the trait `Marker` is implemented for `()` -note: required by a bound in `test` - --> $DIR/issue-88460.rs:15:27 - | -LL | fn test(value: T) - | ---- required by a bound in this function -... -LL | for<'a> T::Assoc<'a>: Marker, - | ^^^^^^ required by this bound in `test` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs index ab9d9a7ce6f08..a5b07d5706c0a 100644 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs +++ b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs @@ -1,18 +1,15 @@ -// check-fail -// known-bug: #90950 +// check-pass trait Yokeable<'a>: 'static { type Output: 'a; } - trait IsCovariant<'a> {} struct Yoke Yokeable<'a>> { data: Y, } - // impl Yokeable<'a>> Yoke { // fn project Yokeable<'a>>( // &self, @@ -22,17 +19,17 @@ struct Yoke Yokeable<'a>> { // } // } -fn upcast(x: Yoke) -> Yoke + 'static>> where +fn upcast(x: Yoke) -> Yoke + 'static>> +where Y: for<'a> Yokeable<'a>, - for<'a> >::Output: IsCovariant<'a> - { + for<'a> >::Output: IsCovariant<'a>, +{ // x.project(|data, _| { // Box::new(data) // }) unimplemented!() } - impl<'a> Yokeable<'a> for Box + 'static> { type Output = Box + 'a>; } @@ -44,8 +41,6 @@ impl<'a, T: ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T> { } impl<'a, T: ToOwned + ?Sized> IsCovariant<'a> for Cow<'a, T> {} - - fn upcast_yoke(y: Yoke>) -> Yoke + 'static>> { upcast(y) } diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr deleted file mode 100644 index 5be33bccdc317..0000000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `for<'a> <_ as Yokeable<'a>>::Output: IsCovariant<'a>` is not satisfied - --> $DIR/issue-90950.rs:50:12 - | -LL | upcast(y) - | ------ ^ the trait `for<'a> IsCovariant<'a>` is not implemented for `<_ as Yokeable<'a>>::Output` - | | - | required by a bound introduced by this call - | - = help: the trait `IsCovariant<'a>` is implemented for `std::borrow::Cow<'a, T>` -note: required by a bound in `upcast` - --> $DIR/issue-90950.rs:27:42 - | -LL | fn upcast(x: Yoke) -> Yoke + 'static>> where - | ------ required by a bound in this function -LL | Y: for<'a> Yokeable<'a>, -LL | for<'a> >::Output: IsCovariant<'a> - | ^^^^^^^^^^^^^^^ required by this bound in `upcast` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs index 7693b11824762..554d1d8c2d39d 100644 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs +++ b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs @@ -1,7 +1,6 @@ -// check-fail -// known-bug: #89196 +// check-pass -// Should pass, but we normalize and check bounds before we resolve the generics +// We normalize and check bounds before we resolve the generics // of the function (which we know because of the return type). trait Trait<'a> { @@ -13,10 +12,12 @@ impl<'a, T> Trait<'a> for T { } fn weird_bound() -> X - where - for<'a> X: Trait<'a>, - for<'a> >::Out: Copy -{ todo!() } +where + for<'a> X: Trait<'a>, + for<'a> >::Out: Copy, +{ + todo!() +} fn main() { let _: () = weird_bound(); diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr deleted file mode 100644 index 73388a72574e2..0000000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `for<'a> <_ as Trait<'a>>::Out: Copy` is not satisfied - --> $DIR/norm-before-method-resolution.rs:22:17 - | -LL | let _: () = weird_bound(); - | ^^^^^^^^^^^ the trait `for<'a> Copy` is not implemented for `<_ as Trait<'a>>::Out` - | -note: required by a bound in `weird_bound` - --> $DIR/norm-before-method-resolution.rs:18:40 - | -LL | fn weird_bound() -> X - | ----------- required by a bound in this function -... -LL | for<'a> >::Out: Copy - | ^^^^ required by this bound in `weird_bound` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`.