Skip to content

Commit

Permalink
call impl_or_trait_item() instead instead of associated_item()
Browse files Browse the repository at this point in the history
The older method was not aware of the return type possibility.
  • Loading branch information
nikomatsakis authored and GuillaumeGomez committed Dec 20, 2016
1 parent 044b07d commit 88e9430
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/librustc_typeck/check/method/probe.rs
Expand Up @@ -468,7 +468,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {

debug!("assemble_inherent_impl_probe {:?}", impl_def_id);

let item = match self.associated_item(impl_def_id) {
let item = match self.impl_or_trait_item(impl_def_id) {
Some(m) => m,
None => {
return;
Expand Down Expand Up @@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {

let tcx = self.tcx;
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
let item = match self.associated_item(bound_trait_ref.def_id()) {
let item = match self.impl_or_trait_item(bound_trait_ref.def_id()) {
Some(v) => v,
None => {
continue;
Expand Down Expand Up @@ -1350,15 +1350,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
self.tcx.erase_late_bound_regions(value)
}

/// Find item with name `item_name` defined in impl/trait `def_id`
/// and return it, or `None`, if no such item was defined there.
fn associated_item(&self, def_id: DefId) -> Option<ty::AssociatedItem> {
match self.looking_for {
LookingFor::MethodName(item_name) => self.fcx.associated_item(def_id, item_name),
_ => None,
}
}

/// Find the method with the appropriate name (or return type, as the case may be).
fn impl_or_trait_item(&self, def_id: DefId) -> Option<ty::AssociatedItem> {
match self.looking_for {
LookingFor::MethodName(name) => {
Expand Down

0 comments on commit 88e9430

Please sign in to comment.