/// Return the NodeId for an enclosing scope that is also `unsafe`
Return the NodeId for an enclosing scope that is also `unsafe`
Return the NodeId for an enclosing scope that is also ` unsafe `
fn is_enclosed(tcx: TyCtxt,
               used_unsafe: &FxHashSet<ast::NodeId>,
               id: ast::NodeId) -> Option<(String, ast::NodeId)> {
    let parent_id = tcx.hir.get_parent_node(id);
    if parent_id != id {
        if used_unsafe.contains(&parent_id) {
            Some(("block".to_string(), parent_id))
        } else if let Some(hir::map::NodeItem(&hir::Item {
            node: hir::ItemKind::Fn(_, header, _, _),
            ..
        })) = tcx.hir.find(parent_id) {
            match header.unsafety {
                hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
                hir::Unsafety::Normal => None,
            }
        } else {
            is_enclosed(tcx, used_unsafe, parent_id)
        }
    } else {
        None
    }
}
fn is_enclosed ( tcx : TyCtxt , used_unsafe : & FxHashSet < ast :: NodeId > , id : ast :: NodeId ) -> Option < ( String , ast :: NodeId ) > { let parent_id = tcx . hir . get_parent_node ( id ) ; if parent_id != id { if used_unsafe . contains ( & parent_id ) { Some ( ( " " . to_string ( ) , parent_id ) ) } else if let Some ( hir :: map :: NodeItem ( & hir :: Item { node : hir :: ItemKind :: Fn ( _ , header , _ , _ ) , .. } ) ) = tcx . hir . find ( parent_id ) { match header . unsafety { hir :: Unsafety :: Unsafe => Some ( ( " " . to_string ( ) , parent_id ) ) , hir :: Unsafety :: Normal => None , } } else { is_enclosed ( tcx , used_unsafe , parent_id ) } } else { None } }
Return the NodeId for an enclosing scope that is also `unsafe`
Return the NodeId for an enclosing scope that is also ` unsafe `
tcx
TyCtxt
used_unsafe
&FxHashSet<ast::NodeId>
id
ast::NodeId