diff --git a/src/imports.rs b/src/imports.rs index 37b1d9e5d46..ec6a9f1e593 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -37,8 +37,14 @@ impl Rewrite for ast::ViewPath { // FIXME convert to list? None } - ast::ViewPath_::ViewPathSimple(_,_) => { - None + ast::ViewPath_::ViewPathSimple(ident, ref path) => { + let path_str = pprust::path_to_string(path); + + Some(if path.segments.last().unwrap().identifier == ident { + path_str + } else { + format!("{} as {}", path_str, ident) + }) } } } diff --git a/tests/source/imports.rs b/tests/source/imports.rs index 3590ecae61f..f759de3e7bb 100644 --- a/tests/source/imports.rs +++ b/tests/source/imports.rs @@ -39,3 +39,8 @@ fn test() { use Baz::*; use Qux; } + +// Simple imports +use foo::bar::baz as baz ; +use bar::quux as kaas; +use foo; diff --git a/tests/target/imports.rs b/tests/target/imports.rs index a799c096210..bbef3e85e16 100644 --- a/tests/target/imports.rs +++ b/tests/target/imports.rs @@ -32,3 +32,8 @@ fn test() { use Baz::*; use Qux; } + +// Simple imports +use foo::bar::baz; +use bar::quux as kaas; +use foo;