@@ -511,7 +511,7 @@ declare_lint! {
511
511
/// let def = String::from("def");
512
512
/// let mut s = String::new();
513
513
/// s.push_str(abc);
514
- /// s.push_str(def.as_str( ));
514
+ /// s.push_str(& def));
515
515
/// ```
516
516
517
517
declare_lint ! {
@@ -843,10 +843,10 @@ fn lint_string_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) {
843
843
if let Some ( arglists) = method_chain_args ( arg, & [ "chars" ] ) {
844
844
let target = & arglists[ 0 ] [ 0 ] ;
845
845
let ( self_ty, _) = walk_ptrs_ty_depth ( cx. tcx . tables ( ) . expr_ty ( target) ) ;
846
- let extra_suggestion = if self_ty. sty == ty:: TyStr {
846
+ let ref_str = if self_ty. sty == ty:: TyStr {
847
847
""
848
848
} else if match_type ( cx, self_ty, & paths:: STRING ) {
849
- ".as_str() "
849
+ "& "
850
850
} else {
851
851
return ;
852
852
} ;
@@ -860,8 +860,8 @@ fn lint_string_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) {
860
860
db. span_suggestion ( expr. span , "try this" ,
861
861
format ! ( "{}.push_str({}{})" ,
862
862
snippet( cx, args[ 0 ] . span, "_" ) ,
863
- snippet ( cx , target . span , "_" ) ,
864
- extra_suggestion ) ) ;
863
+ ref_str ,
864
+ snippet ( cx , target . span , "_" ) ) ) ;
865
865
} ) ;
866
866
}
867
867
}
0 commit comments