Skip to content

Commit 6548a5f

Browse files
committed
Remove default macro transparencies
All transparancies are passed explicitly now. Also remove `#[rustc_macro_transparency]` annotations from built-in macros, they are no longer used. `#[rustc_macro_transparency]` only makes sense for declarative macros now.
1 parent cf9db76 commit 6548a5f

File tree

5 files changed

+1
-35
lines changed

5 files changed

+1
-35
lines changed

src/libcore/macros.rs

-8
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ pub(crate) mod builtin {
734734
#[allow_internal_unstable(fmt_internals)]
735735
#[rustc_builtin_macro]
736736
#[macro_export]
737-
#[rustc_macro_transparency = "opaque"]
738737
macro_rules! format_args {
739738
($fmt:expr) => ({ /* compiler built-in */ });
740739
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
@@ -747,7 +746,6 @@ pub(crate) mod builtin {
747746
#[allow_internal_unstable(fmt_internals)]
748747
#[rustc_builtin_macro]
749748
#[macro_export]
750-
#[rustc_macro_transparency = "opaque"]
751749
macro_rules! format_args_nl {
752750
($fmt:expr) => ({ /* compiler built-in */ });
753751
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
@@ -1235,42 +1233,36 @@ pub(crate) mod builtin {
12351233
#[stable(feature = "rust1", since = "1.0.0")]
12361234
#[allow_internal_unstable(test, rustc_attrs)]
12371235
#[rustc_builtin_macro]
1238-
#[rustc_macro_transparency = "semitransparent"]
12391236
pub macro test($item:item) { /* compiler built-in */ }
12401237

12411238
/// Attribute macro applied to a function to turn it into a benchmark test.
12421239
#[unstable(feature = "test", issue = "50297",
12431240
reason = "`bench` is a part of custom test frameworks which are unstable")]
12441241
#[allow_internal_unstable(test, rustc_attrs)]
12451242
#[rustc_builtin_macro]
1246-
#[rustc_macro_transparency = "semitransparent"]
12471243
pub macro bench($item:item) { /* compiler built-in */ }
12481244

12491245
/// An implementation detail of the `#[test]` and `#[bench]` macros.
12501246
#[unstable(feature = "custom_test_frameworks", issue = "50297",
12511247
reason = "custom test frameworks are an unstable feature")]
12521248
#[allow_internal_unstable(test, rustc_attrs)]
12531249
#[rustc_builtin_macro]
1254-
#[rustc_macro_transparency = "semitransparent"]
12551250
pub macro test_case($item:item) { /* compiler built-in */ }
12561251

12571252
/// Attribute macro applied to a static to register it as a global allocator.
12581253
#[stable(feature = "global_allocator", since = "1.28.0")]
12591254
#[allow_internal_unstable(rustc_attrs)]
12601255
#[rustc_builtin_macro]
1261-
#[rustc_macro_transparency = "semitransparent"]
12621256
pub macro global_allocator($item:item) { /* compiler built-in */ }
12631257

12641258
/// Unstable implementation detail of the `rustc` compiler, do not use.
12651259
#[rustc_builtin_macro]
1266-
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
12671260
#[stable(feature = "rust1", since = "1.0.0")]
12681261
#[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
12691262
pub macro RustcDecodable($item:item) { /* compiler built-in */ }
12701263

12711264
/// Unstable implementation detail of the `rustc` compiler, do not use.
12721265
#[rustc_builtin_macro]
1273-
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
12741266
#[stable(feature = "rust1", since = "1.0.0")]
12751267
#[allow_internal_unstable(core_intrinsics)]
12761268
pub macro RustcEncodable($item:item) { /* compiler built-in */ }

src/librustc/ich/impls_syntax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData {
402402
parent -> _,
403403
call_site,
404404
def_site,
405-
default_transparency,
406405
allow_internal_unstable,
407406
allow_internal_unsafe,
408407
local_inner_macros,

src/libsyntax/ext/base.rs

-20
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,6 @@ pub struct SyntaxExtension {
549549
pub kind: SyntaxExtensionKind,
550550
/// Span of the macro definition.
551551
pub span: Span,
552-
/// Hygienic properties of spans produced by this macro by default.
553-
pub default_transparency: Transparency,
554552
/// Whitelist of unstable features that are treated as stable inside this macro.
555553
pub allow_internal_unstable: Option<Lrc<[Symbol]>>,
556554
/// Suppresses the `unsafe_code` lint for code produced by this macro.
@@ -572,22 +570,6 @@ pub struct SyntaxExtension {
572570
pub is_derive_copy: bool,
573571
}
574572

575-
impl SyntaxExtensionKind {
576-
/// When a syntax extension is constructed,
577-
/// its transparency can often be inferred from its kind.
578-
fn default_transparency(&self) -> Transparency {
579-
match self {
580-
SyntaxExtensionKind::Bang(..) |
581-
SyntaxExtensionKind::Attr(..) |
582-
SyntaxExtensionKind::Derive(..) |
583-
SyntaxExtensionKind::NonMacroAttr { .. } => Transparency::Opaque,
584-
SyntaxExtensionKind::LegacyBang(..) |
585-
SyntaxExtensionKind::LegacyAttr(..) |
586-
SyntaxExtensionKind::LegacyDerive(..) => Transparency::SemiTransparent,
587-
}
588-
}
589-
}
590-
591573
impl SyntaxExtension {
592574
/// Returns which kind of macro calls this syntax extension.
593575
pub fn macro_kind(&self) -> MacroKind {
@@ -606,7 +588,6 @@ impl SyntaxExtension {
606588
pub fn default(kind: SyntaxExtensionKind, edition: Edition) -> SyntaxExtension {
607589
SyntaxExtension {
608590
span: DUMMY_SP,
609-
default_transparency: kind.default_transparency(),
610591
allow_internal_unstable: None,
611592
allow_internal_unsafe: false,
612593
local_inner_macros: false,
@@ -646,7 +627,6 @@ impl SyntaxExtension {
646627
parent,
647628
call_site,
648629
def_site: self.span,
649-
default_transparency: self.default_transparency,
650630
allow_internal_unstable: self.allow_internal_unstable.clone(),
651631
allow_internal_unsafe: self.allow_internal_unsafe,
652632
local_inner_macros: self.local_inner_macros,

src/libsyntax/ext/tt/macro_rules.rs

-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ pub fn compile(
478478
SyntaxExtension {
479479
kind: SyntaxExtensionKind::LegacyBang(expander),
480480
span: def.span,
481-
default_transparency: transparency,
482481
allow_internal_unstable,
483482
allow_internal_unsafe: attr::contains_name(&def.attrs, sym::allow_internal_unsafe),
484483
local_inner_macros,

src/libsyntax_pos/hygiene.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,7 @@ impl Span {
550550
/// The returned span belongs to the created expansion and has the new properties,
551551
/// but its location is inherited from the current span.
552552
pub fn fresh_expansion(self, expn_data: ExpnData) -> Span {
553-
let transparency = expn_data.default_transparency;
554-
self.fresh_expansion_with_transparency(expn_data, transparency)
553+
self.fresh_expansion_with_transparency(expn_data, Transparency::SemiTransparent)
555554
}
556555

557556
pub fn fresh_expansion_with_transparency(
@@ -591,8 +590,6 @@ pub struct ExpnData {
591590
/// The span of the macro definition (possibly dummy).
592591
/// This span serves only informational purpose and is not used for resolution.
593592
pub def_site: Span,
594-
/// Transparency used by `apply_mark` for the expansion with this expansion data by default.
595-
pub default_transparency: Transparency,
596593
/// List of #[unstable]/feature-gated features that the macro is allowed to use
597594
/// internally without forcing the whole crate to opt-in
598595
/// to them.
@@ -615,7 +612,6 @@ impl ExpnData {
615612
parent: ExpnId::root(),
616613
call_site,
617614
def_site: DUMMY_SP,
618-
default_transparency: Transparency::SemiTransparent,
619615
allow_internal_unstable: None,
620616
allow_internal_unsafe: false,
621617
local_inner_macros: false,

0 commit comments

Comments
 (0)