Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl UseTree {

// Normalise foo::{bar} -> foo::bar
if let UseSegment::List(ref list) = last {
if list.len() == 1 {
if list.len() == 1 && list[0].to_string() != "self" {
normalize_sole_list = true;
}
}
Expand Down Expand Up @@ -1034,7 +1034,10 @@ mod test {
parse_use_tree("a::self as foo").normalize(),
parse_use_tree("a as foo")
);
assert_eq!(parse_use_tree("a::{self}").normalize(), parse_use_tree("a"));
assert_eq!(
parse_use_tree("a::{self}").normalize(),
parse_use_tree("a::{self}")
);
assert_eq!(parse_use_tree("a::{b}").normalize(), parse_use_tree("a::b"));
assert_eq!(
parse_use_tree("a::{b, c::self}").normalize(),
Expand Down Expand Up @@ -1069,8 +1072,8 @@ mod test {
);

assert!(
parse_use_tree("foo::{self as bar}").normalize()
< parse_use_tree("foo::{qux as bar}").normalize()
parse_use_tree("foo::{qux as bar}").normalize()
< parse_use_tree("foo::{self as bar}").normalize()
);
assert!(
parse_use_tree("foo::{qux as bar}").normalize()
Expand Down
6 changes: 3 additions & 3 deletions tests/target/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ use list::{

use test::{/* A */ self /* B */, Other /* C */};

use syntax;
pub use syntax::ast::{Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath, Expr_};
use syntax::{self};
use Foo::{Bar, Baz};
use {Bar /* comment */, /* Pre-comment! */ Foo};

use std::io;
use std::io;
use std::io::{self};

mod Foo {
pub use syntax::ast::{
Expand All @@ -53,8 +53,8 @@ use foo;
use foo::bar::baz;

// With aliases.
use foo as bar;
use foo::qux as bar;
use foo::{self as bar};
use foo::{self as bar, baz};
use foo::{baz, qux as bar};

Expand Down
1 change: 1 addition & 0 deletions tests/target/issue-3568.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use a::b::{self};