Format simple imports

This commit is contained in:
Marcus Klaas 2015-07-25 23:10:48 +02:00
parent 0f3848471d
commit 397d0d3d72
3 changed files with 18 additions and 2 deletions

View File

@ -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)
})
}
}
}

View File

@ -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;

View File

@ -32,3 +32,8 @@ fn test() {
use Baz::*;
use Qux;
}
// Simple imports
use foo::bar::baz;
use bar::quux as kaas;
use foo;