Conversation
|
@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.
Introduce `Unnormalized` wrapper
This comment has been minimized.
This comment has been minimized.
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
309b0de to
a616210
Compare
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.
Introduce `Unnormalized` wrapper
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (10d0ef4): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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. @bors rollup=never Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary -2.4%, secondary -6.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 492.281s -> 489.321s (-0.60%) |
3b64c2b to
5407a88
Compare
|
r? @lcnr |
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in cc @BoxyUwU Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor Some changes occurred in need_type_info.rs cc @lcnr Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_sanitizers cc @rcvalle HIR ty lowering was modified cc @fmease Some changes occurred in match checking cc @Nadrieril Some changes occurred to constck cc @fee1-dead Some changes occurred in exhaustiveness checking cc @Nadrieril changes to the core type system cc @lcnr Some changes occurred in src/tools/clippy cc @rust-lang/clippy The Miri subtree was changed cc @rust-lang/miri |
| Unnormalized { value } | ||
| } | ||
|
|
||
| pub fn skip_normalization(self) -> T { |
There was a problem hiding this comment.
Please also add a doc comment to this function giving the rest of us compiler folks some hint of what this is all about when we encounter it in the source. :)
| pub fn instantiate_own_identity( | ||
| self, | ||
| ) -> impl Iterator<Item = (Clause<'tcx>, Span)> + DoubleEndedIterator + ExactSizeIterator { | ||
| ) -> impl Iterator<Item = Unnormalized<(Clause<'tcx>, Span)>> + DoubleEndedIterator + ExactSizeIterator |
There was a problem hiding this comment.
`(Unnormalized<Clause<'tcx>>, Span)
| args: GenericArgsRef<'tcx>, | ||
| ) -> impl Iterator<Item = (ty::PolyTraitRef<'tcx>, Span)> + DoubleEndedIterator + ExactSizeIterator | ||
| { | ||
| ) -> impl Iterator<Item = Unnormalized<(ty::PolyTraitRef<'tcx>, Span)>> |
There was a problem hiding this comment.
same for all the other ones, no need to wrap the span with Unnormalized. Only need to do so for things which contain types
| pub fn instantiate_identity( | ||
| self, | ||
| tcx: TyCtxt<'tcx>, | ||
| ) -> Unnormalized<InstantiatedPredicates<'tcx>> { |
There was a problem hiding this comment.
instead change InstantiatedPredicates to contain Unnormalized clauses
| pub struct IterIdentityCopied<Iter: IntoIterator> { | ||
| pub struct IterIdentityCopied<I: Interner, Iter: IntoIterator> { | ||
| it: Iter::IntoIter, | ||
| _tcx: PhantomData<fn() -> I>, |
There was a problem hiding this comment.
what do we need this one for?
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| .skip_normalization() | ||
| .skip_binder() |
There was a problem hiding this comment.
can you add fn skip_binder to Unnormalized<[Early]Binder<T>> directly. When skipping binders we also don't care about normalization
| // This keeps us from suggesting borrowing the argument to `mem::drop`, e.g. | ||
| if !clauses.instantiate_identity(tcx).predicates.iter().any(|clause| { | ||
| if !clauses.instantiate_identity(tcx).skip_normalization().predicates.iter().any(|clause| { | ||
| clause.as_trait_clause().is_some_and(|tc| { |
There was a problem hiding this comment.
we probably want a function fn as_trait_clause on Unnormalized to return Unnormalized<Binder<PolyTraitClause>> and duplicate a bunch of the field projections we already have for binder, instead also returning Unnormalized` of the field/wrapped thing
| ty::EarlyBinder::bind(ty).instantiate(tcx, generic_args).skip_normalization(); | ||
| let new_ty = | ||
| ty::EarlyBinder::bind(ty).instantiate(tcx, new_args).skip_normalization(); | ||
| if let Ok(old_ty) = tcx.try_normalize_erasing_regions( |
There was a problem hiding this comment.
I would try to change fn try_normalize_erasing_regions to take Unnormalized<T> and return T and then avoid the skip_normalization here
There was a problem hiding this comment.
I am not totally sure how to best land this change, so do push back if you think any change here makes this PR worse to land instead of better.
I think all the places that do correctly normalize should not have to do skip_normalization by having normalization take an Unnormalized<T> in this PR already 🤔
I think any place where wiring the Unnormalized<T> to the normalize call isn't completely trivial can keep using skip_binder and Unnormalized::new, but having a skip_normalization call right above a call to normalize seems suboptimal 😅
I didn't change normalization routines to make the initial PR trivial. But perhaps I could do that for the most used routines one by one, like |
|
I think yeah, maybe we do want to land this PR as is, without consuming Have separate PRs which adds That way we can also split up to work over multiple people if more people want to be involved. What else might work 🤔 we could instead do a rename of unsure, could try to push this PR through as is, but ideally we can split this up as much as possible without having a lot of redundant steps. This way other people can also review some of the work. |
|
maybe doing it for some of the normalization routines is actually making the diff smaller? You could definitely try it for genuinely just a big change :3 |
View all comments
This is the first step of the eager normalization series.
API changes are in the first commit. The compiler errors are mostly fixed via
ast-grep, with exceptions handled manually.This initial PR contains no behavior change.
r? @ghost