fn is_enclosed(
    tcx: TyCtxt<'_>,
    used_unsafe: &FxHashSet<hir::HirId>,
    id: hir::HirId,
    unsafe_op_in_unsafe_fn_allowed: bool,
) -> Option<(&'static str, hir::HirId)> {
    let parent_id = tcx.hir().get_parent_node(id);
    if parent_id != id {
        if used_unsafe.contains(&parent_id) {
            Some(("block", parent_id))
        } else if let Some(Node::Item(&hir::Item {
            kind: hir::ItemKind::Fn(ref sig, _, _),
            ..
        })) = tcx.hir().find(parent_id)
        {
            if sig.header.unsafety == hir::Unsafety::Unsafe && unsafe_op_in_unsafe_fn_allowed {
                Some(("fn", parent_id))
            } else {
                None
            }
        } else {
            is_enclosed(tcx, used_unsafe, parent_id, unsafe_op_in_unsafe_fn_allowed)
        }
    } else {
        None
    }
}
/// Returns the `HirId` for an enclosing scope that is also `unsafe`.
Returns the `HirId` for an enclosing scope that is also `unsafe`.
Returns the ` HirId ` for an enclosing scope that is also ` unsafe ` .
fn is_enclosed(
    tcx: TyCtxt<'_>,
    used_unsafe: &FxHashSet<hir::HirId>,
    id: hir::HirId,
    unsafe_op_in_unsafe_fn_allowed: bool,
) -> Option<(&'static str, hir::HirId)> {
    let parent_id = tcx.hir().get_parent_node(id);
    if parent_id != id {
        if used_unsafe.contains(&parent_id) {
            Some(("block", parent_id))
        } else if let Some(Node::Item(&hir::Item {
            kind: hir::ItemKind::Fn(ref sig, _, _),
            ..
        })) = tcx.hir().find(parent_id)
        {
            if sig.header.unsafety == hir::Unsafety::Unsafe && unsafe_op_in_unsafe_fn_allowed {
                Some(("fn", parent_id))
            } else {
                None
            }
        } else {
            is_enclosed(tcx, used_unsafe, parent_id, unsafe_op_in_unsafe_fn_allowed)
        }
    } else {
        None
    }
}
fn is_enclosed ( tcx : TyCtxt < ' _ > , used_unsafe : & FxHashSet < hir :: HirId > , id : hir :: HirId , unsafe_op_in_unsafe_fn_allowed : bool , ) -> Option < ( & ' static str , hir :: HirId ) > { let parent_id = tcx . hir ( ) . get_parent_node ( id ) ; if parent_id != id { if used_unsafe . contains ( & parent_id ) { Some ( ( " " , parent_id ) ) } else if let Some ( Node :: Item ( & hir :: Item { kind : hir :: ItemKind :: Fn ( ref sig , _ , _ ) , .. } ) ) = tcx . hir ( ) . find ( parent_id ) { if sig . header . unsafety == hir :: Unsafety :: Unsafe && unsafe_op_in_unsafe_fn_allowed { Some ( ( " " , parent_id ) ) } else { None } } else { is_enclosed ( tcx , used_unsafe , parent_id , unsafe_op_in_unsafe_fn_allowed ) } } else { None } }
Returns the `HirId` for an enclosing scope that is also `unsafe`.
Returns the ` HirId ` for an enclosing scope that is also ` unsafe ` .
tcx
TyCtxt<'_>
used_unsafe
&FxHashSet<hir::HirId>
id
hir::HirId
unsafe_op_in_unsafe_fn_allowed
bool