/// Tests whether this is the AST for a reference to the type
/// parameter with id `param_id`. We use this so as to avoid running
/// `ast_ty_to_ty`, because we want to avoid triggering an all-out
/// conversion of the type to avoid inducing unnecessary cycles.
Tests whether this is the AST for a reference to the type
parameter with id `param_id`. We use this so as to avoid running
`ast_ty_to_ty`, because we want to avoid triggering an all-out
conversion of the type to avoid inducing unnecessary cycles.
Tests whether this is the AST for a reference to the type parameter with id ` param_id ` . We use this so as to avoid running ` ast_ty_to_ty ` because we want to avoid triggering an all - out conversion of the type to avoid inducing unnecessary cycles .
fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                      ast_ty: &hir::Ty,
                      param_id: ast::NodeId)
                      -> bool
{
    if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node {
        match path.def {
            Def::SelfTy(Some(def_id), None) |
            Def::TyParam(def_id) => {
                def_id == tcx.hir.local_def_id(param_id)
            }
            _ => false
        }
    } else {
        false
    }
}
fn is_param < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , ast_ty : & hir :: Ty , param_id : ast :: NodeId ) -> bool { if let hir :: TyKind :: Path ( hir :: QPath :: Resolved ( None , ref path ) ) = ast_ty . node { match path . def { Def :: SelfTy ( Some ( def_id ) , None ) | Def :: TyParam ( def_id ) => { def_id == tcx . hir . local_def_id ( param_id ) } _ => false } } else { false } }
Tests whether this is the AST for a reference to the type
parameter with id `param_id`.
Tests whether this is the AST for a reference to the type parameter with id ` param_id ` .
tcx
TyCtxt<'a, 'tcx, 'tcx>
ast_ty
&hir::Ty
param_id
ast::NodeId