fn get_path_parent_def_id(
    tcx: TyCtxt<'_>,
    def_id: DefId,
    path: &UsePath<'_>
) -> Option<DefId>
Expand description

Get DefId of of an item’s user-visible parent.

“User-visible” should account for re-exporting and inlining, which is why this function isn’t just tcx.parent(def_id). If the provided path has more than one path element, the DefId of the second-to-last will be given.

use crate::foo::Bar;
           ^^^ DefId of this item will be returned

If the provided path has only one item, tcx.parent(def_id) will be returned instead.