-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add SliceLike
to rustc_type_ir
, use it in the generic solver code (+ some other changes)
#126813
Conversation
Some changes occurred in match checking cc @Nadrieril Some changes occurred in compiler/rustc_sanitizers cc @rust-lang/project-exploit-mitigations, @rcvalle HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes) First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why. Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in. Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷 r? lcnr
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (d906ddd): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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)Results (primary -3.5%, secondary 3.1%)This 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 sizeResults (secondary 0.3%)This 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.
Bootstrap: 697.477s -> 694.569s (-0.42%) |
Looks like there's a slight perf improvement -- either noise, or because of the addition of |
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.
iter::zip(a.into_iter(), b.into_iter())
seems quite confusing. What are your thoughts about adding zip
to slice_like
to handle this. Alternatively zip_slice_like
as a free function
#[derivative(Debug = "ignore")] | ||
pub(crate) _use_alias_ty_new_instead: (), | ||
} | ||
|
||
impl<I: Interner> AliasTy<I> { | ||
pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTy<I> { |
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.
can now just delegate to new_from_args
?
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.
Yep, that's simpler
It seems excessive to basically pull down one iterator combination. I don't actually understand what you find confusing about that, either. I guess I could make it slightly less noisy by renaming
|
yeah, I'd prefer |
0770597
to
d521e21
Compare
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5b270e1): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @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)Results (primary -2.1%, secondary -3.5%)This 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.
CyclesResults (primary -2.0%)This 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 692.774s -> 693.576s (0.12%) |
@rustbot label: +perf-regression-triaged |
First, we split out
TraitRef::new_from_args
which takes justty::GenericArgsRef
fromTraitRef::new
which takesimpl IntoIterator<Item: Into<GenericArg>>
. I will explain in a minute why.Second, we introduce
SliceLike
, which allows us to be generic overList<T>
and[T]
. This trait has anas_slice()
andinto_iter()
method, and some other convenience functions. However, importantly, since types likeI::GenericArgs
now implementSliceLike
rather thanIntoIter<Item = I::GenericArg>
, we can't useTraitRef::new
on this directly. That's wherenew_from_args
comes in.Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use
as_slice()
in a few places. 🤷r? lcnr