Do not suggest borrow that is already there in fully-qualified call
When encountering `&str::from("value")` do not suggest `&&str::from("value")`.
Fix #132041.
This commit is contained in:
parent
076a0a26fd
commit
bb74f47327
3 changed files with 40 additions and 0 deletions
|
|
@ -1195,6 +1195,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
c @ ObligationCauseCode::WhereClauseInExpr(_, _, hir_id, _)
|
||||
if self.tcx.hir_span(*hir_id).lo() == span.lo() =>
|
||||
{
|
||||
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
|
||||
{
|
||||
// Do not suggest borrowing when we already do so. This would happen with
|
||||
// `let _ = &str::from("");` where the expression corresponds to the `str`.
|
||||
return false;
|
||||
}
|
||||
c
|
||||
}
|
||||
c if matches!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue