mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
fix: merge_imports handling of ::{self}
This commit is contained in:
parent
ee38d02591
commit
7c9c0d1a39
@ -543,6 +543,12 @@ impl UseTree {
|
||||
}
|
||||
match self.path.clone().last().unwrap() {
|
||||
UseSegment::List(list) => {
|
||||
if list.len() == 1 && list[0].path.len() == 1 {
|
||||
match list[0].path[0] {
|
||||
UseSegment::Slf(..) => return vec![self],
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
let prefix = &self.path[..self.path.len() - 1];
|
||||
let mut result = vec![];
|
||||
for nested_use_tree in list {
|
||||
@ -1018,6 +1024,10 @@ mod test {
|
||||
["a::{c, d, b}", "a::{d, e, b, a, f}", "a::{f, g, c}"],
|
||||
["a::{a, b, c, d, e, f, g}"]
|
||||
);
|
||||
test_merge!(
|
||||
["a::{self}", "b::{self as foo}"],
|
||||
["a::{self}", "b::{self as foo}"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -22,3 +22,10 @@ use a::{b::{c::*}};
|
||||
use a::{b::{c::{}}};
|
||||
use a::{b::{c::d}};
|
||||
use a::{b::{c::{xxx, yyy, zzz}}};
|
||||
|
||||
// https://github.com/rust-lang/rustfmt/issues/3808
|
||||
use d::{self};
|
||||
use e::{self as foo};
|
||||
use f::{self, b};
|
||||
use g::a;
|
||||
use g::{self, b};
|
||||
|
@ -14,3 +14,9 @@ use foo::{a, b, c};
|
||||
pub use foo::{bar, foobar};
|
||||
|
||||
use a::b::c::{d, xxx, yyy, zzz, *};
|
||||
|
||||
// https://github.com/rust-lang/rustfmt/issues/3808
|
||||
use d::{self};
|
||||
use e::{self as foo};
|
||||
use f::{self, b};
|
||||
use g::{self, a, b};
|
||||
|
Loading…
Reference in New Issue
Block a user