diff --git a/src/imports.rs b/src/imports.rs index a66bcbd3e94..9a02ee64fb7 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -309,19 +309,24 @@ impl UseTree { } } + let mut done = false; if aliased_self { - match self.path.last() { + match self.path.last_mut() { Some(UseSegment::Ident(_, ref mut old_rename)) => { assert!(old_rename.is_none()); - if let UseSegment::Slf(Some(rename)) = last { + if let UseSegment::Slf(Some(rename)) = last.clone() { *old_rename = Some(rename); - return self; + done = true; } } _ => unreachable!(), } } + if done { + return self; + } + // Normalise foo::{bar} -> foo::bar if let UseSegment::List(ref list) = last { if list.len() == 1 {