Skip to content
Permalink
Browse files

Replace Iterator::find calls with Iterator::any when better

  • Loading branch information
GuillaumeGomez committed Nov 26, 2019
1 parent 4ab8aa3 commit b91a6fcd5d82da723d7af1bf6790fd93a7741e93
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/librustdoc/passes/collect_intra_doc_links.rs
@@ -84,17 +84,16 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
let ty_res = ty_res.map_id(|_| panic!("unexpected node_id"));
match ty_res {
Res::Def(DefKind::Enum, did) => {
let item = cx.tcx.inherent_impls(did)
.iter()
.flat_map(|imp| cx.tcx.associated_items(*imp))
.find(|item| item.ident.name == variant_name);
if item.is_some() {
if cx.tcx.inherent_impls(did)
.iter()
.flat_map(|imp| cx.tcx.associated_items(*imp))
.any(|item| item.ident.name == variant_name) {
return Err(());
}
match cx.tcx.type_of(did).kind {
ty::Adt(def, _) if def.is_enum() => {
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,
Some(format!("variant.{}.field.{}",
variant_name, variant_field_name))))

0 comments on commit b91a6fc

Please sign in to comment.
You can’t perform that action at this time.