pub fn check_expr(tcx: &ty::ctxt, e: &hir::Expr,
                  cb: &mut FnMut(DefId, Span, &Option<&Stability>)) {
    let span;
    let id = match e.node {
        hir::ExprMethodCall(i, _, _) => {
            span = i.span;
            let method_call = ty::MethodCall::expr(e.id);
            tcx.tables.borrow().method_map[&method_call].def_id
        }
        hir::ExprField(ref base_e, ref field) => {
            span = field.span;
            match tcx.expr_ty_adjusted(base_e).sty {
                ty::TyStruct(def, _) => def.struct_variant().field_named(field.node.name).did,
                _ => tcx.sess.span_bug(e.span,
                                       "stability::check_expr: named field access on non-struct")
            }
        }
        hir::ExprTupField(ref base_e, ref field) => {
            span = field.span;
            match tcx.expr_ty_adjusted(base_e).sty {
                ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
                ty::TyTuple(..) => return,
                _ => tcx.sess.span_bug(e.span,
                                       "stability::check_expr: unnamed field access on \
                                        something other than a tuple or struct")
            }
        }
        hir::ExprStruct(_, ref expr_fields, _) => {
            let type_ = tcx.expr_ty(e);
            match type_.sty {
                ty::TyStruct(def, _) => {
                    // check the stability of each field that appears
                    // in the construction expression.
                    for field in expr_fields {
                        let did = def.struct_variant()
                            .field_named(field.ident.node.name)
                            .did;
                        maybe_do_stability_check(tcx, did, field.span, cb);
                    }

                    // we're done.
                    return
                }
                // we don't look at stability attributes on
                // struct-like enums (yet...), but it's definitely not
                // a bug to have construct one.
                ty::TyEnum(..) => return,
                _ => {
                    tcx.sess.span_bug(e.span,
                                      &format!("stability::check_expr: struct construction \
                                                of non-struct, type {:?}",
                                               type_));
                }
            }
        }
        _ => return
    };

    maybe_do_stability_check(tcx, id, span, cb);
}
/// Helper for discovering nodes to check for stability
Helper for discovering nodes to check for stability
Helper for discovering nodes to check for stability
pub fn check_expr(tcx: &ty::ctxt, e: &hir::Expr,
                  cb: &mut FnMut(DefId, Span, &Option<&Stability>)) {
    let span;
    let id = match e.node {
        hir::ExprMethodCall(i, _, _) => {
            span = i.span;
            let method_call = ty::MethodCall::expr(e.id);
            tcx.tables.borrow().method_map[&method_call].def_id
        }
        hir::ExprField(ref base_e, ref field) => {
            span = field.span;
            match tcx.expr_ty_adjusted(base_e).sty {
                ty::TyStruct(def, _) => def.struct_variant().field_named(field.node.name).did,
                _ => tcx.sess.span_bug(e.span,
                                       "stability::check_expr: named field access on non-struct")
            }
        }
        hir::ExprTupField(ref base_e, ref field) => {
            span = field.span;
            match tcx.expr_ty_adjusted(base_e).sty {
                ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
                ty::TyTuple(..) => return,
                _ => tcx.sess.span_bug(e.span,
                                       "stability::check_expr: unnamed field access on \
                                        something other than a tuple or struct")
            }
        }
        hir::ExprStruct(_, ref expr_fields, _) => {
            let type_ = tcx.expr_ty(e);
            match type_.sty {
                ty::TyStruct(def, _) => {
                    // check the stability of each field that appears
                    // in the construction expression.
                    for field in expr_fields {
                        let did = def.struct_variant()
                            .field_named(field.ident.node.name)
                            .did;
                        maybe_do_stability_check(tcx, did, field.span, cb);
                    }
                    // we're done.
                    return
                }
                // we don't look at stability attributes on
                // struct-like enums (yet...), but it's definitely not
                // a bug to have construct one.
                ty::TyEnum(..) => return,
                _ => {
                    tcx.sess.span_bug(e.span,
                                      &format!("stability::check_expr: struct construction \
                                                of non-struct, type {:?}",
                                               type_));
                }
            }
        }
        _ => return
    };
    maybe_do_stability_check(tcx, id, span, cb);
}
pub fn check_expr ( tcx : & ty :: ctxt , e : & hir :: Expr , cb : & mut FnMut ( DefId , Span , & Option < & Stability > ) ) { let span ; let id = match e . node { hir :: ExprMethodCall ( i , _ , _ ) => { span = i . span ; let method_call = ty :: MethodCall :: expr ( e . id ) ; tcx . tables . borrow ( ) . method_map [ & method_call ] . def_id } hir :: ExprField ( ref base_e , ref field ) => { span = field . span ; match tcx . expr_ty_adjusted ( base_e ) . sty { ty :: TyStruct ( def , _ ) => def . struct_variant ( ) . field_named ( field . node . name ) . did , _ => tcx . sess . span_bug ( e . span , " " ) } } hir :: ExprTupField ( ref base_e , ref field ) => { span = field . span ; match tcx . expr_ty_adjusted ( base_e ) . sty { ty :: TyStruct ( def , _ ) => def . struct_variant ( ) . fields [ field . node ] . did , ty :: TyTuple ( .. ) => return , _ => tcx . sess . span_bug ( e . span , " \
 " ) } } hir :: ExprStruct ( _ , ref expr_fields , _ ) => { let type_ = tcx . expr_ty ( e ) ; match type_ . sty { ty :: TyStruct ( def , _ ) => { // check the stability of each field that appears // in the construction expression. for field in expr_fields { let did = def . struct_variant ( ) . field_named ( field . ident . node . name ) . did ; maybe_do_stability_check ( tcx , did , field . span , cb ) ; } // we're done. return } // we don't look at stability attributes on // struct-like enums (yet...), but it's definitely not // a bug to have construct one. ty :: TyEnum ( .. ) => return , _ => { tcx . sess . span_bug ( e . span , & format ! ( " \
 " type_ ) ) ; } } } _ => return } ; maybe_do_stability_check ( tcx , id , span , cb ) ; }
Helper for discovering nodes to check for stability
Helper for discovering nodes to check for stability
tcx
&ty::ctxt
e
&hir::Expr
cb
&mut FnMut(DefId, Span, &Option<&Stability>)
tcx
&ty::ctxt
e
&hir::Expr
cb
&mut FnMut(DefId, Span, &Option<&Stability>)