Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Require specific feature names in #[allow_internal_unstable]. #54714

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn add_derived_markers<T>(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(),
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/proc_macro_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
7 changes: 7 additions & 0 deletions src/libsyntax_pos/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down