Uh oh!
There was an error while loading. Please reload this page.
refactor LoweringContext::lower_generics_mut - #86298
Conversation
There was a problem hiding this comment.
Can you give a longer name to this function? There are already plenty of ways to get def_ids here.
Perhaps predicate_id?
There was a problem hiding this comment.
I think ty_param_id is probably more accurate.
There was a problem hiding this comment.
This loop can be refactored into a call to generics.params.iter().find. The matches! test should perhaps be an assertion on the found parameter.
There was a problem hiding this comment.
Are you saying that param.id won't match unless it's a type parameter? I guess duplicate LocalDefIds aren't supposed to happen, and we already know that def_id is for a TyParam. I'm also wary of adding an assertion where there wasn't one in the original code.
On the other hand, the matches! will allow skipping of calls to self.resolver.local_def_id for non-type generic parameters, which could have a performance impact, given that this function is kind of quadratic in the number of generic parameters.
bors
commented
Jul 24, 2021
☔ The latest upstream changes (presumably #87338) made this pull request unmergeable. Please resolve the merge conflicts. |
Further reduce nesting by using early exits and replacing the innermost loop with `.find()`. Also eliminates the labeled branch. Add comments explaining why the copying of `?Sized` bounds is necessary.
30eebcd to
0771f9cComparetlyu
commented
Jul 25, 2021
| .map(|d| (d.base_res(), d.unresolved_segments())) | ||
| { | ||
| Some((Res::Def(DefKind::TyParam, def_id), 0)) | ||
| if bound_pred.bound_generic_params.is_empty() => |
There was a problem hiding this comment.
The match expression and this test do not depend on bound. Can those be lifted out of the loop?
jackh726
commented
Sep 8, 2021
bors
commented
Sep 8, 2021
☔ The latest upstream changes (presumably #88061) made this pull request unmergeable. Please resolve the merge conflicts. |
JohnCSimon
commented
Sep 27, 2021
Ping from triage: |
Reduce nesting by using early exits and factoring out a helper
function. Also add comments explaining why the copying of
?Sizedbounds is necessary.r? @estebank
@rustbot label +A-hir +A-traits +C-cleanup +T-compiler