-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Point to lifetime spans on lifetime errors #51862
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
let mut sp = cm.def_span(self.hir.span(node)); | ||
if let Some(generics) = self.hir.get_generics(scope) { | ||
for param in &generics.params { | ||
if param.name.name().as_str() == br.name.as_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.
This loop feels like something that occurs more often (e.g. in lowering code or other diagnostics). Maybe pull it out into a method on Generics
and do a quick grep around the source to see if any other places could benefit from an fn(&Generics, Name) -> Option<&Param>
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 made a cursory look for other possible uses but I couldn't any. I'm sure I'll find some while working on something else down the line, though.
This comment has been minimized.
This comment has been minimized.
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.
Looks good, if we extract a helper would look better. 😛
), | ||
ty::ReEarlyBound(ref br) => { | ||
let mut sp = cm.def_span(self.hir.span(node)); | ||
if let Some(generics) = self.hir.get_generics(scope) { |
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 agree with @oli-obk that we should not "open code" this loop but rather extract a helper. Bonus points for finding other code to use it =)
let mut sp = cm.def_span(self.hir.span(node)); | ||
if let Some(generics) = self.hir.get_generics(scope) { | ||
for param in &generics.params { | ||
if param.name.name().as_str() == name.as_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.
If nothing else, the same loop seems to be down here?
Helper added. |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit 8449c5a has been approved by |
…akis Point to lifetime spans on lifetime errors
Point to lifetime spans on lifetime errors
☀️ Test successful - status-appveyor, status-travis |
No description provided.