diff options
| author | gaurikholkar <f2013002@goa.bits-pilani.ac.in> | 2017-08-20 17:55:07 +0530 |
|---|---|---|
| committer | gaurikholkar <f2013002@goa.bits-pilani.ac.in> | 2017-08-20 17:55:07 +0530 |
| commit | 2ff1734c612094f009a1eff0c2f0bc58baa46a34 (patch) | |
| tree | fddc97ef46a6ba18d2839eb4547ea350f9b67bc6 | |
| parent | 8b89f3168d593e4bfd3babc0a37b624e9593aec1 (diff) | |
| download | rust-2ff1734c612094f009a1eff0c2f0bc58baa46a34.tar.gz rust-2ff1734c612094f009a1eff0c2f0bc58baa46a34.zip | |
code review fixes
| -rw-r--r-- | src/librustc/infer/error_reporting/anon_anon_conflict.rs | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/src/librustc/infer/error_reporting/anon_anon_conflict.rs b/src/librustc/infer/error_reporting/anon_anon_conflict.rs index 4a2b751f5e8..1432294f67f 100644 --- a/src/librustc/infer/error_reporting/anon_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/anon_anon_conflict.rs @@ -131,42 +131,29 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { let ret_ty = self.tcx.type_of(def_id); if let ty::TyFnDef(_, _) = ret_ty.sty { - if let hir_map::NodeItem(it) = self.tcx.hir.get(node_id) { - if let hir::ItemFn(ref fndecl, _, _, _, _, _) = it.node { - return fndecl - .inputs - .iter() - .filter_map(|arg| { - self.find_component_for_bound_region(&**arg, - br) - }) - .next(); - } - } else if let hir_map::NodeTraitItem(it) = self.tcx.hir.get(node_id) { - if let hir::TraitItemKind::Method(ref fndecl, _) = it.node { - return fndecl - .decl - .inputs - .iter() - .filter_map(|arg| { - self.find_component_for_bound_region(&**arg, - br) - }) - .next(); - } - } else if let hir_map::NodeImplItem(it) = self.tcx.hir.get(node_id) { - if let hir::ImplItemKind::Method(ref fndecl, _) = it.node { - return fndecl - .decl - .inputs - .iter() - .filter_map(|arg| { - self.find_component_for_bound_region(&**arg, - br) - }) - .next(); - } - } + let inputs: &[_] = + match self.tcx.hir.get(node_id) { + hir_map::NodeItem(&hir::Item { + node: hir::ItemFn(ref fndecl, ..), .. + }) => &fndecl.inputs, + hir_map::NodeTraitItem(&hir::TraitItem { + node: hir::TraitItemKind::Method(ref fndecl, ..), + .. + }) => &fndecl.decl.inputs, + hir_map::NodeImplItem(&hir::ImplItem { + node: hir::ImplItemKind::Method(ref fndecl, ..), + .. + }) => &fndecl.decl.inputs, + + _ => &[], + }; + + return inputs + .iter() + .filter_map(|arg| { + self.find_component_for_bound_region(&**arg, br) + }) + .next(); } } } |
