fn type_derefs_to_local<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                                  span: Span,
                                  rcvr_ty: Ty<'tcx>,
                                  rcvr_expr: Option<&hir::Expr>) -> bool {
    fn is_local(ty: Ty) -> bool {
        match ty.sty {
            ty::TyEnum(def, _) | ty::TyStruct(def, _) => def.did.is_local(),

            ty::TyTrait(ref tr) => tr.principal_def_id().is_local(),

            ty::TyParam(_) => true,

            // everything else (primitive types etc.) is effectively
            // non-local (there are "edge" cases, e.g. (LocalType,), but
            // the noise from these sort of types is usually just really
            // annoying, rather than any sort of help).
            _ => false
        }
    }

    // This occurs for UFCS desugaring of `T::method`, where there is no
    // receiver expression for the method call, and thus no autoderef.
    if rcvr_expr.is_none() {
        return is_local(fcx.resolve_type_vars_if_possible(rcvr_ty));
    }

    check::autoderef(fcx, span, rcvr_ty, None,
                     check::UnresolvedTypeAction::Ignore, ty::NoPreference,
                     |ty, _| {
        if is_local(ty) {
            Some(())
        } else {
            None
        }
    }).2.is_some()
}
/// Checks whether there is a local type somewhere in the chain of
/// autoderefs of `rcvr_ty`.
Checks whether there is a local type somewhere in the chain of
autoderefs of `rcvr_ty`.
Checks whether there is a local type somewhere in the chain of autoderefs of ` rcvr_ty ` .
fn type_derefs_to_local<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                                  span: Span,
                                  rcvr_ty: Ty<'tcx>,
                                  rcvr_expr: Option<&hir::Expr>) -> bool {
    fn is_local(ty: Ty) -> bool {
        match ty.sty {
            ty::TyEnum(def, _) | ty::TyStruct(def, _) => def.did.is_local(),
            ty::TyTrait(ref tr) => tr.principal_def_id().is_local(),
            ty::TyParam(_) => true,
            // everything else (primitive types etc.) is effectively
            // non-local (there are "edge" cases, e.g. (LocalType,), but
            // the noise from these sort of types is usually just really
            // annoying, rather than any sort of help).
            _ => false
        }
    }
    // This occurs for UFCS desugaring of `T::method`, where there is no
    // receiver expression for the method call, and thus no autoderef.
    if rcvr_expr.is_none() {
        return is_local(fcx.resolve_type_vars_if_possible(rcvr_ty));
    }
    check::autoderef(fcx, span, rcvr_ty, None,
                     check::UnresolvedTypeAction::Ignore, ty::NoPreference,
                     |ty, _| {
        if is_local(ty) {
            Some(())
        } else {
            None
        }
    }).2.is_some()
}
fn type_derefs_to_local < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > , span : Span , rcvr_ty : Ty < ' tcx > , rcvr_expr : Option < & hir :: Expr > ) -> bool { fn is_local ( ty : Ty ) -> bool { match ty . sty { ty :: TyEnum ( def , _ ) | ty :: TyStruct ( def , _ ) => def . did . is_local ( ) , ty :: TyTrait ( ref tr ) => tr . principal_def_id ( ) . is_local ( ) , ty :: TyParam ( _ ) => true , // everything else (primitive types etc.) is effectively // non-local (there are "edge" cases, e.g. (LocalType,), but // the noise from these sort of types is usually just really // annoying, rather than any sort of help). _ => false } } // This occurs for UFCS desugaring of `T::method`, where there is no // receiver expression for the method call, and thus no autoderef. if rcvr_expr . is_none ( ) { return is_local ( fcx . resolve_type_vars_if_possible ( rcvr_ty ) ) ; } check :: autoderef ( fcx , span , rcvr_ty , None , check :: UnresolvedTypeAction :: Ignore , ty :: NoPreference , | ty , _ | { if is_local ( ty ) { Some ( ( ) ) } else { None } } ) . 2 . is_some ( ) }
Checks whether there is a local type somewhere in the chain of
autoderefs of `rcvr_ty`.
Checks whether there is a local type somewhere in the chain of autoderefs of ` rcvr_ty ` .
fcx
&FnCtxt<'a, 'tcx>
span
Span
rcvr_ty
Ty<'tcx>
rcvr_expr
Option<&hir::Expr>
fcx
&FnCtxt<'a, 'tcx>
span
Span
rcvr_ty
Ty<'tcx>
rcvr_expr
Option<&hir::Expr>