mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
style: clean up magic number for finding pattern usages
This commit is contained in:
parent
2611fbf623
commit
9ba8dbc902
@ -129,16 +129,12 @@ fn replace_usages(
|
|||||||
let pats = name
|
let pats = name
|
||||||
.syntax()
|
.syntax()
|
||||||
.ancestors()
|
.ancestors()
|
||||||
.nth(5)
|
.find(|node| {
|
||||||
.and_then(node_to_pats)
|
ast::CallExpr::can_cast(node.kind())
|
||||||
.or_else(|| {
|
|| ast::MethodCallExpr::can_cast(node.kind())
|
||||||
cov_mark::hit!(replace_method_usage);
|
|
||||||
|
|
||||||
name.syntax()
|
|
||||||
.parent()
|
|
||||||
.filter(|node| ast::MethodCallExpr::can_cast(node.kind()))
|
|
||||||
.and_then(|node| node.parent().and_then(node_to_pats))
|
|
||||||
})
|
})
|
||||||
|
.and_then(|node| node.parent())
|
||||||
|
.and_then(node_to_pats)
|
||||||
.unwrap_or(Vec::new());
|
.unwrap_or(Vec::new());
|
||||||
|
|
||||||
let tuple_pats = pats.iter().filter_map(|pat| match pat {
|
let tuple_pats = pats.iter().filter_map(|pat| match pat {
|
||||||
@ -387,7 +383,6 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn method_usage() {
|
fn method_usage() {
|
||||||
cov_mark::check!(replace_method_usage);
|
|
||||||
check_assist(
|
check_assist(
|
||||||
convert_tuple_return_type_to_struct,
|
convert_tuple_return_type_to_struct,
|
||||||
r#"
|
r#"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user