Skip to content

Commit 389686a

Browse files
committed
Auto merge of #54714 - eddyb:fine-grained-feats, r=<try>
[WIP] Require specific feature names in `#[allow_internal_unstable]`. I opened this with just a hacky commit to test the perf impact of one implementation strategy.
2 parents f55129d + af5cce1 commit 389686a

File tree

11 files changed

+21
-0
lines changed

11 files changed

+21
-0
lines changed

Diff for: src/librustc/hir/lowering.rs

+1
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ impl<'a> LoweringContext<'a> {
652652
def_site: Some(span),
653653
format: source_map::CompilerDesugaring(reason),
654654
allow_internal_unstable: true,
655+
_allow_internal_unstable_features: <_>::default(),
655656
allow_internal_unsafe: false,
656657
local_inner_macros: false,
657658
edition: source_map::hygiene::default_edition(),

Diff for: src/librustc/ich/impls_syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnInfo {
395395
def_site,
396396
format,
397397
allow_internal_unstable,
398+
_allow_internal_unstable_features,
398399
allow_internal_unsafe,
399400
local_inner_macros,
400401
edition

Diff for: src/librustc_allocator/expand.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
102102
def_site: None,
103103
format: MacroAttribute(Symbol::intern(name)),
104104
allow_internal_unstable: true,
105+
_allow_internal_unstable_features: <_>::default(),
105106
allow_internal_unsafe: false,
106107
local_inner_macros: false,
107108
edition: hygiene::default_edition(),

Diff for: src/libsyntax/ext/derive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub fn add_derived_markers<T>(cx: &mut ExtCtxt, span: Span, traits: &[ast::Path]
6363
def_site: None,
6464
format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)),
6565
allow_internal_unstable: true,
66+
_allow_internal_unstable_features: <_>::default(),
6667
allow_internal_unsafe: false,
6768
local_inner_macros: false,
6869
edition: hygiene::default_edition(),

Diff for: src/libsyntax/ext/expand.rs

+5
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
568568
def_site: None,
569569
format: MacroAttribute(Symbol::intern(&attr.path.to_string())),
570570
allow_internal_unstable: false,
571+
_allow_internal_unstable_features: <_>::default(),
571572
allow_internal_unsafe: false,
572573
local_inner_macros: false,
573574
edition: ext.edition(),
@@ -757,6 +758,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
757758
def_site: def_site_span,
758759
format: macro_bang_format(path),
759760
allow_internal_unstable,
761+
_allow_internal_unstable_features: <_>::default(),
760762
allow_internal_unsafe,
761763
local_inner_macros,
762764
edition,
@@ -808,6 +810,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
808810
def_site: tt_span,
809811
format: macro_bang_format(path),
810812
allow_internal_unstable,
813+
_allow_internal_unstable_features: <_>::default(),
811814
allow_internal_unsafe: false,
812815
local_inner_macros: false,
813816
edition: hygiene::default_edition(),
@@ -849,6 +852,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
849852
format: macro_bang_format(path),
850853
// FIXME probably want to follow macro_rules macros here.
851854
allow_internal_unstable,
855+
_allow_internal_unstable_features: <_>::default(),
852856
allow_internal_unsafe: false,
853857
local_inner_macros: false,
854858
edition,
@@ -924,6 +928,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
924928
def_site: None,
925929
format: MacroAttribute(pretty_name),
926930
allow_internal_unstable: false,
931+
_allow_internal_unstable_features: <_>::default(),
927932
allow_internal_unsafe: false,
928933
local_inner_macros: false,
929934
edition: ext.edition(),

Diff for: src/libsyntax/std_inject.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn ignored_span(sp: Span) -> Span {
3030
def_site: None,
3131
format: MacroAttribute(Symbol::intern("std_inject")),
3232
allow_internal_unstable: true,
33+
_allow_internal_unstable_features: <_>::default(),
3334
allow_internal_unsafe: false,
3435
local_inner_macros: false,
3536
edition: hygiene::default_edition(),

Diff for: src/libsyntax/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ fn generate_test_harness(sess: &ParseSess,
294294
def_site: None,
295295
format: MacroAttribute(Symbol::intern("test_case")),
296296
allow_internal_unstable: true,
297+
_allow_internal_unstable_features: <_>::default(),
297298
allow_internal_unsafe: false,
298299
local_inner_macros: false,
299300
edition: hygiene::default_edition(),

Diff for: src/libsyntax_ext/proc_macro_registrar.rs

+1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ fn mk_registrar(cx: &mut ExtCtxt,
358358
def_site: None,
359359
format: MacroAttribute(Symbol::intern("proc_macro")),
360360
allow_internal_unstable: true,
361+
_allow_internal_unstable_features: <_>::default(),
361362
allow_internal_unsafe: false,
362363
local_inner_macros: false,
363364
edition: hygiene::default_edition(),

Diff for: src/libsyntax_ext/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn expand_test_or_bench(
7777
def_site: None,
7878
format: MacroAttribute(Symbol::intern("test")),
7979
allow_internal_unstable: true,
80+
_allow_internal_unstable_features: <_>::default(),
8081
allow_internal_unsafe: false,
8182
local_inner_macros: false,
8283
edition: hygiene::default_edition(),

Diff for: src/libsyntax_ext/test_case.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn expand(
5252
def_site: None,
5353
format: MacroAttribute(Symbol::intern("test_case")),
5454
allow_internal_unstable: true,
55+
_allow_internal_unstable_features: <_>::default(),
5556
allow_internal_unsafe: false,
5657
local_inner_macros: false,
5758
edition: hygiene::default_edition(),

Diff for: src/libsyntax_pos/hygiene.rs

+7
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ impl fmt::Debug for SyntaxContext {
534534
}
535535
}
536536

537+
// HACK(eddyb) only testing the performance impact of using more memory.
538+
// Also, `[u8; 19]` doesn't implement the right traits, so instead I've
539+
// approximated `[u8; 19]` to `[u32; 5]` which can be written as a tuple:
540+
type UnstableFeatures = (((u32, u32), (u32, u32)), u32); // [u8; (145 + 7) / 8];
541+
537542
/// Extra information for tracking spans of macro and syntax sugar expansion
538543
#[derive(Clone, Hash, Debug, RustcEncodable, RustcDecodable)]
539544
pub struct ExpnInfo {
@@ -558,6 +563,8 @@ pub struct ExpnInfo {
558563
/// features internally without forcing the whole crate to opt-in
559564
/// to them.
560565
pub allow_internal_unstable: bool,
566+
// HACK(eddyb) only testing the performance impact of using more memory.
567+
pub _allow_internal_unstable_features: UnstableFeatures,
561568
/// Whether the macro is allowed to use `unsafe` internally
562569
/// even if the user crate has `#![forbid(unsafe_code)]`.
563570
pub allow_internal_unsafe: bool,

0 commit comments

Comments
 (0)