Skip to content

Commit fbdcb49

Browse files
committed
Simplify
1 parent 26dd0c4 commit fbdcb49

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
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 {

crates/ide_assists/src/handlers/wrap_return_type_in_result.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
1313
// Wrap the function's return type into Result.
1414
//
1515
// ```
16+
// # //- minicore: result
1617
// fn foo() -> i32$0 { 42i32 }
1718
// ```
1819
// ->

crates/ide_assists/src/tests/generated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,7 @@ fn doctest_wrap_return_type_in_result() {
16001600
check_doc_test(
16011601
"wrap_return_type_in_result",
16021602
r#####"
1603+
//- minicore: result
16031604
fn foo() -> i32$0 { 42i32 }
16041605
"#####,
16051606
r#####"

0 commit comments

Comments
 (0)