not to avoid self (#3570)

This commit is contained in:
rChaser53 2019-05-21 11:43:28 +09:00 committed by Seiichi Uchida
parent 530086046f
commit 0ef2144c82
3 changed files with 11 additions and 7 deletions

View File

@ -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;
}
}
@ -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(),
@ -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()

View File

@ -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::{
@ -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};

View File

@ -0,0 +1 @@
use a::b::{self};