@@ -358,7 +358,7 @@ impl Segment {
358
358
}
359
359
360
360
fn names_to_string ( segments : & [ Segment ] ) -> String {
361
- names_to_string ( & segments. iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) )
361
+ names_to_string ( segments. iter ( ) . map ( |seg| seg. ident . name ) )
362
362
}
363
363
}
364
364
@@ -2241,13 +2241,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2241
2241
}
2242
2242
}
2243
2243
2244
- fn names_to_string ( names : & [ Symbol ] ) -> String {
2244
+ fn names_to_string ( names : impl Iterator < Item = Symbol > ) -> String {
2245
2245
let mut result = String :: new ( ) ;
2246
- for ( i, name) in names. iter ( ) . filter ( |name| * * name != kw:: PathRoot ) . enumerate ( ) {
2246
+ for ( i, name) in names. filter ( |name| * name != kw:: PathRoot ) . enumerate ( ) {
2247
2247
if i > 0 {
2248
2248
result. push_str ( "::" ) ;
2249
2249
}
2250
- if Ident :: with_dummy_span ( * name) . is_raw_guess ( ) {
2250
+ if Ident :: with_dummy_span ( name) . is_raw_guess ( ) {
2251
2251
result. push_str ( "r#" ) ;
2252
2252
}
2253
2253
result. push_str ( name. as_str ( ) ) ;
@@ -2256,31 +2256,32 @@ fn names_to_string(names: &[Symbol]) -> String {
2256
2256
}
2257
2257
2258
2258
fn path_names_to_string ( path : & Path ) -> String {
2259
- names_to_string ( & path. segments . iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) )
2259
+ names_to_string ( path. segments . iter ( ) . map ( |seg| seg. ident . name ) )
2260
2260
}
2261
2261
2262
2262
/// A somewhat inefficient routine to obtain the name of a module.
2263
- fn module_to_string ( module : Module < ' _ > ) -> Option < String > {
2263
+ fn module_to_string ( mut module : Module < ' _ > ) -> Option < String > {
2264
2264
let mut names = Vec :: new ( ) ;
2265
-
2266
- fn collect_mod ( names : & mut Vec < Symbol > , module : Module < ' _ > ) {
2265
+ loop {
2267
2266
if let ModuleKind :: Def ( .., name) = module. kind {
2268
2267
if let Some ( parent) = module. parent {
2269
2268
names. push ( name) ;
2270
- collect_mod ( names, parent) ;
2269
+ module = parent
2270
+ } else {
2271
+ break ;
2271
2272
}
2272
2273
} else {
2273
2274
names. push ( sym:: opaque_module_name_placeholder) ;
2274
- collect_mod ( names, module. parent . unwrap ( ) ) ;
2275
+ let Some ( parent) = module. parent else {
2276
+ return None ;
2277
+ } ;
2278
+ module = parent;
2275
2279
}
2276
2280
}
2277
- collect_mod ( & mut names, module) ;
2278
-
2279
2281
if names. is_empty ( ) {
2280
2282
return None ;
2281
2283
}
2282
- names. reverse ( ) ;
2283
- Some ( names_to_string ( & names) )
2284
+ Some ( names_to_string ( names. iter ( ) . rev ( ) . copied ( ) ) )
2284
2285
}
2285
2286
2286
2287
#[ derive( Copy , Clone , Debug ) ]
0 commit comments