mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-26 03:45:04 +00:00
formatting
This commit is contained in:
parent
bd77d8c3d1
commit
7bc89f2542
1 changed files with 20 additions and 14 deletions
|
@ -1,8 +1,8 @@
|
|||
use hir::TypeInfo;
|
||||
use std::{iter::successors, collections::HashMap};
|
||||
use std::{collections::HashMap, iter::successors};
|
||||
use syntax::{
|
||||
algo::neighbor,
|
||||
ast::{self, AstNode, Pat, MatchArm, HasName},
|
||||
ast::{self, AstNode, HasName, MatchArm, Pat},
|
||||
Direction,
|
||||
};
|
||||
|
||||
|
@ -108,7 +108,9 @@ fn are_same_types(
|
|||
|
||||
let unwrapped_current_arm_type = current_arm_type.unwrap().1;
|
||||
|
||||
if let (Some(other_arm_type), Some(current_arm_type)) = (other_arm_type_entry.1, unwrapped_current_arm_type) {
|
||||
if let (Some(other_arm_type), Some(current_arm_type)) =
|
||||
(other_arm_type_entry.1, unwrapped_current_arm_type)
|
||||
{
|
||||
if other_arm_type.original != current_arm_type.original {
|
||||
return false;
|
||||
}
|
||||
|
@ -121,27 +123,31 @@ fn are_same_types(
|
|||
fn get_arm_types(context: &AssistContext, arm: &MatchArm) -> HashMap<String, Option<TypeInfo>> {
|
||||
let mut mapping: HashMap<String, Option<TypeInfo>> = HashMap::new();
|
||||
|
||||
fn recurse(pat: &Option<Pat>, map: &mut HashMap<String, Option<TypeInfo>>, ctx: &AssistContext) {
|
||||
fn recurse(
|
||||
pat: &Option<Pat>,
|
||||
map: &mut HashMap<String, Option<TypeInfo>>,
|
||||
ctx: &AssistContext,
|
||||
) {
|
||||
if let Some(local_pat) = pat {
|
||||
match pat {
|
||||
Some(ast::Pat::TupleStructPat(tuple)) => {
|
||||
for field in tuple.fields() {
|
||||
recurse(&Some(field), map, ctx);
|
||||
}
|
||||
},
|
||||
}
|
||||
Some(ast::Pat::RecordPat(record)) => {
|
||||
if let Some(field_list) = record.record_pat_field_list() {
|
||||
for field in field_list.fields() {
|
||||
recurse(&field.pat(), map, ctx);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Some(ast::Pat::IdentPat(ident_pat)) => {
|
||||
if let Some(name) = ident_pat.name() {
|
||||
let pat_type = ctx.sema.type_of_pat(local_pat);
|
||||
map.insert(name.text().to_string(), pat_type);
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -572,7 +578,7 @@ fn func(x: MyEnum) {
|
|||
MyEnum::Crawl { a, b } => "",
|
||||
};
|
||||
}
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue