From e784712f09d4978b5331ceaf96476bcf4b1b0b1b Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 9 Apr 2018 21:07:49 +1200 Subject: [PATCH] Try to fix a build regression before it happens --- src/imports.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 {