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