-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
WIP: eliminate DefineOpaqueTypes
by using Yes
across the compiler
#127034
Changes from all commits
dc028f3
2f4fbf8
2622e1a
2379e0e
2090303
513b139
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1688,7 +1688,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | |||||||||||||
}); | ||||||||||||||
self.infcx | ||||||||||||||
.at(&obligation.cause, obligation.param_env) | ||||||||||||||
.eq(DefineOpaqueTypes::No, placeholder_trait_ref, trait_bound) | ||||||||||||||
.eq(DefineOpaqueTypes::Yes, placeholder_trait_ref, trait_bound) | ||||||||||||||
.map(|InferOk { obligations: _, value: () }| { | ||||||||||||||
// This method is called within a probe, so we can't have | ||||||||||||||
// inference variables and placeholders escape. | ||||||||||||||
|
@@ -1752,7 +1752,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | |||||||||||||
let is_match = self | ||||||||||||||
.infcx | ||||||||||||||
.at(&obligation.cause, obligation.param_env) | ||||||||||||||
.eq(DefineOpaqueTypes::No, obligation.predicate, infer_projection) | ||||||||||||||
.eq(DefineOpaqueTypes::Yes, obligation.predicate, infer_projection) | ||||||||||||||
.is_ok_and(|InferOk { obligations, value: () }| { | ||||||||||||||
self.evaluate_predicates_recursively( | ||||||||||||||
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()), | ||||||||||||||
|
@@ -2532,7 +2532,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { | |||||||||||||
let InferOk { obligations, .. } = self | ||||||||||||||
.infcx | ||||||||||||||
.at(&cause, obligation.param_env) | ||||||||||||||
.eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref) | ||||||||||||||
.eq(DefineOpaqueTypes::Yes, placeholder_obligation_trait_ref, impl_trait_ref) | ||||||||||||||
.map_err(|e| { | ||||||||||||||
debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx())) | ||||||||||||||
})?; | ||||||||||||||
|
@@ -2675,7 +2675,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { | |||||||||||||
); | ||||||||||||||
self.infcx | ||||||||||||||
.at(&obligation.cause, obligation.param_env) | ||||||||||||||
.eq(DefineOpaqueTypes::No, predicate.trait_ref, trait_ref) | ||||||||||||||
.eq(DefineOpaqueTypes::Yes, predicate.trait_ref, trait_ref) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used in selection (behind a probe) and confirmation. Without the previous commit skipping rust/library/core/src/iter/adapters/filter.rs Lines 73 to 78 in 127fa22
to immediately match the opaque type against the APIT with the same bounds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've looked into it a bit. Do you know of any fundamental issues with moving the old solver to a similar normalization scheme for opaques as the new solver uses? Or is that just a bad version of lazy norm? |
||||||||||||||
.map(|InferOk { obligations, .. }| obligations) | ||||||||||||||
.map_err(|_| ()) | ||||||||||||||
} | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(type_alias_impl_trait)] | ||
trait Trait<'a> { | ||
type Out<U>; | ||
} | ||
|
||
impl<'a, T> Trait<'a> for T { | ||
type Out<U> = T; | ||
} | ||
|
||
type Foo = impl Sized; | ||
|
||
fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X | ||
where | ||
for<'a> X: Trait<'a>, | ||
for<'a> <X as Trait<'a>>::Out<()>: Copy, | ||
{ | ||
let x = *x; //~ ERROR: cannot move out of `*x` | ||
//~^ ERROR: cannot move a value of type `<X as Trait<'_>>::Out<Foo>` | ||
todo!(); | ||
} | ||
|
||
fn main() { | ||
let _: () = weird_bound(&()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0161]: cannot move a value of type `<X as Trait<'_>>::Out<Foo>` | ||
--> $DIR/bind-hidden-type-in-projection-matching.rs:17:9 | ||
| | ||
LL | let x = *x; | ||
| ^ the size of `<X as Trait<'_>>::Out<Foo>` cannot be statically determined | ||
|
||
error[E0507]: cannot move out of `*x` which is behind a shared reference | ||
--> $DIR/bind-hidden-type-in-projection-matching.rs:17:13 | ||
| | ||
LL | let x = *x; | ||
| ^^ move occurs because `*x` has type `<X as Trait<'_>>::Out<Foo>`, which does not implement the `Copy` trait | ||
| | ||
help: consider removing the dereference here | ||
| | ||
LL - let x = *x; | ||
LL + let x = x; | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0161, E0507. | ||
For more information about an error, try `rustc --explain E0161`. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss these in #127035