@@ -6,7 +6,7 @@ use clippy_utils::ty::is_copy;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: { BindingAnnotation , ByRef , Expr , ExprKind , MatchSource , Node , PatKind , QPath } ;
8
8
use rustc_lint:: LateContext ;
9
- use rustc_middle:: ty:: { self , adjustment:: Adjust } ;
9
+ use rustc_middle:: ty:: { self , adjustment:: Adjust , print :: with_forced_trimmed_paths } ;
10
10
use rustc_span:: symbol:: { sym, Symbol } ;
11
11
12
12
use super :: CLONE_DOUBLE_REF ;
@@ -47,10 +47,10 @@ pub(super) fn check(
47
47
cx,
48
48
CLONE_DOUBLE_REF ,
49
49
expr. span ,
50
- & format ! (
50
+ & with_forced_trimmed_paths ! ( format!(
51
51
"using `clone` on a double-reference; \
52
52
this will copy the reference of type `{ty}` instead of cloning the inner type"
53
- ) ,
53
+ ) ) ,
54
54
|diag| {
55
55
if let Some ( snip) = sugg:: Sugg :: hir_opt ( cx, arg) {
56
56
let mut ty = innermost;
@@ -61,11 +61,11 @@ pub(super) fn check(
61
61
}
62
62
let refs = "&" . repeat ( n + 1 ) ;
63
63
let derefs = "*" . repeat ( n) ;
64
- let explicit = format ! ( "<{refs}{ty}>::clone({snip})" ) ;
64
+ let explicit = with_forced_trimmed_paths ! ( format!( "<{refs}{ty}>::clone({snip})" ) ) ;
65
65
diag. span_suggestion (
66
66
expr. span ,
67
67
"try dereferencing it" ,
68
- format ! ( "{refs}({derefs}{}).clone()" , snip. deref( ) ) ,
68
+ with_forced_trimmed_paths ! ( format!( "{refs}({derefs}{}).clone()" , snip. deref( ) ) ) ,
69
69
Applicability :: MaybeIncorrect ,
70
70
) ;
71
71
diag. span_suggestion (
@@ -129,7 +129,9 @@ pub(super) fn check(
129
129
cx,
130
130
CLONE_ON_COPY ,
131
131
expr. span ,
132
- & format ! ( "using `clone` on type `{ty}` which implements the `Copy` trait" ) ,
132
+ & with_forced_trimmed_paths ! ( format!(
133
+ "using `clone` on type `{ty}` which implements the `Copy` trait"
134
+ ) ) ,
133
135
help,
134
136
sugg,
135
137
app,
0 commit comments