@@ -6,7 +6,7 @@ use clippy_utils::ty::is_copy;
66use rustc_errors:: Applicability ;
77use rustc_hir:: { BindingAnnotation , ByRef , Expr , ExprKind , MatchSource , Node , PatKind , QPath } ;
88use rustc_lint:: LateContext ;
9- use rustc_middle:: ty:: { self , adjustment:: Adjust } ;
9+ use rustc_middle:: ty:: { self , adjustment:: Adjust , print :: with_forced_trimmed_paths } ;
1010use rustc_span:: symbol:: { sym, Symbol } ;
1111
1212use super :: CLONE_DOUBLE_REF ;
@@ -47,10 +47,10 @@ pub(super) fn check(
4747 cx,
4848 CLONE_DOUBLE_REF ,
4949 expr. span ,
50- & format ! (
50+ & with_forced_trimmed_paths ! ( format!(
5151 "using `clone` on a double-reference; \
5252 this will copy the reference of type `{ty}` instead of cloning the inner type"
53- ) ,
53+ ) ) ,
5454 |diag| {
5555 if let Some ( snip) = sugg:: Sugg :: hir_opt ( cx, arg) {
5656 let mut ty = innermost;
@@ -61,11 +61,11 @@ pub(super) fn check(
6161 }
6262 let refs = "&" . repeat ( n + 1 ) ;
6363 let derefs = "*" . repeat ( n) ;
64- let explicit = format ! ( "<{refs}{ty}>::clone({snip})" ) ;
64+ let explicit = with_forced_trimmed_paths ! ( format!( "<{refs}{ty}>::clone({snip})" ) ) ;
6565 diag. span_suggestion (
6666 expr. span ,
6767 "try dereferencing it" ,
68- format ! ( "{refs}({derefs}{}).clone()" , snip. deref( ) ) ,
68+ with_forced_trimmed_paths ! ( format!( "{refs}({derefs}{}).clone()" , snip. deref( ) ) ) ,
6969 Applicability :: MaybeIncorrect ,
7070 ) ;
7171 diag. span_suggestion (
@@ -129,7 +129,9 @@ pub(super) fn check(
129129 cx,
130130 CLONE_ON_COPY ,
131131 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+ ) ) ,
133135 help,
134136 sugg,
135137 app,
0 commit comments