Skip to content

Commit 2ff1734

Browse files
committed
code review fixes
1 parent 8b89f31 commit 2ff1734

File tree

1 file changed

+23
-36
lines changed

1 file changed

+23
-36
lines changed

src/librustc/infer/error_reporting/anon_anon_conflict.rs

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -131,42 +131,29 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
131131
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
132132
let ret_ty = self.tcx.type_of(def_id);
133133
if let ty::TyFnDef(_, _) = ret_ty.sty {
134-
if let hir_map::NodeItem(it) = self.tcx.hir.get(node_id) {
135-
if let hir::ItemFn(ref fndecl, _, _, _, _, _) = it.node {
136-
return fndecl
137-
.inputs
138-
.iter()
139-
.filter_map(|arg| {
140-
self.find_component_for_bound_region(&**arg,
141-
br)
142-
})
143-
.next();
144-
}
145-
} else if let hir_map::NodeTraitItem(it) = self.tcx.hir.get(node_id) {
146-
if let hir::TraitItemKind::Method(ref fndecl, _) = it.node {
147-
return fndecl
148-
.decl
149-
.inputs
150-
.iter()
151-
.filter_map(|arg| {
152-
self.find_component_for_bound_region(&**arg,
153-
br)
154-
})
155-
.next();
156-
}
157-
} else if let hir_map::NodeImplItem(it) = self.tcx.hir.get(node_id) {
158-
if let hir::ImplItemKind::Method(ref fndecl, _) = it.node {
159-
return fndecl
160-
.decl
161-
.inputs
162-
.iter()
163-
.filter_map(|arg| {
164-
self.find_component_for_bound_region(&**arg,
165-
br)
166-
})
167-
.next();
168-
}
169-
}
134+
let inputs: &[_] =
135+
match self.tcx.hir.get(node_id) {
136+
hir_map::NodeItem(&hir::Item {
137+
node: hir::ItemFn(ref fndecl, ..), ..
138+
}) => &fndecl.inputs,
139+
hir_map::NodeTraitItem(&hir::TraitItem {
140+
node: hir::TraitItemKind::Method(ref fndecl, ..),
141+
..
142+
}) => &fndecl.decl.inputs,
143+
hir_map::NodeImplItem(&hir::ImplItem {
144+
node: hir::ImplItemKind::Method(ref fndecl, ..),
145+
..
146+
}) => &fndecl.decl.inputs,
147+
148+
_ => &[],
149+
};
150+
151+
return inputs
152+
.iter()
153+
.filter_map(|arg| {
154+
self.find_component_for_bound_region(&**arg, br)
155+
})
156+
.next();
170157
}
171158
}
172159
}

0 commit comments

Comments
 (0)