-
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
generalize: handle occurs check failure in aliases #117088
Conversation
/// incorrect errors when relating `?0` with `<?0 as Trait>::Assoc`. | ||
in_alias: bool, |
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.
exists because of <() as Trait<<?0 as Trait<()>>::Assoc>>::Assoc == ?0
have to update comment. With Projection
goals the behavior is still broken, but I want to change it to emit alias-relate
in the new solver in a different PR, at which point this should work.
if !infer_replacement_is_complete { | ||
warn!("incomplete generalization of an alias type: {t:?}"); | ||
} |
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.
handling this correctly is HARD. We'd have to push the infer var to the place which introduced the binder and then have a nested Equate
goal or sth.
idk how to handle this during coherence, ideally just succeed with equating and emit an Ambiguity
predicate?
|
||
let ty = value.may_be_infer(); | ||
if ty.is_ty_var() { | ||
span_bug!(self.delegate.span(), "occurs check failure in MIR typeck"); |
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.
potentially reachable with user type annotations? Probably not as the actual type inferred by HIR typeck also needs to contain an inference variable? 🤔
96204ee
to
6fdb8cb
Compare
This comment has been minimized.
This comment has been minimized.
6fdb8cb
to
768015f
Compare
This comment has been minimized.
This comment has been minimized.
5840c9d
to
f817a32
Compare
This comment has been minimized.
This comment has been minimized.
f817a32
to
ea6e393
Compare
This comment has been minimized.
This comment has been minimized.
this is still in draft, so marking as author so i can clean up my queue :> @rustbot author |
ea6e393
to
6913673
Compare
This PR mostly fixes generalization for aliases, fixing #105787. It is therefore a (theoretical) breaking change. Equating It is non-trivial whether we can get trait solver overflow (in the old solver) for rigid projections, e.g. trait Unnormalizable<T> {
type Assoc;
}
struct Inv<T>(*mut T);
fn unconstrained<T>() -> T {
todo!()
}
fn create<T, U: Unnormalizable<T>>(
x: &U,
) -> (Inv<T>, Inv<<U as Unnormalizable<T>>::Assoc>) {
todo!()
}
fn foo<T: Unnormalizable<U> + Unnormalizable<V>, U, V>() {
let q = unconstrained();
let (mut x, y) = create::<_, _>(&q);
x = y; // equate `?x` with `<T as Unnormalizable<?x>>::Assoc`
drop::<T>(q);
} However, projection goals only constrain the term to the projection itself if we were able to select a I believe that you can get solver overflow with specialization and default associated items, but idc 😁 This only fixes problem case 2 of rust-lang/trait-system-refactor-initiative#8. However, this is by far the easiest way to get an incorrect occurs check failure (and the only one I bothered to write a coherence unsoundness test for). This only impacts the old solver for projections containing bound variables (as we otherwise eagerly normalize and replace the projection with an inference variable). I consider this to 1) be a step in the right direction and 2) necessary for future work on the new trait solver. |
should have done perf + crater 😅 @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
r=me after rebase |
6913673
to
cf8a2bd
Compare
@bors r+ rollup=never |
@bors r+ approver is wrong |
💡 This pull request was already approved, no need to approve it again.
|
…rors generalize: handle occurs check failure in aliases mostly fixes rust-lang#105787, except for the `for<'a> fn(<<?x as OtherTrait>::Assoc as Trait<'a>>::Assoc) eq ?x` case in rust-lang/trait-system-refactor-initiative#8. r? `@compiler-errors`
This is going to fail, CC #118597. Actually, @pietroalbini might be a better person to tag, sorry for the mix-up. |
@bors retry kicking the job to avoid failure |
The job Click to see the possible cause of the failure (guessed by this bot)
|
☀️ Test successful - checks-actions |
Finished benchmarking commit (25dca40): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 672.674s -> 673.516s (0.13%) |
…3, r=BoxyUwU split `NormalizesTo` out of `Projection` 3 third attempt at rust-lang#112658. Rebasing rust-lang#116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since rust-lang#117088. see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg fixes rust-lang/trait-system-refactor-initiative#1 r? `@compiler-errors`
mostly fixes #105787, except for the
for<'a> fn(<<?x as OtherTrait>::Assoc as Trait<'a>>::Assoc) eq ?x
case in rust-lang/trait-system-refactor-initiative#8.r? @compiler-errors