Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize obligations before matching them against a candidate #109115

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ LL | trait X<'a>
LL | where
LL | for<'b> <Self as X<'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: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
| ++++++++++++++++++++++++++++++++++++

error: aborting due to previous error

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/generic-associated-types/bugs/issue-88460.rs
Original file line number Diff line number Diff line change
@@ -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 {}

Expand Down
21 changes: 0 additions & 21 deletions tests/ui/generic-associated-types/bugs/issue-88460.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// check-fail
// known-bug: #90950
// check-pass

trait Yokeable<'a>: 'static {
type Output: 'a;
}


trait IsCovariant<'a> {}

struct Yoke<Y: for<'a> Yokeable<'a>> {
data: Y,
}


// impl<Y: for<'a> Yokeable<'a>> Yoke<Y> {
// fn project<Y2: for<'a> Yokeable<'a>>(
// &self,
Expand All @@ -22,17 +19,17 @@ struct Yoke<Y: for<'a> Yokeable<'a>> {
// }
// }

fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where
fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>>
where
Y: for<'a> Yokeable<'a>,
for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a>
{
for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a>,
{
// x.project(|data, _| {
// Box::new(data)
// })
unimplemented!()
}


impl<'a> Yokeable<'a> for Box<dyn IsCovariant<'static> + 'static> {
type Output = Box<dyn IsCovariant<'a> + 'a>;
}
Expand All @@ -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<Cow<'static, str>>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> {
upcast(y)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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> {
Expand All @@ -13,10 +12,12 @@ impl<'a, T> Trait<'a> for T {
}

fn weird_bound<X>() -> X
where
for<'a> X: Trait<'a>,
for<'a> <X as Trait<'a>>::Out: Copy
{ todo!() }
where
for<'a> X: Trait<'a>,
for<'a> <X as Trait<'a>>::Out: Copy,
{
todo!()
}

fn main() {
let _: () = weird_bound();
Expand Down

This file was deleted.