pub fn lookup_method(&self,
                         self_ty: Ty<'tcx>,
                         segment: &hir::PathSegment,
                         span: Span,
                         call_expr: &'gcx hir::Expr,
                         self_expr: &'gcx hir::Expr)
                         -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
        debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
               segment.ident,
               self_ty,
               call_expr,
               self_expr);

        let pick = self.lookup_probe(
            span,
            segment.ident,
            self_ty,
            call_expr,
            ProbeScope::TraitsInScope
        )?;

        if let Some(import_id) = pick.import_id {
            let import_def_id = self.tcx.hir().local_def_id(import_id);
            debug!("used_trait_import: {:?}", import_def_id);
            Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
                .unwrap().insert(import_def_id);
        }

        self.tcx.check_stability(pick.item.def_id, Some(call_expr.id), span);

        let result = self.confirm_method(
            span,
            self_expr,
            call_expr,
            self_ty,
            pick.clone(),
            segment,
        );

        if result.illegal_sized_bound {
            // We probe again, taking all traits into account (not only those in scope).
            let candidates =
                match self.lookup_probe(span,
                                        segment.ident,
                                        self_ty,
                                        call_expr,
                                        ProbeScope::AllTraits) {

                    // If we find a different result the caller probably forgot to import a trait.
                    Ok(ref new_pick) if *new_pick != pick => vec![new_pick.item.container.id()],
                    Err(Ambiguity(ref sources)) => {
                        sources.iter()
                               .filter_map(|source| {
                                   match *source {
                                       // Note: this cannot come from an inherent impl,
                                       // because the first probing succeeded.
                                       ImplSource(def) => self.tcx.trait_id_of_impl(def),
                                       TraitSource(_) => None,
                                   }
                               })
                               .collect()
                    }
                    _ => Vec::new(),
                };

            return Err(IllegalSizedBound(candidates));
        }

        Ok(result.callee)
    }
/// Performs method lookup. If lookup is successful, it will return the callee
/// and store an appropriate adjustment for the self-expr. In some cases it may
/// report an error (e.g., invoking the `drop` method).
///
/// # Arguments
///
/// Given a method call like `foo.bar::<T1,...Tn>(...)`:
///
/// * `fcx`:                   the surrounding `FnCtxt` (!)
/// * `span`:                  the span for the method call
/// * `method_name`:           the name of the method being called (`bar`)
/// * `self_ty`:               the (unadjusted) type of the self expression (`foo`)
/// * `supplied_method_types`: the explicit method type parameters, if any (`T1..Tn`)
/// * `self_expr`:             the self expression (`foo`)
Performs method lookup. If lookup is successful, it will return the callee
and store an appropriate adjustment for the self-expr. In some cases it may
report an error .
Performs method lookup . If lookup is successful it will return the callee and store an appropriate adjustment for the self - expr . In some cases it may report an error .
pub fn lookup_method(&self,
                         self_ty: Ty<'tcx>,
                         segment: &hir::PathSegment,
                         span: Span,
                         call_expr: &'gcx hir::Expr,
                         self_expr: &'gcx hir::Expr)
                         -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
        debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})",
               segment.ident,
               self_ty,
               call_expr,
               self_expr);
        let pick = self.lookup_probe(
            span,
            segment.ident,
            self_ty,
            call_expr,
            ProbeScope::TraitsInScope
        )?;
        if let Some(import_id) = pick.import_id {
            let import_def_id = self.tcx.hir().local_def_id(import_id);
            debug!("used_trait_import: {:?}", import_def_id);
            Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
                .unwrap().insert(import_def_id);
        }
        self.tcx.check_stability(pick.item.def_id, Some(call_expr.id), span);
        let result = self.confirm_method(
            span,
            self_expr,
            call_expr,
            self_ty,
            pick.clone(),
            segment,
        );
        if result.illegal_sized_bound {
            // We probe again, taking all traits into account (not only those in scope).
            let candidates =
                match self.lookup_probe(span,
                                        segment.ident,
                                        self_ty,
                                        call_expr,
                                        ProbeScope::AllTraits) {
                    // If we find a different result the caller probably forgot to import a trait.
                    Ok(ref new_pick) if *new_pick != pick => vec![new_pick.item.container.id()],
                    Err(Ambiguity(ref sources)) => {
                        sources.iter()
                               .filter_map(|source| {
                                   match *source {
                                       // Note: this cannot come from an inherent impl,
                                       // because the first probing succeeded.
                                       ImplSource(def) => self.tcx.trait_id_of_impl(def),
                                       TraitSource(_) => None,
                                   }
                               })
                               .collect()
                    }
                    _ => Vec::new(),
                };
            return Err(IllegalSizedBound(candidates));
        }
        Ok(result.callee)
    }
pub fn lookup_method ( & self , self_ty : Ty < ' tcx > , segment : & hir :: PathSegment , span : Span , call_expr : & ' gcx hir :: Expr , self_expr : & ' gcx hir :: Expr ) -> Result < MethodCallee < ' tcx > , MethodError < ' tcx > > { debug ! ( " " segment ident self_ty call_expr self_expr ) ; let pick = self . lookup_probe ( span , segment . ident , self_ty , call_expr , ProbeScope :: TraitsInScope ) ? ; if let Some ( import_id ) = pick . import_id { let import_def_id = self . tcx . hir ( ) . local_def_id ( import_id ) ; debug ! ( " " import_def_id ) ; Lrc :: get_mut ( & mut self . tables . borrow_mut ( ) . used_trait_imports ) . unwrap ( ) . insert ( import_def_id ) ; } self . tcx . check_stability ( pick . item . def_id , Some ( call_expr . id ) , span ) ; let result = self . confirm_method ( span , self_expr , call_expr , self_ty , pick . clone ( ) , segment , ) ; if result . illegal_sized_bound { // We probe again, taking all traits into account (not only those in scope). let candidates = match self . lookup_probe ( span , segment . ident , self_ty , call_expr , ProbeScope :: AllTraits ) { // If we find a different result the caller probably forgot to import a trait. Ok ( ref new_pick ) if * new_pick != pick => vec ! [ new_pick item container id ( ) ] , Err ( Ambiguity ( ref sources ) ) => { sources . iter ( ) . filter_map ( | source | { match * source { // Note: this cannot come from an inherent impl, // because the first probing succeeded. ImplSource ( def ) => self . tcx . trait_id_of_impl ( def ) , TraitSource ( _ ) => None , } } ) . collect ( ) } _ => Vec :: new ( ) , } ; return Err ( IllegalSizedBound ( candidates ) ) ; } Ok ( result . callee ) }
Performs method lookup.
Performs method lookup .
&self
self_ty
Ty<'tcx>
segment
&hir::PathSegment
span
Span
call_expr
&'gcx hir::Expr
self_expr
&'gcx hir::Expr
&self
self_ty
Ty<'tcx>
segment
&hir::PathSegment
span
Span
call_expr
&'gcx hir::Expr
self_expr
&'gcx hir::Expr