Add rigid alias marker#156742
Conversation
|
Unfinished. Let's have a look at the perf impact nonetheless. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[Experiment] Add rigid alias marker
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 73eccb5 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[Experiment] Add rigid alias marker
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (42e2939): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.6%, secondary -1.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.5%, secondary 17.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 510.83s -> 514.725s (0.76%) |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in cc @BoxyUwU Some changes occurred in match checking cc @Nadrieril changes to the core type system cc @lcnr Some changes occurred to constck cc @fee1-dead This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410 Some changes occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in cc @BoxyUwU Some changes occurred in need_type_info.rs cc @lcnr |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
There's an assumptions-on-binders ICE I don't know how to fix yet. That shouldn't affect perf much. Let's see. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| }; | ||
|
|
||
| if let Ok(_) = relation.relate(alias.to_ty(infcx.cx()), alias2) { | ||
| if let Ok(_) = relation.relate(alias.to_ty(infcx.cx(), IsRigid::No), alias2) { |
There was a problem hiding this comment.
This relating causes ICE. Unsure why it didn't surface before. And I'm having trouble grasping the rigidness invariants here so don't have a clue about where to insert normalization or set_aliases_to_rigid.
|
The job Click to see the possible cause of the failure (guessed by this bot)For more information how to resolve CI failures of this job, visit this link. |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d885f34): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.4%, secondary 1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.4%, secondary -4.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 523.739s -> 531.127s (1.41%) |
| } | ||
|
|
||
| ty::Alias(data) => match self.structurally_relate_aliases { | ||
| // We shouldn't perform lazy norm for rigid aliases. |
There was a problem hiding this comment.
that sentence is slightly confusing, both times u use it.
I think "performing lazy norm" doesn't immediately make sense to me.
Would probably do sth like this?
| // We shouldn't perform lazy norm for rigid aliases. | |
| // We only need to be careful with potentially normalizeable | |
| // aliases here. See `generalize_alias_term` for more information. |
and then change the comment of generalize_alias_term to talk about "potentially normalizeable aliases" instead of just alias :>
| // `assemble_candidates_after_normalizing_self_ty`. | ||
| ty::Alias(_) | ty::Placeholder(..) | ty::Error(_) => (), | ||
| ty::Alias(ty::IsRigid::Yes, _) | ty::Placeholder(..) | ty::Error(_) => (), | ||
| // Need to support aliases not marked as rigid for the old solver. |
There was a problem hiding this comment.
| // Need to support aliases not marked as rigid for the old solver. | |
| // FIXME(-Znext-solver=no): Need to support aliases not marked as rigid for the old solver. |
| // FIXME(rigid_aliases_marker): ideally we set aliases to non_rigid right after | ||
| // the typing mode is set to `PostAnalysis`. | ||
| // But modifying local decls in MIR body is inconvenient. And we can't fold | ||
| // `PlaceRef` in `checked_places`. |
| } | ||
| fn fold_ty(&mut self, ty: I::Ty) -> I::Ty { | ||
| if let ty::Alias(alias_ty) = ty.kind() { | ||
| if let ty::Alias(_is_rigid, alias_ty) = ty.kind() { |
There was a problem hiding this comment.
hmm, does an assert that is_rigid, ty::IsRigid::No ever trigger? I think we should only ever have non-rigid opaques here
| // FIXME: Strictly speaking this may be incomplete if the normalized-to | ||
| // type contains an ambiguous alias referencing bound regions. We should | ||
| // consider changing this to only use "shallow structural equality". | ||
| self.eq_structurally_relating_aliases(goal.param_env, term, unconstrained_term)?; |
There was a problem hiding this comment.
we can rip out eq_structurally_relating_aliases entirely now i think as the relevant aliases are all marked as Rigid
| let actual = | ||
| self.normalize(GoalSource::Misc, goal.param_env, actual)?; |
There was a problem hiding this comment.
oh, we shouldn't normalize while there are still erased regions 😅, i'd keep the existing code here
| .insert_placeholder_assumptions(self.infcx.universe(), Some(Assumptions::empty())); | ||
|
|
||
| let (normalized, ambig_goal) = (self.normalize)(alias_term)?; | ||
| let (normalized, normalization_was_ambiguous) = (self.normalize)(alias_term)?; |
There was a problem hiding this comment.
oh, what is happening here? why are we creating a new universe here?
There was a problem hiding this comment.
ah, this check is wrong 😅 we have to use the universe from before we create the new universes for placeholders
rn the check we do here doesn't really detect anything afaict 😅
There was a problem hiding this comment.
We need to detect that the normalized term doesn't contain new infer vars. We do that by increasing the universe index at the start so that newly created infer vars will be in a unnameable universe.
There was a problem hiding this comment.
it's more limiting, it should not reference any infer vars from a universe of any of the placeholders we created as part of normalization.
so somewhat more strict than what is currently implemented
| let infcx = self.infcx; | ||
| *self.var_map.entry(ty).or_insert_with(|| infcx.next_ty_var(DUMMY_SP)) | ||
| } | ||
| &ty::Alias(is_rigid, alias) |
There was a problem hiding this comment.
| &ty::Alias(is_rigid, alias) | |
| // FIXME(rigid_aliases_marker): This should automatically | |
| // handled by type folders instead of needing to do it | |
| // manually here | |
| &ty::Alias(is_rigid, alias) |
| obligation.param_env, | ||
| ty::Unnormalized::new_wip(obligation.predicate), | ||
| ); | ||
| self.register_predicate_obligations(infcx, ocx.into_pending_obligations()); |
There was a problem hiding this comment.
| Const::new_unevaluated(cx, ty::IsRigid::Yes, a), | ||
| Const::new_unevaluated(cx, ty::IsRigid::Yes, b), |
There was a problem hiding this comment.
that can actually introduce IsRigid::Yes in the old solver, which is not ideal xx
doesn't rly matter, but could we add a IsRigid::yes_if_next_solver(relation.infcx) or sth for this
|
|
||
| if ty != unnormalized_ty { | ||
| if normalized_ty != unnormalized_ty { | ||
| // FIXME: our rigidness folding is redundant in this case. |
There was a problem hiding this comment.
we can instead only do this conversion if we actually change the typing_env. If it is already PostAnalysis when entering, we're all good :>
View all comments
This PR adds a rigidness marker to
AliasTy/UnevaluatedConst.It's used to skip renormalization of rigid aliases.
The difficulty is that rigid aliases are only valid in their own
TypingEnvso we need to treat them as non-rigid when entering anotherTypingEnv.This PR also adds a flag
-Zrenormalize-rigid-aliasesto test whether we properly handle typing mode change.Currently only
tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.rsfails this check.r? lcnr