-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Do not suggest borrow that is already there in fully-qualified call #132469
base: master
Are you sure you want to change the base?
Conversation
When encountering `&str::from("value")` do not suggest `&&str::from("value")`. Fix rust-lang#132041.
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
if let hir::Node::Expr(expr) = self.tcx.parent_hir_node(*hir_id) | ||
&& let hir::ExprKind::Call(base, _) = expr.kind | ||
&& let hir::ExprKind::Path(hir::QPath::TypeRelative(ty, _)) = base.kind | ||
&& ty.span == 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 not following the logic: where in this condition are you checking that the expression is already borrowed?
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 can add the check for the existing borrow one level up, but I also wanted to avoid suggesting &str::from("")
when we have str::from("")
as that won't help either.
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 see, so the comment below could be saying something like "don't suggest borrowing when this wouldn't fix the problem (because the type is specified by a path instead of inferred)"?
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.
Ah I understand my confusion: I had understood "Do not suggest borrowing when we already do so" as "Do not suggest borrowing when the expression is already borrowed"
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.
Coming back to this: I still don't understand what this branch is catching. Can you rephrase the comment to be more explicit about what the branch means plz?
When encountering
&str::from("value")
do not suggest&&str::from("value")
.Fix #132041.