File tree Expand file tree Collapse file tree 1 file changed +22
-15
lines changed Expand file tree Collapse file tree 1 file changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,27 @@ pub(super) fn check(
100100 return ;
101101 }
102102
103+ // We need to provide nonempty parts to diag.multipart_suggestion so we
104+ // collate all our parts here and then remove those that are empty.
105+ let parts = [
106+ (
107+ receiver. span . to ( method_call_span) ,
108+ format ! ( "std::iter::{method_to_use_name}" ) ,
109+ ) ,
110+ new_span,
111+ (
112+ ex. span . shrink_to_hi ( ) ,
113+ if use_take {
114+ format ! ( ".take({count})" )
115+ } else {
116+ String :: new ( )
117+ } ,
118+ ) ,
119+ ]
120+ . into_iter ( )
121+ . filter ( |part| !( part. 0 . is_empty ( ) && part. 1 . is_empty ( ) ) )
122+ . collect ( ) ;
123+
103124 span_lint_and_then (
104125 cx,
105126 MAP_WITH_UNUSED_ARGUMENT_OVER_RANGES ,
@@ -112,21 +133,7 @@ pub(super) fn check(
112133 } else {
113134 format ! ( "remove the explicit range and use `{method_to_use_name}`" )
114135 } ,
115- vec ! [
116- (
117- receiver. span. to( method_call_span) ,
118- format!( "std::iter::{method_to_use_name}" ) ,
119- ) ,
120- new_span,
121- (
122- ex. span. shrink_to_hi( ) ,
123- if use_take {
124- format!( ".take({count})" )
125- } else {
126- String :: new( )
127- } ,
128- ) ,
129- ] ,
136+ parts,
130137 applicability,
131138 ) ;
132139 } ,
You can’t perform that action at this time.
0 commit comments