diff options
| author | Jimmy Brisson <theotherjimmy@gmail.com> | 2017-10-12 16:45:07 -0500 |
|---|---|---|
| committer | Jimmy Brisson <theotherjimmy@gmail.com> | 2017-10-13 09:34:13 -0500 |
| commit | fcb8bc9d4e08924d4e4bde1ef4995b329fbc11b5 (patch) | |
| tree | 8db65827b7301f5411e82b536b407f7f6d842675 /src | |
| parent | 2160bab0dac479e72f49932c1c71cb3d01f4e9f6 (diff) | |
| download | rust-fcb8bc9d4e08924d4e4bde1ef4995b329fbc11b5.tar.gz rust-fcb8bc9d4e08924d4e4bde1ef4995b329fbc11b5.zip | |
Remove recursion from `define_{provider|map}_struct`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/maps/plumbing.rs | 103 |
1 files changed, 4 insertions, 99 deletions
diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 462149c2ed8..3f215303ccb 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -468,8 +468,7 @@ macro_rules! define_maps { define_provider_struct! { tcx: $tcx, - input: ($(([$($modifiers)*] [$name] [$K] [$V]))*), - output: () + input: ($(([$($modifiers)*] [$name] [$K] [$V]))*) } impl<$tcx> Copy for Providers<$tcx> {} @@ -480,78 +479,19 @@ macro_rules! define_maps { } macro_rules! define_map_struct { - // Initial state (tcx: $tcx:tt, - input: $input:tt) => { - define_map_struct! { - tcx: $tcx, - input: $input, - output: () - } - }; - - // Final output - (tcx: $tcx:tt, - input: (), - output: ($($output:tt)*)) => { + input: ($(([$(modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => { pub struct Maps<$tcx> { providers: IndexVec<CrateNum, Providers<$tcx>>, query_stack: RefCell<Vec<(Span, Query<$tcx>)>>, - $($output)* - } - }; - - // Field recognized and ready to shift into the output - (tcx: $tcx:tt, - ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]), - input: $input:tt, - output: ($($output:tt)*)) => { - define_map_struct! { - tcx: $tcx, - input: $input, - output: ($($output)* - $(#[$attr])* $($pub)* $name: RefCell<QueryMap<queries::$name<$tcx>>>,) - } - }; - - // No modifiers left? This is a private item. - (tcx: $tcx:tt, - input: (([] $attrs:tt $name:tt) $($input:tt)*), - output: $output:tt) => { - define_map_struct! { - tcx: $tcx, - ready: ([] $attrs $name), - input: ($($input)*), - output: $output - } - }; - - // Skip other modifiers - (tcx: $tcx:tt, - input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*), - output: $output:tt) => { - define_map_struct! { - tcx: $tcx, - input: (([$($modifiers)*] $($fields)*) $($input)*), - output: $output + $($(#[$attr])* $name: RefCell<QueryMap<queries::$name<$tcx>>>,)* } }; } macro_rules! define_provider_struct { - // Initial state: - (tcx: $tcx:tt, input: $input:tt) => { - define_provider_struct! { - tcx: $tcx, - input: $input, - output: () - } - }; - - // Final state: (tcx: $tcx:tt, - input: (), - output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => { + input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => { pub struct Providers<$tcx> { $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)* } @@ -566,41 +506,6 @@ macro_rules! define_provider_struct { } } }; - - // Something ready to shift: - (tcx: $tcx:tt, - ready: ($name:tt $K:tt $V:tt), - input: $input:tt, - output: ($($output:tt)*)) => { - define_provider_struct! { - tcx: $tcx, - input: $input, - output: ($($output)* ($name $K $V)) - } - }; - - // Regular queries produce a `V` only. - (tcx: $tcx:tt, - input: (([] $name:tt $K:tt $V:tt) $($input:tt)*), - output: $output:tt) => { - define_provider_struct! { - tcx: $tcx, - ready: ($name $K $V), - input: ($($input)*), - output: $output - } - }; - - // Skip modifiers. - (tcx: $tcx:tt, - input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*), - output: $output:tt) => { - define_provider_struct! { - tcx: $tcx, - input: (([$($modifiers)*] $($fields)*) $($input)*), - output: $output - } - }; } |
