diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 09bdca4915a1..e653392e3fb5 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -353,11 +353,11 @@ impl<'tcx> QueryDescription for queries::mir_pass<'tcx> { macro_rules! define_maps { (<$tcx:tt> $($(#[$attr:meta])* - [$($pub:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => { - pub struct Maps<$tcx> { - providers: IndexVec>, - query_stack: RefCell)>>, - $($(#[$attr])* $($pub)* $name: RefCell>>),* + [$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => { + define_map_struct! { + tcx: $tcx, + input: ($(([$($attr)*] [$($modifiers)*] $name))*), + output: () } impl<$tcx> Maps<$tcx> { @@ -519,6 +519,41 @@ macro_rules! define_maps { } } +macro_rules! define_map_struct { + (tcx: $tcx:tt, + input: (), + output: ($($output:tt)*)) => { + pub struct Maps<$tcx> { + providers: IndexVec>, + query_stack: RefCell)>>, + $($output)* + } + }; + + // Detect things with the `pub` modifier + (tcx: $tcx:tt, + input: (([$($attr:meta)*] [pub] $name:ident) $($input:tt)*), + output: ($($output:tt)*)) => { + define_map_struct! { + tcx: $tcx, + input: ($($input)*), + output: ($($output)* + $(#[$attr])* pub $name: RefCell>>,) + } + }; + + (tcx: $tcx:tt, + input: (([$($attr:meta)*] [$($modifiers:tt)*] $name:ident) $($input:tt)*), + output: ($($output:tt)*)) => { + define_map_struct! { + tcx: $tcx, + input: ($($input)*), + output: ($($output)* + $(#[$attr])* $name: RefCell>>,) + } + }; +} + // Each of these maps also corresponds to a method on a // `Provider` trait for requesting a value of that type, // and a method on `Maps` itself for doing that in a