Skip to content

Commit

Permalink
not to avoid self (#3570)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchaser53 authored and topecongiro committed May 21, 2019
1 parent 5300860 commit 0ef2144
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/imports.rs
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
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
@@ -0,0 +1 @@
use a::b::{self};

0 comments on commit 0ef2144

Please sign in to comment.