Skip to content

Commit

Permalink
Replace Iterator::find calls with Iterator::any when better
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 27, 2019
1 parent 4ab8aa3 commit b91a6fc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,17 +84,16 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
let ty_res = ty_res.map_id(|_| panic!("unexpected node_id")); let ty_res = ty_res.map_id(|_| panic!("unexpected node_id"));
match ty_res { match ty_res {
Res::Def(DefKind::Enum, did) => { Res::Def(DefKind::Enum, did) => {
let item = cx.tcx.inherent_impls(did) if cx.tcx.inherent_impls(did)
.iter() .iter()
.flat_map(|imp| cx.tcx.associated_items(*imp)) .flat_map(|imp| cx.tcx.associated_items(*imp))
.find(|item| item.ident.name == variant_name); .any(|item| item.ident.name == variant_name) {
if item.is_some() {
return Err(()); return Err(());
} }
match cx.tcx.type_of(did).kind { match cx.tcx.type_of(did).kind {
ty::Adt(def, _) if def.is_enum() => { ty::Adt(def, _) if def.is_enum() => {
if def.all_fields() if def.all_fields()
.find(|item| item.ident.name == variant_field_name).is_some() { .any(|item| item.ident.name == variant_field_name) {
Ok((ty_res, Ok((ty_res,
Some(format!("variant.{}.field.{}", Some(format!("variant.{}.field.{}",
variant_name, variant_field_name)))) variant_name, variant_field_name))))
Expand Down

0 comments on commit b91a6fc

Please sign in to comment.