fn update_visibility_of_intermediate_use_statements(
        &mut self,
        segments: &[hir::PathSegment<'_>],
    ) {
        if let [.., module, segment] = segments {
            if let Some(item) = module
                .res
                .and_then(|res| res.mod_def_id())
                // If the module is `self`, i.e. the current crate,
                // there will be no corresponding item.
                .filter(|def_id| def_id.index != CRATE_DEF_INDEX || def_id.krate != LOCAL_CRATE)
                .and_then(|def_id| {
                    def_id.as_local().map(|def_id| self.tcx.hir().local_def_id_to_hir_id(def_id))
                })
                .map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
            {
                if let hir::ItemKind::Mod(m) = &item.kind {
                    for &item_id in m.item_ids {
                        let item = self.tcx.hir().item(item_id);
                        if !self.tcx.hygienic_eq(
                            segment.ident,
                            item.ident,
                            item_id.def_id.to_def_id(),
                        ) {
                            continue;
                        }
                        if let hir::ItemKind::Use(..) = item.kind {
                            self.update(item.def_id, Some(AccessLevel::Exported));
                        }
                    }
                }
            }
        }
    }
/// Given the path segments of a `ItemKind::Use`, then we need
/// to update the visibility of the intermediate use so that it isn't linted
/// by `unreachable_pub`.
///
/// This isn't trivial as `path.res` has the `DefId` of the eventual target
/// of the use statement not of the next intermediate use statement.
///
/// To do this, consider the last two segments of the path to our intermediate
/// use statement. We expect the penultimate segment to be a module and the
/// last segment to be the name of the item we are exporting. We can then
/// look at the items contained in the module for the use statement with that
/// name and update that item's visibility.
///
/// FIXME: This solution won't work with glob imports and doesn't respect
/// namespaces. See <https://github.com/rust-lang/rust/pull/57922#discussion_r251234202>.
Given the path segments of a `ItemKind::Use`, then we need
to update the visibility of the intermediate use so that it isn't linted
by `unreachable_pub`.

This isn't trivial as `path.res` has the `DefId` of the eventual target
of the use statement not of the next intermediate use statement.

To do this, consider the last two segments of the path to our intermediate
use statement. We expect the penultimate segment to be a module and the
last segment to be the name of the item we are exporting. We can then
look at the items contained in the module for the use statement with that
name and update that item's visibility.

This solution won't work with glob imports and doesn't respect
namespaces. See .
Given the path segments of a ` ItemKind :: Use ` then we need to update the visibility of the intermediate use so that it isn ' t linted by ` unreachable_pub ` . This isn ' t trivial as ` path . res ` has the ` DefId ` of the eventual target of the use statement not of the next intermediate use statement . To do this consider the last two segments of the path to our intermediate use statement . We expect the penultimate segment to be a module and the last segment to be the name of the item we are exporting . We can then look at the items contained in the module for the use statement with that name and update that item ' s visibility . This solution won ' t work with glob imports and doesn ' t respect namespaces . See .
fn update_visibility_of_intermediate_use_statements(
        &mut self,
        segments: &[hir::PathSegment<'_>],
    ) {
        if let [.., module, segment] = segments {
            if let Some(item) = module
                .res
                .and_then(|res| res.mod_def_id())
                // If the module is `self`, i.e. the current crate,
                // there will be no corresponding item.
                .filter(|def_id| def_id.index != CRATE_DEF_INDEX || def_id.krate != LOCAL_CRATE)
                .and_then(|def_id| {
                    def_id.as_local().map(|def_id| self.tcx.hir().local_def_id_to_hir_id(def_id))
                })
                .map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
            {
                if let hir::ItemKind::Mod(m) = &item.kind {
                    for &item_id in m.item_ids {
                        let item = self.tcx.hir().item(item_id);
                        if !self.tcx.hygienic_eq(
                            segment.ident,
                            item.ident,
                            item_id.def_id.to_def_id(),
                        ) {
                            continue;
                        }
                        if let hir::ItemKind::Use(..) = item.kind {
                            self.update(item.def_id, Some(AccessLevel::Exported));
                        }
                    }
                }
            }
        }
    }
fn update_visibility_of_intermediate_use_statements ( & mut self , segments : & [ hir :: PathSegment < ' _ > ] , ) { if let [ .. , module , segment ] = segments { if let Some ( item ) = module . res . and_then ( | res | res . mod_def_id ( ) ) // If the module is `self`, i.e. the current crate, // there will be no corresponding item. . filter ( | def_id | def_id . index != CRATE_DEF_INDEX || def_id . krate != LOCAL_CRATE ) . and_then ( | def_id | { def_id . as_local ( ) . map ( | def_id | self . tcx . hir ( ) . local_def_id_to_hir_id ( def_id ) ) } ) . map ( | module_hir_id | self . tcx . hir ( ) . expect_item ( module_hir_id ) ) { if let hir :: ItemKind :: Mod ( m ) = & item . kind { for & item_id in m . item_ids { let item = self . tcx . hir ( ) . item ( item_id ) ; if ! self . tcx . hygienic_eq ( segment . ident , item . ident , item_id . def_id . to_def_id ( ) , ) { continue ; } if let hir :: ItemKind :: Use ( .. ) = item . kind { self . update ( item . def_id , Some ( AccessLevel :: Exported ) ) ; } } } } } }
Given the path segments of a `ItemKind::Use`, then we need
to update the visibility of the intermediate use so that it isn't linted
by `unreachable_pub`.
Given the path segments of a ` ItemKind :: Use ` then we need to update the visibility of the intermediate use so that it isn ' t linted by ` unreachable_pub ` .
&mut self
segments
&[hir::PathSegment<'_>]
&mut self
segments
&[hir::PathSegment<'_>]