]> git.lizzy.rs Git - rust.git/blob - src/librustc_middle/hir/exports.rs
Rollup merge of #75485 - RalfJung:pin, r=nagisa
[rust.git] / src / librustc_middle / hir / exports.rs
1 use crate::ty;
2
3 use rustc_data_structures::fx::FxHashMap;
4 use rustc_hir::def::Res;
5 use rustc_hir::def_id::LocalDefId;
6 use rustc_macros::HashStable;
7 use rustc_span::symbol::Ident;
8 use rustc_span::Span;
9
10 use std::fmt::Debug;
11
12 /// This is the replacement export map. It maps a module to all of the exports
13 /// within.
14 pub type ExportMap<Id> = FxHashMap<LocalDefId, Vec<Export<Id>>>;
15
16 #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
17 pub struct Export<Id> {
18     /// The name of the target.
19     pub ident: Ident,
20     /// The resolution of the target.
21     pub res: Res<Id>,
22     /// The span of the target.
23     pub span: Span,
24     /// The visibility of the export.
25     /// We include non-`pub` exports for hygienic macros that get used from extern crates.
26     pub vis: ty::Visibility,
27 }
28
29 impl<Id> Export<Id> {
30     pub fn map_id<R>(self, map: impl FnMut(Id) -> R) -> Export<R> {
31         Export { ident: self.ident, res: self.res.map_id(map), span: self.span, vis: self.vis }
32     }
33 }