@@ -5,7 +5,7 @@ use rustc_lint::{LateContext, LateLintPass};
55use rustc_middle:: ty;
66use rustc_middle:: ty:: { ClauseKind , GenericPredicates , ProjectionPredicate , TraitPredicate } ;
77use rustc_session:: declare_lint_pass;
8- use rustc_span:: { BytePos , Span , sym} ;
8+ use rustc_span:: { BytePos , Span , sym, Symbol } ;
99
1010declare_clippy_lint ! {
1111 /// ### What it does
@@ -86,7 +86,7 @@ fn get_args_to_check<'tcx>(
8686 fn_mut_trait : DefId ,
8787 ord_trait : Option < DefId > ,
8888 partial_ord_trait : Option < DefId > ,
89- ) -> Vec < ( usize , String ) > {
89+ ) -> Vec < ( usize , Symbol ) > {
9090 let mut args_to_check = Vec :: new ( ) ;
9191 if let Some ( def_id) = cx. typeck_results ( ) . type_dependent_def_id ( expr. hir_id ) {
9292 let fn_sig = cx. tcx . fn_sig ( def_id) . instantiate_identity ( ) ;
@@ -116,15 +116,15 @@ fn get_args_to_check<'tcx>(
116116 . iter ( )
117117 . any ( |ord| Some ( ord. self_ty ( ) ) == return_ty_pred. term . as_type ( ) )
118118 {
119- args_to_check. push ( ( i, String :: from ( " Ord" ) ) ) ;
119+ args_to_check. push ( ( i, sym :: Ord ) ) ;
120120 if args_to_check. len ( ) == args_len - 1 {
121121 break ;
122122 }
123123 } else if partial_ord_preds
124124 . iter ( )
125125 . any ( |pord| pord. self_ty ( ) == return_ty_pred. term . expect_type ( ) )
126126 {
127- args_to_check. push ( ( i, String :: from ( " PartialOrd" ) ) ) ;
127+ args_to_check. push ( ( i, sym :: PartialOrd ) ) ;
128128 if args_to_check. len ( ) == args_len - 1 {
129129 break ;
130130 }
@@ -188,7 +188,8 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd {
188188 span,
189189 format ! (
190190 "this closure returns \
191- the unit type which also implements {trait_name}"
191+ the unit type which also implements {}",
192+ trait_name. as_str( )
192193 ) ,
193194 ) ;
194195 } ,
@@ -199,7 +200,9 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd {
199200 span,
200201 format ! (
201202 "this closure returns \
202- the unit type which also implements {trait_name}"
203+ the unit type which also implements {}",
204+ trait_name. as_str( )
205+
203206 ) ,
204207 Some ( last_semi) ,
205208 "probably caused by this trailing semicolon" ,
0 commit comments