diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-06-17 23:48:03 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-06-17 23:48:47 +0800 |
| commit | fd9c1b962ae29ff928c2c6310a227b56b9db19bd (patch) | |
| tree | d0c0ccc1f36a4f2ae55e96b8368300b1d2a3ab0f /compiler | |
| parent | 02dac5cd78ff36663facc7863e6b4ed4b8df92b2 (diff) | |
| download | rust-fd9c1b962ae29ff928c2c6310a227b56b9db19bd.tar.gz rust-fd9c1b962ae29ff928c2c6310a227b56b9db19bd.zip | |
Find correct span when suggesting using clone
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 7e5f1d97a8b..1154cc26c59 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1302,8 +1302,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => ".clone()".to_string(), }; + let span = expr.span.find_oldest_ancestor_in_same_ctxt().shrink_to_hi(); + diag.span_suggestion_verbose( - expr.span.shrink_to_hi(), + span, "consider using clone here", suggestion, Applicability::MachineApplicable, |
