Skip to content

Commit 9ba8dbc

Browse files
committed
style: clean up magic number for finding pattern usages
1 parent 2611fbf commit 9ba8dbc

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

crates/ide-assists/src/handlers/convert_tuple_return_type_to_struct.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,12 @@ fn replace_usages(
129129
let pats = name
130130
.syntax()
131131
.ancestors()
132-
.nth(5)
133-
.and_then(node_to_pats)
134-
.or_else(|| {
135-
cov_mark::hit!(replace_method_usage);
136-
137-
name.syntax()
138-
.parent()
139-
.filter(|node| ast::MethodCallExpr::can_cast(node.kind()))
140-
.and_then(|node| node.parent().and_then(node_to_pats))
132+
.find(|node| {
133+
ast::CallExpr::can_cast(node.kind())
134+
|| ast::MethodCallExpr::can_cast(node.kind())
141135
})
136+
.and_then(|node| node.parent())
137+
.and_then(node_to_pats)
142138
.unwrap_or(Vec::new());
143139

144140
let tuple_pats = pats.iter().filter_map(|pat| match pat {
@@ -387,7 +383,6 @@ fn main() {
387383

388384
#[test]
389385
fn method_usage() {
390-
cov_mark::check!(replace_method_usage);
391386
check_assist(
392387
convert_tuple_return_type_to_struct,
393388
r#"

0 commit comments

Comments
 (0)