-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Make TyKind
Copy
and change ty.kind()
to return TyKind
#77482
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
❤️ @bors try @rust-timer perf |
⌛ Trying commit 5268ae7 with merge a9b36da2412359e22b389fab4829683fdbe81dbb... |
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.
some small nits, otherwise this is a lot cleaner than before. Thanks!
@@ -575,7 +575,7 @@ impl<T> Trait<T> for X { | |||
// This will also work for `impl Trait`. | |||
let def_id = if let ty::Param(param_ty) = proj_ty.self_ty().kind() { | |||
let generics = self.generics_of(body_owner_def_id); | |||
generics.type_param(param_ty, self).def_id | |||
generics.type_param(¶m_ty, self).def_id |
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.
Probably want to instead take ParamTy
by value in type_param
, but using a reference is fine for now here
@@ -347,7 +347,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { | |||
"`Self`", | |||
err, | |||
None, | |||
projection, | |||
projection.as_ref(), |
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.
followup: probably take Option<ProjectionTy>
in suggest_restriction
*r_ty.kind() == Str || is_std_string(r_ty) || | ||
(Ref(_, l_ty, _), Ref(_, r_ty, _)) // &str or &String + &str, &String or &&str | ||
if (l_ty.kind() == Str || is_std_string(l_ty)) && ( | ||
r_ty.kind() == Str || is_std_string(r_ty) || | ||
&format!("{:?}", rhs_ty) == "&&str" |
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.
unrelated, but we really shouldn't compare on format!("{:?}", rhs_ty)
here
used the wrong rust-timer command edit: and again @rust-timer queue |
Awaiting bors try build completion |
☀️ Try build successful - checks-actions, checks-azure |
Queued a9b36da2412359e22b389fab4829683fdbe81dbb with parent 6f56fbd, future comparison URL. |
Finished benchmarking try commit (a9b36da2412359e22b389fab4829683fdbe81dbb): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
Also cc @eddyb in case you're interested in the perf results |
f7a8357
to
f47fd5d
Compare
not sure about perf, cycles looks quite positive, wall-time is probably about neutral all considered and instructions got worse. I would have expected that we mostly just instantly match on |
I think using So we probably get better perf - and cleaner code - if we eliminate these. experimented in https://godbolt.org/z/o3bsM3 |
f47fd5d
to
46df4cf
Compare
@@ -325,8 +325,8 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>( | |||
) -> RelateResult<'tcx, Ty<'tcx>> { | |||
let tcx = relation.tcx(); | |||
debug!("super_relate_tys: a={:?} b={:?}", a, b); | |||
match (&a.kind(), &b.kind()) { | |||
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => { | |||
match (a.kind(), b.kind()) { |
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.
I hope this was the main reason for the regression. Relate is quite hot and &a.kind()
results in suboptimal codegen
46df4cf
to
380e230
Compare
let's try again @bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 380e230 with merge ab3feb4f1ad1434df143ec7dc8c54097cc1b387c... |
☀️ Try build successful - checks-actions, checks-azure |
Queued ab3feb4f1ad1434df143ec7dc8c54097cc1b387c with parent 738d4a7, future comparison URL. |
Finished benchmarking try commit (ab3feb4f1ad1434df143ec7dc8c54097cc1b387c): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
See https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Make.20TyKind.20Copy.20and.20change.20ty.2Ekind%28%29.20to.20.E2.80.A6.20compiler-team.23363/near/212460531 for some discussion about this. A huge thanks for @LeSeulArtichaut for implementing this MCP! |
Implements T-compiler MCP rust-lang/compiler-team#363.
This should be perf-tested.
r? @lcnr cc @nikomatsakis