@@ -48,8 +48,8 @@ fn collect_path_segments(path: &ast::Path) -> Option<Vec<&ast::PathSegment>> {
48
48
return Some ( v) ;
49
49
}
50
50
51
- fn collect_path_segments_raw < ' b , ' a : ' b > (
52
- segments : & ' b mut Vec < & ' a ast:: PathSegment > ,
51
+ fn collect_path_segments_raw < ' a > (
52
+ segments : & mut Vec < & ' a ast:: PathSegment > ,
53
53
mut path : & ' a ast:: Path ,
54
54
) -> Option < usize > {
55
55
let oldlen = segments. len ( ) ;
@@ -105,8 +105,6 @@ fn fmt_segments_raw(segments: &[&ast::PathSegment], buf: &mut String) {
105
105
enum PathSegmentsMatch {
106
106
// Patch matches exactly
107
107
Full ,
108
- // None of the segments matched. It's a more explicit Partial(0)
109
- Empty ,
110
108
// When some of the segments matched
111
109
Partial ( usize ) ,
112
110
// When all the segments of the right path are matched against the left path,
@@ -129,11 +127,7 @@ fn compare_path_segments(
129
127
if compare_path_segment ( left, right) {
130
128
matching += 1
131
129
} else {
132
- return if matching == 0 {
133
- PathSegmentsMatch :: Empty
134
- } else {
135
- PathSegmentsMatch :: Partial ( matching)
136
- } ;
130
+ return PathSegmentsMatch :: Partial ( matching) ;
137
131
}
138
132
}
139
133
EitherOrBoth :: Left ( _) => {
@@ -149,15 +143,15 @@ fn compare_path_segments(
149
143
150
144
fn compare_path_segment ( a : & ast:: PathSegment , b : & ast:: PathSegment ) -> bool {
151
145
if let ( Some ( ka) , Some ( kb) ) = ( a. kind ( ) , b. kind ( ) ) {
152
- return match ( ka, kb) {
146
+ match ( ka, kb) {
153
147
( ast:: PathSegmentKind :: Name ( nameref_a) , ast:: PathSegmentKind :: Name ( nameref_b) ) => {
154
148
nameref_a. text ( ) == nameref_b. text ( )
155
149
}
156
150
( ast:: PathSegmentKind :: SelfKw , ast:: PathSegmentKind :: SelfKw ) => true ,
157
151
( ast:: PathSegmentKind :: SuperKw , ast:: PathSegmentKind :: SuperKw ) => true ,
158
152
( ast:: PathSegmentKind :: CrateKw , ast:: PathSegmentKind :: CrateKw ) => true ,
159
153
( _, _) => false ,
160
- } ;
154
+ }
161
155
} else {
162
156
false
163
157
}
@@ -226,11 +220,11 @@ impl<'a> ImportAction<'a> {
226
220
227
221
// Find out the best ImportAction to import target path against current_use_tree.
228
222
// If current_use_tree has a nested import the function gets called recursively on every UseTree inside a UseTreeList.
229
- fn walk_use_tree_for_best_action < ' b , ' c , ' a : ' b + ' c > (
230
- current_path_segments : & ' b mut Vec < & ' a ast:: PathSegment > , // buffer containing path segments
223
+ fn walk_use_tree_for_best_action < ' a > (
224
+ current_path_segments : & mut Vec < & ' a ast:: PathSegment > , // buffer containing path segments
231
225
current_parent_use_tree_list : Option < & ' a ast:: UseTreeList > , // will be Some value if we are in a nested import
232
226
current_use_tree : & ' a ast:: UseTree , // the use tree we are currently examinating
233
- target : & ' c [ & ' a ast:: PathSegment ] , // the path we want to import
227
+ target : & [ & ' a ast:: PathSegment ] , // the path we want to import
234
228
) -> ImportAction < ' a > {
235
229
// We save the number of segments in the buffer so we can restore the correct segments
236
230
// before returning. Recursive call will add segments so we need to delete them.
@@ -295,7 +289,7 @@ fn walk_use_tree_for_best_action<'b, 'c, 'a: 'b + 'c>(
295
289
ImportAction :: Nothing
296
290
}
297
291
}
298
- PathSegmentsMatch :: Empty => ImportAction :: AddNewUse (
292
+ PathSegmentsMatch :: Partial ( 0 ) => ImportAction :: AddNewUse (
299
293
// e.g: target is std::fmt and we can have
300
294
// use foo::bar
301
295
// We add a brand new use statement
@@ -346,7 +340,7 @@ fn walk_use_tree_for_best_action<'b, 'c, 'a: 'b + 'c>(
346
340
better_action
347
341
}
348
342
PathSegmentsMatch :: PartialRight ( n) => {
349
- // e.g: target std::fmt and we can have
343
+ // e.g: target is std::fmt and we can have
350
344
// use std::fmt::Debug;
351
345
let segments_to_split = current_path_segments. split_at ( prev_len + n) . 1 ;
352
346
ImportAction :: AddNestedImport ( prev_len + n, path, Some ( segments_to_split[ 0 ] ) , true )
0 commit comments