mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Remove unnecessary argument from suggest_cloning
This commit is contained in:
parent
01b810e052
commit
259348cf7e
@ -476,7 +476,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
|
||||
// The place where the the type moves would be misleading to suggest clone.
|
||||
// #121466
|
||||
self.suggest_cloning(err, ty, expr, move_span);
|
||||
self.suggest_cloning(err, ty, expr);
|
||||
}
|
||||
}
|
||||
if let Some(pat) = finder.pat {
|
||||
@ -987,20 +987,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
can_suggest_clone
|
||||
}
|
||||
|
||||
pub(crate) fn suggest_cloning(
|
||||
&self,
|
||||
err: &mut Diag<'_>,
|
||||
ty: Ty<'tcx>,
|
||||
expr: &hir::Expr<'_>,
|
||||
span: Span,
|
||||
) {
|
||||
pub(crate) fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
|
||||
if let Some(clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
|
||||
&& self
|
||||
.infcx
|
||||
.type_implements_trait(clone_trait_def, [ty], self.param_env)
|
||||
.must_apply_modulo_regions()
|
||||
{
|
||||
self.suggest_cloning_inner(err, ty, expr, span);
|
||||
self.suggest_cloning_inner(err, ty, expr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1019,13 +1013,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn suggest_cloning_inner(
|
||||
&self,
|
||||
err: &mut Diag<'_>,
|
||||
ty: Ty<'tcx>,
|
||||
expr: &hir::Expr<'_>,
|
||||
span: Span,
|
||||
) {
|
||||
fn suggest_cloning_inner(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
|
||||
let tcx = self.infcx.tcx;
|
||||
if let Some(_) = self.clone_on_reference(expr) {
|
||||
// Avoid redundant clone suggestion already suggested in `explain_captures`.
|
||||
@ -1053,7 +1041,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
// Account for `(*x)` to suggest `x.clone()`.
|
||||
expr.span.with_lo(inner_expr.span.hi())
|
||||
} else {
|
||||
span.shrink_to_hi()
|
||||
expr.span.shrink_to_hi()
|
||||
};
|
||||
sugg.push((span, suggestion));
|
||||
let msg = if let ty::Adt(def, _) = ty.kind()
|
||||
@ -1173,7 +1161,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
if let Some(expr) = self.find_expr(borrow_span)
|
||||
&& let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
|
||||
{
|
||||
self.suggest_cloning(&mut err, ty, expr, borrow_span);
|
||||
self.suggest_cloning(&mut err, ty, expr);
|
||||
}
|
||||
self.buffer_error(err);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
};
|
||||
|
||||
if let Some(expr) = self.find_expr(span) {
|
||||
self.suggest_cloning(err, place_ty, expr, span);
|
||||
self.suggest_cloning(err, place_ty, expr);
|
||||
}
|
||||
|
||||
err.subdiagnostic(
|
||||
@ -480,7 +480,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
};
|
||||
|
||||
if let Some(expr) = self.find_expr(span) {
|
||||
self.suggest_cloning(err, place_ty, expr, span);
|
||||
self.suggest_cloning(err, place_ty, expr);
|
||||
}
|
||||
|
||||
err.subdiagnostic(
|
||||
@ -593,7 +593,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
|
||||
|
||||
if let Some(expr) = self.find_expr(binding_span) {
|
||||
self.suggest_cloning(err, bind_to.ty, expr, binding_span);
|
||||
self.suggest_cloning(err, bind_to.ty, expr);
|
||||
}
|
||||
|
||||
err.subdiagnostic(
|
||||
|
Loading…
Reference in New Issue
Block a user