remove big match
This commit is contained in:
parent
48f5f01e8b
commit
8f5585ac00
|
@ -524,74 +524,59 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
return (false, None);
|
return (false, None);
|
||||||
}
|
}
|
||||||
let hir_map = self.infcx.tcx.hir();
|
let hir_map = self.infcx.tcx.hir();
|
||||||
let my_hir = hir_map.local_def_id_to_hir_id(
|
let my_def = self.body.source.def_id();
|
||||||
self.body.source.def_id().as_local().unwrap(),
|
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
|
||||||
);
|
let td = if let Some(a) = self.infcx.tcx.impl_of_method(my_def).and_then(|x| {
|
||||||
match hir_map.find(hir_map.get_parent_node(my_hir)) {
|
self.infcx.tcx.trait_id_of_impl(x)
|
||||||
Some(Node::Item(hir::Item {
|
}) {
|
||||||
kind:
|
a
|
||||||
hir::ItemKind::Impl(hir::Impl {
|
} else {
|
||||||
of_trait:
|
return (false, None);
|
||||||
Some(hir::TraitRef {
|
};
|
||||||
path:
|
(true, td.as_local().and_then(|tld| {
|
||||||
hir::Path {
|
let h = hir_map.local_def_id_to_hir_id(tld);
|
||||||
res:
|
match hir_map.find(h) {
|
||||||
hir::def::Res::Def(_, td),
|
Some(Node::Item(hir::Item {
|
||||||
..
|
kind: hir::ItemKind::Trait(
|
||||||
},
|
_, _, _, _,
|
||||||
..
|
items
|
||||||
}),
|
),
|
||||||
..
|
..
|
||||||
}),
|
})) => {
|
||||||
..
|
let mut f_in_trait_opt = None;
|
||||||
})) => {
|
for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
|
||||||
(true, td.as_local().and_then(|tld| {
|
let hi = fi.hir_id();
|
||||||
let h = hir_map.local_def_id_to_hir_id(tld);
|
if !matches!(k, hir::AssocItemKind::Fn { .. }) {
|
||||||
match hir_map.find(h) {
|
continue;
|
||||||
Some(Node::Item(hir::Item {
|
|
||||||
kind: hir::ItemKind::Trait(
|
|
||||||
_, _, _, _,
|
|
||||||
items
|
|
||||||
),
|
|
||||||
..
|
|
||||||
})) => {
|
|
||||||
let mut f_in_trait_opt = None;
|
|
||||||
for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
|
|
||||||
let hi = fi.hir_id();
|
|
||||||
if !matches!(k, hir::AssocItemKind::Fn { .. }) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if hir_map.name(hi) != hir_map.name(my_hir) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
f_in_trait_opt = Some(hi);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
f_in_trait_opt.and_then(|f_in_trait| {
|
|
||||||
match hir_map.find(f_in_trait) {
|
|
||||||
Some(Node::TraitItem(hir::TraitItem {
|
|
||||||
kind: hir::TraitItemKind::Fn(hir::FnSig {
|
|
||||||
decl: hir::FnDecl {
|
|
||||||
inputs,
|
|
||||||
..
|
|
||||||
},
|
|
||||||
..
|
|
||||||
}, _),
|
|
||||||
..
|
|
||||||
})) => {
|
|
||||||
let hir::Ty { span, .. } = inputs[local.index() - 1];
|
|
||||||
Some(span)
|
|
||||||
},
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => None
|
if hir_map.name(hi) != hir_map.name(my_hir) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
f_in_trait_opt = Some(hi);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}))
|
f_in_trait_opt.and_then(|f_in_trait| {
|
||||||
|
match hir_map.find(f_in_trait) {
|
||||||
|
Some(Node::TraitItem(hir::TraitItem {
|
||||||
|
kind: hir::TraitItemKind::Fn(hir::FnSig {
|
||||||
|
decl: hir::FnDecl {
|
||||||
|
inputs,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
..
|
||||||
|
}, _),
|
||||||
|
..
|
||||||
|
})) => {
|
||||||
|
let hir::Ty { span, .. } = inputs[local.index() - 1];
|
||||||
|
Some(span)
|
||||||
|
},
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_ => None
|
||||||
}
|
}
|
||||||
_ => (false, None),
|
}))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// point to span of upvar making closure call require mutable borrow
|
// point to span of upvar making closure call require mutable borrow
|
||||||
|
|
Loading…
Reference in a new issue