Skip to content

Commit

Permalink
Only query associated_items once
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Jan 22, 2021
1 parent ee639de commit aa4f583
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,14 +921,13 @@ pub(super) fn check_impl_items_against_trait<'tcx>(

// Locate trait definition and items
let trait_def = tcx.trait_def(impl_trait_ref.def_id);

let impl_items = impl_item_refs.iter().map(|iiref| tcx.hir().impl_item(iiref.id));
let associated_items = tcx.associated_items(impl_trait_ref.def_id);

// Check existing impl methods to see if they are both present in trait
// and compatible with trait signature
for impl_item in impl_items {
let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.hir_id));
let associated_items = tcx.associated_items(impl_trait_ref.def_id);

let mut items = associated_items.filter_by_name(tcx, ty_impl_item.ident, impl_trait_ref.def_id);

Expand Down Expand Up @@ -1010,7 +1009,7 @@ pub(super) fn check_impl_items_against_trait<'tcx>(

if let Ok(ancestors) = trait_def.ancestors(tcx, impl_id.to_def_id()) {
let impl_span = tcx.sess.source_map().guess_head_span(full_impl_span);

// Check for missing items from trait
let mut missing_items = Vec::new();
for trait_item in tcx.associated_items(impl_trait_ref.def_id).in_definition_order() {
Expand Down

0 comments on commit aa4f583

Please sign in to comment.