-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Preserve explicit lifetime information when removing mut
#16273
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
Conversation
Rather than trying to reconstruct the reference type without the `mut`, remove the `mut` itself so that user-inserted lifetime information is preserved. The message has been changed from "consider changing to [NON-MUT REF]" to "remove this `mut`"
|
Lintcheck changes for dcb19a0
This comment will be updated if you push new changes |
| sp, | ||
| "consider changing to".to_string(), | ||
| format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),), | ||
| mut_span, |
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.
Is there any reason not to use this as the lint span?
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.
Given the existing message ("this argument is a mutable reference, but not used mutably") it makes sense to point to the whole argument when linting.
I'll change this to "this parameter is a mutable reference but is not used mutably" which is more correct though.
Tell me if you want me to change the span.
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'm fine with not dealing with this now. I have a general issue with how we use error spans that are way larger than what's needed to communicate the problem, but it's also unrelated to fixing the suggestion.
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.
Thank you.
Rather than trying to reconstruct the reference type without the
mut, remove themutitself so that user-inserted lifetime information is preserved.The message has been changed from "consider changing to [NON-MUT REF]" to "remove this
mut"changelog: [
needless_pass_by_ref_mut]: preserve user-provided lifetime informationFixes #16267