pub fn check_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool,
                  cb: &mut FnMut(DefId, Span, &Option<&Stability>)) {
    match item.node {
        hir::ItemExternCrate(_) => {
            // compiler-generated `extern crate` items have a dummy span.
            if item.span == DUMMY_SP { return }

            let cnum = match tcx.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
                Some(cnum) => cnum,
                None => return,
            };
            let id = DefId { krate: cnum, node: ast::CRATE_NODE_ID };
            maybe_do_stability_check(tcx, id, item.span, cb);
        }

        // For implementations of traits, check the stability of each item
        // individually as it's possible to have a stable trait with unstable
        // items.
        hir::ItemImpl(_, _, _, Some(ref t), _, ref impl_items) => {
            let trait_did = tcx.def_map.borrow().get(&t.ref_id).unwrap().def_id();
            let trait_items = tcx.trait_items(trait_did);

            for impl_item in impl_items {
                let item = trait_items.iter().find(|item| {
                    item.name() == impl_item.ident.name
                }).unwrap();
                if warn_about_defns {
                    maybe_do_stability_check(tcx, item.def_id(), impl_item.span, cb);
                }
            }
        }

        _ => (/* pass */)
    }
}
/// 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_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool,
                  cb: &mut FnMut(DefId, Span, &Option<&Stability>)) {
    match item.node {
        hir::ItemExternCrate(_) => {
            // compiler-generated `extern crate` items have a dummy span.
            if item.span == DUMMY_SP { return }
            let cnum = match tcx.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
                Some(cnum) => cnum,
                None => return,
            };
            let id = DefId { krate: cnum, node: ast::CRATE_NODE_ID };
            maybe_do_stability_check(tcx, id, item.span, cb);
        }
        // For implementations of traits, check the stability of each item
        // individually as it's possible to have a stable trait with unstable
        // items.
        hir::ItemImpl(_, _, _, Some(ref t), _, ref impl_items) => {
            let trait_did = tcx.def_map.borrow().get(&t.ref_id).unwrap().def_id();
            let trait_items = tcx.trait_items(trait_did);
            for impl_item in impl_items {
                let item = trait_items.iter().find(|item| {
                    item.name() == impl_item.ident.name
                }).unwrap();
                if warn_about_defns {
                    maybe_do_stability_check(tcx, item.def_id(), impl_item.span, cb);
                }
            }
        }
        _ => (/* pass */)
    }
}
pub fn check_item ( tcx : & ty :: ctxt , item : & hir :: Item , warn_about_defns : bool , cb : & mut FnMut ( DefId , Span , & Option < & Stability > ) ) { match item . node { hir :: ItemExternCrate ( _ ) => { // compiler-generated `extern crate` items have a dummy span. if item . span == DUMMY_SP { return } let cnum = match tcx . sess . cstore . find_extern_mod_stmt_cnum ( item . id ) { Some ( cnum ) => cnum , None => return , } ; let id = DefId { krate : cnum , node : ast :: CRATE_NODE_ID } ; maybe_do_stability_check ( tcx , id , item . span , cb ) ; } // For implementations of traits, check the stability of each item // individually as it's possible to have a stable trait with unstable // items. hir :: ItemImpl ( _ , _ , _ , Some ( ref t ) , _ , ref impl_items ) => { let trait_did = tcx . def_map . borrow ( ) . get ( & t . ref_id ) . unwrap ( ) . def_id ( ) ; let trait_items = tcx . trait_items ( trait_did ) ; for impl_item in impl_items { let item = trait_items . iter ( ) . find ( | item | { item . name ( ) == impl_item . ident . name } ) . unwrap ( ) ; if warn_about_defns { maybe_do_stability_check ( tcx , item . def_id ( ) , impl_item . span , cb ) ; } } } _ => ( /* pass */ ) } }
Helper for discovering nodes to check for stability
Helper for discovering nodes to check for stability
tcx
&ty::ctxt
item
&hir::Item
warn_about_defns
bool
cb
&mut FnMut(DefId, Span, &Option<&Stability>)
tcx
&ty::ctxt
item
&hir::Item
warn_about_defns
bool
cb
&mut FnMut(DefId, Span, &Option<&Stability>)