mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
fill_match_arms bind pattern implementation
This commit is contained in:
parent
34db4edb80
commit
41f5471f3e
@ -136,8 +136,20 @@ fn is_variant_missing(existing_arms: &mut Vec<MatchArm>, var: &Pat) -> bool {
|
||||
}
|
||||
|
||||
fn does_pat_match_variant(pat: &Pat, var: &Pat) -> bool {
|
||||
let pat_head = pat.syntax().first_child().map(|node| node.text());
|
||||
let var_head = var.syntax().first_child().map(|node| node.text());
|
||||
let first_node_text = |pat: &Pat| pat.syntax().first_child().map(|node| node.text());
|
||||
|
||||
let pat_head = match pat {
|
||||
Pat::BindPat(bind_pat) => {
|
||||
if let Some(p) = bind_pat.pat() {
|
||||
first_node_text(&p)
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pat => first_node_text(pat),
|
||||
};
|
||||
|
||||
let var_head = first_node_text(var);
|
||||
|
||||
pat_head == var_head
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user