or-patterns: liveness/visit_arm
: remove top_pats_hack
.
This commit is contained in:
parent
9d1c3c96e7
commit
cc5fe6d520
1 changed files with 11 additions and 18 deletions
|
@ -404,7 +404,7 @@ fn visit_fn<'tcx>(
|
||||||
lsets.warn_about_unused_args(body, entry_ln);
|
lsets.warn_about_unused_args(body, entry_ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
|
fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P<hir::Pat>) {
|
||||||
// For struct patterns, take note of which fields used shorthand
|
// For struct patterns, take note of which fields used shorthand
|
||||||
// (`x` rather than `x: x`).
|
// (`x` rather than `x: x`).
|
||||||
let mut shorthand_field_ids = HirIdSet::default();
|
let mut shorthand_field_ids = HirIdSet::default();
|
||||||
|
@ -412,26 +412,21 @@ fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
|
||||||
pats.push_back(pat);
|
pats.push_back(pat);
|
||||||
while let Some(pat) = pats.pop_front() {
|
while let Some(pat) = pats.pop_front() {
|
||||||
use crate::hir::PatKind::*;
|
use crate::hir::PatKind::*;
|
||||||
match pat.node {
|
match &pat.node {
|
||||||
Binding(_, _, _, ref inner_pat) => {
|
Binding(.., inner_pat) => {
|
||||||
pats.extend(inner_pat.iter());
|
pats.extend(inner_pat.iter());
|
||||||
}
|
}
|
||||||
Struct(_, ref fields, _) => {
|
Struct(_, fields, _) => {
|
||||||
for field in fields {
|
let ids = fields.iter().filter(|f| f.is_shorthand).map(|f| f.pat.hir_id);
|
||||||
if field.is_shorthand {
|
shorthand_field_ids.extend(ids);
|
||||||
shorthand_field_ids.insert(field.pat.hir_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ref(ref inner_pat, _) |
|
Ref(inner_pat, _) | Box(inner_pat) => {
|
||||||
Box(ref inner_pat) => {
|
|
||||||
pats.push_back(inner_pat);
|
pats.push_back(inner_pat);
|
||||||
}
|
}
|
||||||
TupleStruct(_, ref inner_pats, _) |
|
TupleStruct(_, inner_pats, _) | Tuple(inner_pats, _) | Or(inner_pats) => {
|
||||||
Tuple(ref inner_pats, _) => {
|
|
||||||
pats.extend(inner_pats.iter());
|
pats.extend(inner_pats.iter());
|
||||||
}
|
}
|
||||||
Slice(ref pre_pats, ref inner_pat, ref post_pats) => {
|
Slice(pre_pats, inner_pat, post_pats) => {
|
||||||
pats.extend(pre_pats.iter());
|
pats.extend(pre_pats.iter());
|
||||||
pats.extend(inner_pat.iter());
|
pats.extend(inner_pat.iter());
|
||||||
pats.extend(post_pats.iter());
|
pats.extend(post_pats.iter());
|
||||||
|
@ -440,7 +435,7 @@ fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pat.each_binding(|_bm, hir_id, _sp, ident| {
|
pat.each_binding(|_, hir_id, _, ident| {
|
||||||
ir.add_live_node_for_node(hir_id, VarDefNode(ident.span));
|
ir.add_live_node_for_node(hir_id, VarDefNode(ident.span));
|
||||||
ir.add_variable(Local(LocalInfo {
|
ir.add_variable(Local(LocalInfo {
|
||||||
id: hir_id,
|
id: hir_id,
|
||||||
|
@ -456,9 +451,7 @@ fn visit_local<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) {
|
fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) {
|
||||||
for pat in arm.top_pats_hack() {
|
add_from_pat(ir, &arm.pat);
|
||||||
add_from_pat(ir, pat);
|
|
||||||
}
|
|
||||||
intravisit::walk_arm(ir, arm);
|
intravisit::walk_arm(ir, arm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue