Skip to content

Commit 96074f6

Browse files
bors[bot]Veykril
andauthored
Merge #9467
9467: internal: wrap_return_type_in_result works on the HIR r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 3770fce + fbdcb49 commit 96074f6

File tree

4 files changed

+99
-107
lines changed

4 files changed

+99
-107
lines changed

crates/ide_assists/src/handlers/unmerge_use.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use ast::make;
2+
use itertools::Itertools;
13
use syntax::{
24
ast::{self, VisibilityOwner},
35
ted::{self, Position},
@@ -42,9 +44,9 @@ pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
4244
"Unmerge use",
4345
target,
4446
|builder| {
45-
let new_use = ast::make::use_(
47+
let new_use = make::use_(
4648
use_.visibility(),
47-
ast::make::use_tree(
49+
make::use_tree(
4850
path,
4951
tree.use_tree_list(),
5052
tree.rename(),
@@ -62,17 +64,14 @@ pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
6264
}
6365

6466
fn resolve_full_path(tree: &ast::UseTree) -> Option<ast::Path> {
65-
let mut paths = tree
67+
let paths = tree
6668
.syntax()
6769
.ancestors()
68-
.take_while(|n| n.kind() != SyntaxKind::USE_KW)
70+
.take_while(|n| n.kind() != SyntaxKind::USE)
6971
.filter_map(ast::UseTree::cast)
7072
.filter_map(|t| t.path());
7173

72-
let mut final_path = paths.next()?;
73-
for path in paths {
74-
final_path = ast::make::path_concat(path, final_path)
75-
}
74+
let final_path = paths.fold1(|prev, next| make::path_concat(next, prev))?;
7675
if final_path.segment().map_or(false, |it| it.self_token().is_some()) {
7776
final_path.qualifier()
7877
} else {

0 commit comments

Comments
 (0)