9262: fix: Don't keep a trailing `self` token in import paths after `unmerge_use` r=Veykril a=Veykril

Fixes #9213
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-06-14 11:57:20 +00:00 committed by GitHub
commit 278ae172df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,11 @@ fn resolve_full_path(tree: &ast::UseTree) -> Option<ast::Path> {
for path in paths {
final_path = ast::make::path_concat(path, final_path)
}
Some(final_path)
if final_path.segment().map_or(false, |it| it.self_token().is_some()) {
final_path.qualifier()
} else {
Some(final_path)
}
}
#[cfg(test)]
@ -223,4 +227,14 @@ pub use std::fmt::Display;
",
);
}
#[test]
fn unmerge_use_item_on_self() {
check_assist(
unmerge_use,
r"use std::process::{Command, self$0};",
r"use std::process::{Command};
use std::process;",
);
}
}