This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -324,9 +324,8 @@ impl UseTree {
324
324
attrs,
325
325
} ;
326
326
327
- let leading_modsep = context. config . edition ( ) == Edition :: Edition2018
328
- && a. prefix . to_string ( ) . len ( ) > 2
329
- && a. prefix . to_string ( ) . starts_with ( "::" ) ;
327
+ let leading_modsep =
328
+ context. config . edition ( ) == Edition :: Edition2018 && a. prefix . is_global ( ) ;
330
329
331
330
let mut modsep = leading_modsep;
332
331
@@ -367,7 +366,15 @@ impl UseTree {
367
366
) ) ;
368
367
}
369
368
UseTreeKind :: Simple ( ref rename, ..) => {
370
- let name = rewrite_ident ( context, path_to_imported_ident ( & a. prefix ) ) . to_owned ( ) ;
369
+ // If the path has leading double colons and is composed of only 2 segments, then we
370
+ // bypass the call to path_to_imported_ident which would get only the ident and
371
+ // lose the path root, e.g., `that` in `::that`.
372
+ // The span of `a.prefix` contains the leading colons.
373
+ let name = if a. prefix . segments . len ( ) == 2 && leading_modsep {
374
+ context. snippet ( a. prefix . span ) . to_owned ( )
375
+ } else {
376
+ rewrite_ident ( context, path_to_imported_ident ( & a. prefix ) ) . to_owned ( )
377
+ } ;
371
378
let alias = rename. and_then ( |ident| {
372
379
if ident. name == "_" {
373
380
// for impl-only-use
You can’t perform that action at this time.
0 commit comments