From af5cce102556902a9b9c6a78b5bc56ae5131ae6b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 1 Oct 2018 14:28:06 +0300 Subject: [PATCH] HACK: add 20 bytes to ExpnInfo to test its performance impact. --- src/librustc/hir/lowering.rs | 1 + src/librustc/ich/impls_syntax.rs | 1 + src/librustc_allocator/expand.rs | 1 + src/libsyntax/ext/derive.rs | 1 + src/libsyntax/ext/expand.rs | 5 +++++ src/libsyntax/std_inject.rs | 1 + src/libsyntax/test.rs | 1 + src/libsyntax_ext/proc_macro_registrar.rs | 1 + src/libsyntax_ext/test.rs | 1 + src/libsyntax_ext/test_case.rs | 1 + src/libsyntax_pos/hygiene.rs | 7 +++++++ 11 files changed, 21 insertions(+) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index aa1bd6dd59ccf..9c46b15b86c4e 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -652,6 +652,7 @@ impl<'a> LoweringContext<'a> { def_site: Some(span), format: source_map::CompilerDesugaring(reason), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: source_map::hygiene::default_edition(), diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index a15411c7d8369..07393c0ac15dc 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -395,6 +395,7 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnInfo { def_site, format, allow_internal_unstable, + _allow_internal_unstable_features, allow_internal_unsafe, local_inner_macros, edition diff --git a/src/librustc_allocator/expand.rs b/src/librustc_allocator/expand.rs index 5df68d49af5f7..9aaa145e7cbef 100644 --- a/src/librustc_allocator/expand.rs +++ b/src/librustc_allocator/expand.rs @@ -102,6 +102,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> { def_site: None, format: MacroAttribute(Symbol::intern(name)), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index 684cee3887463..c0d7c680358b6 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -63,6 +63,7 @@ pub fn add_derived_markers(cx: &mut ExtCtxt, span: Span, traits: &[ast::Path] def_site: None, format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 52322e98d46f9..c153b06a78ec9 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -568,6 +568,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { def_site: None, format: MacroAttribute(Symbol::intern(&attr.path.to_string())), allow_internal_unstable: false, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: ext.edition(), @@ -757,6 +758,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { def_site: def_site_span, format: macro_bang_format(path), allow_internal_unstable, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe, local_inner_macros, edition, @@ -808,6 +810,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { def_site: tt_span, format: macro_bang_format(path), allow_internal_unstable, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), @@ -849,6 +852,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { format: macro_bang_format(path), // FIXME probably want to follow macro_rules macros here. allow_internal_unstable, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition, @@ -924,6 +928,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { def_site: None, format: MacroAttribute(pretty_name), allow_internal_unstable: false, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: ext.edition(), diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 1210f331b285b..7b0be585bd61a 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -30,6 +30,7 @@ fn ignored_span(sp: Span) -> Span { def_site: None, format: MacroAttribute(Symbol::intern("std_inject")), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9f554a90afbc4..de1e1c58f8b3b 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -294,6 +294,7 @@ fn generate_test_harness(sess: &ParseSess, def_site: None, format: MacroAttribute(Symbol::intern("test_case")), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index 65e175f95df81..e862dfa82c619 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -358,6 +358,7 @@ fn mk_registrar(cx: &mut ExtCtxt, def_site: None, format: MacroAttribute(Symbol::intern("proc_macro")), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 8ddfb1d9cba22..0e5b99008495e 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -77,6 +77,7 @@ pub fn expand_test_or_bench( def_site: None, format: MacroAttribute(Symbol::intern("test")), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_ext/test_case.rs b/src/libsyntax_ext/test_case.rs index 0128db7dd78d7..1722e630010fb 100644 --- a/src/libsyntax_ext/test_case.rs +++ b/src/libsyntax_ext/test_case.rs @@ -52,6 +52,7 @@ pub fn expand( def_site: None, format: MacroAttribute(Symbol::intern("test_case")), allow_internal_unstable: true, + _allow_internal_unstable_features: <_>::default(), allow_internal_unsafe: false, local_inner_macros: false, edition: hygiene::default_edition(), diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index f053cb10d0649..ba95e51d33a6f 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -534,6 +534,11 @@ impl fmt::Debug for SyntaxContext { } } +// HACK(eddyb) only testing the performance impact of using more memory. +// Also, `[u8; 19]` doesn't implement the right traits, so instead I've +// approximated `[u8; 19]` to `[u32; 5]` which can be written as a tuple: +type UnstableFeatures = (((u32, u32), (u32, u32)), u32); // [u8; (145 + 7) / 8]; + /// Extra information for tracking spans of macro and syntax sugar expansion #[derive(Clone, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct ExpnInfo { @@ -558,6 +563,8 @@ pub struct ExpnInfo { /// features internally without forcing the whole crate to opt-in /// to them. pub allow_internal_unstable: bool, + // HACK(eddyb) only testing the performance impact of using more memory. + pub _allow_internal_unstable_features: UnstableFeatures, /// Whether the macro is allowed to use `unsafe` internally /// even if the user crate has `#![forbid(unsafe_code)]`. pub allow_internal_unsafe: bool,