1
Fork 0

Merge pull request #144 from marcusklaas/single-use

Format simple imports
This commit is contained in:
Nick Cameron 2015-07-26 09:38:07 +12:00
commit ed889e01db
3 changed files with 18 additions and 2 deletions

View file

@ -37,8 +37,14 @@ impl Rewrite for ast::ViewPath {
// FIXME convert to list? // FIXME convert to list?
None None
} }
ast::ViewPath_::ViewPathSimple(_,_) => { ast::ViewPath_::ViewPathSimple(ident, ref path) => {
None 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 Baz::*;
use Qux; 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 Baz::*;
use Qux; use Qux;
} }
// Simple imports
use foo::bar::baz;
use bar::quux as kaas;
use foo;