Skip to content

Commit 0ef2144

Browse files
rchaser53topecongiro
authored andcommitted
not to avoid self (rust-lang#3570)
1 parent 5300860 commit 0ef2144

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/imports.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl UseTree {
478478

479479
// Normalise foo::{bar} -> foo::bar
480480
if let UseSegment::List(ref list) = last {
481-
if list.len() == 1 {
481+
if list.len() == 1 && list[0].to_string() != "self" {
482482
normalize_sole_list = true;
483483
}
484484
}
@@ -1034,7 +1034,10 @@ mod test {
10341034
parse_use_tree("a::self as foo").normalize(),
10351035
parse_use_tree("a as foo")
10361036
);
1037-
assert_eq!(parse_use_tree("a::{self}").normalize(), parse_use_tree("a"));
1037+
assert_eq!(
1038+
parse_use_tree("a::{self}").normalize(),
1039+
parse_use_tree("a::{self}")
1040+
);
10381041
assert_eq!(parse_use_tree("a::{b}").normalize(), parse_use_tree("a::b"));
10391042
assert_eq!(
10401043
parse_use_tree("a::{b, c::self}").normalize(),
@@ -1069,8 +1072,8 @@ mod test {
10691072
);
10701073

10711074
assert!(
1072-
parse_use_tree("foo::{self as bar}").normalize()
1073-
< parse_use_tree("foo::{qux as bar}").normalize()
1075+
parse_use_tree("foo::{qux as bar}").normalize()
1076+
< parse_use_tree("foo::{self as bar}").normalize()
10741077
);
10751078
assert!(
10761079
parse_use_tree("foo::{qux as bar}").normalize()

tests/target/imports.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use list::{
2222

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

25-
use syntax;
2625
pub use syntax::ast::{Expr, ExprAssign, ExprCall, ExprMethodCall, ExprPath, Expr_};
26+
use syntax::{self};
2727
use Foo::{Bar, Baz};
2828
use {Bar /* comment */, /* Pre-comment! */ Foo};
2929

3030
use std::io;
31-
use std::io;
31+
use std::io::{self};
3232

3333
mod Foo {
3434
pub use syntax::ast::{
@@ -53,8 +53,8 @@ use foo;
5353
use foo::bar::baz;
5454

5555
// With aliases.
56-
use foo as bar;
5756
use foo::qux as bar;
57+
use foo::{self as bar};
5858
use foo::{self as bar, baz};
5959
use foo::{baz, qux as bar};
6060

tests/target/issue-3568.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use a::b::{self};

0 commit comments

Comments
 (0)