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