Skip to content

Commit d65e272

Browse files
committed
Auto merge of #63462 - matthewjasper:hygienic-builtin-derives, r=petrochenkov
Opaque builtin derive macros * Buiilt-in derives are now opaque macros * This required limiting the visibility of some previously unexposed functions in `core`. * This also required the change to `Ident` serialization. * All gensyms are replaced with hygienic identifiers * Use hygiene to avoid most other name-resolution issues with buiilt-in derives. * As far as I know the only remaining case that breaks is an ADT that has the same name as one of its parameters. Fixing this completely seemed to be more effort than it's worth. * Remove gensym in `Ident::decode`, which lead to linker errors due to `inline` being gensymmed. * `Ident`now panics if incremental compilation tries to serialize it (it currently doesn't). * `Ident` no longer uses `gensym` to emulate cross-crate hygiene. It only applied to reexports. * `SyntaxContext` is no longer serializable. * The long-term fix for this is to properly implement cross-crate hygiene, but this seemed to be acceptable for now. * Move type/const parameter shadowing checks to `resolve` * This was previously split between resolve and type checking. The type checking pass compared `InternedString`s, not Identifiers. * Removed the `SyntaxContext` from `{ast, hir}::{InlineAsm, GlobalAsm}` cc #60869 r? @petrochenkov
2 parents ac60ca0 + 1c0a546 commit d65e272

File tree

49 files changed

+376
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+376
-272
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
let mut new = None;
3838
if let Some(current_as_str) = args[i].to_str() {
3939
if (&*args[i - 1] == "-C" && current_as_str.starts_with("metadata")) ||
40-
current_as_str.starts_with("-Cmetadata") {
40+
current_as_str.starts_with("-Cmetadata") {
4141
new = Some(format!("{}-{}", current_as_str, s));
4242
}
4343
}
@@ -89,7 +89,7 @@ fn main() {
8989
if let Some(crate_name) = crate_name {
9090
if let Some(target) = env::var_os("RUSTC_TIME") {
9191
if target == "all" ||
92-
target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
92+
target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
9393
{
9494
cmd.arg("-Ztime");
9595
}

src/libcore/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub trait Clone : Sized {
135135

136136
/// Derive macro generating an impl of the trait `Clone`.
137137
#[rustc_builtin_macro]
138-
#[rustc_macro_transparency = "semitransparent"]
138+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
139139
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
140140
#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]
141141
pub macro Clone($item:item) { /* compiler built-in */ }

src/libcore/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
202202

203203
/// Derive macro generating an impl of the trait `PartialEq`.
204204
#[rustc_builtin_macro]
205-
#[rustc_macro_transparency = "semitransparent"]
205+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
206206
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
207207
#[allow_internal_unstable(core_intrinsics)]
208208
pub macro PartialEq($item:item) { /* compiler built-in */ }
@@ -265,7 +265,7 @@ pub trait Eq: PartialEq<Self> {
265265

266266
/// Derive macro generating an impl of the trait `Eq`.
267267
#[rustc_builtin_macro]
268-
#[rustc_macro_transparency = "semitransparent"]
268+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
269269
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
270270
#[allow_internal_unstable(core_intrinsics, derive_eq)]
271271
pub macro Eq($item:item) { /* compiler built-in */ }
@@ -616,7 +616,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
616616

617617
/// Derive macro generating an impl of the trait `Ord`.
618618
#[rustc_builtin_macro]
619-
#[rustc_macro_transparency = "semitransparent"]
619+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
620620
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
621621
#[allow_internal_unstable(core_intrinsics)]
622622
pub macro Ord($item:item) { /* compiler built-in */ }
@@ -865,7 +865,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
865865

866866
/// Derive macro generating an impl of the trait `PartialOrd`.
867867
#[rustc_builtin_macro]
868-
#[rustc_macro_transparency = "semitransparent"]
868+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
869869
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
870870
#[allow_internal_unstable(core_intrinsics)]
871871
pub macro PartialOrd($item:item) { /* compiler built-in */ }

src/libcore/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub trait Default: Sized {
117117

118118
/// Derive macro generating an impl of the trait `Default`.
119119
#[rustc_builtin_macro]
120-
#[rustc_macro_transparency = "semitransparent"]
120+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
121121
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
122122
#[allow_internal_unstable(core_intrinsics)]
123123
pub macro Default($item:item) { /* compiler built-in */ }

src/libcore/fmt/builders.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub struct DebugStruct<'a, 'b: 'a> {
9898
has_fields: bool,
9999
}
100100

101-
pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>,
101+
pub(super) fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>,
102102
name: &str)
103103
-> DebugStruct<'a, 'b> {
104104
let result = fmt.write_str(name);
@@ -251,7 +251,10 @@ pub struct DebugTuple<'a, 'b: 'a> {
251251
empty_name: bool,
252252
}
253253

254-
pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> DebugTuple<'a, 'b> {
254+
pub(super) fn debug_tuple_new<'a, 'b>(
255+
fmt: &'a mut fmt::Formatter<'b>,
256+
name: &str,
257+
) -> DebugTuple<'a, 'b> {
255258
let result = fmt.write_str(name);
256259
DebugTuple {
257260
fmt,
@@ -418,7 +421,7 @@ pub struct DebugSet<'a, 'b: 'a> {
418421
inner: DebugInner<'a, 'b>,
419422
}
420423

421-
pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b> {
424+
pub(super) fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b> {
422425
let result = fmt.write_str("{");
423426
DebugSet {
424427
inner: DebugInner {
@@ -555,7 +558,7 @@ pub struct DebugList<'a, 'b: 'a> {
555558
inner: DebugInner<'a, 'b>,
556559
}
557560

558-
pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a, 'b> {
561+
pub(super) fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a, 'b> {
559562
let result = fmt.write_str("[");
560563
DebugList {
561564
inner: DebugInner {
@@ -697,7 +700,7 @@ pub struct DebugMap<'a, 'b: 'a> {
697700
state: PadAdapterState,
698701
}
699702

700-
pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b> {
703+
pub(super) fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b> {
701704
let result = fmt.write_str("{");
702705
DebugMap {
703706
fmt,

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ pub trait Debug {
549549
pub(crate) mod macros {
550550
/// Derive macro generating an impl of the trait `Debug`.
551551
#[rustc_builtin_macro]
552-
#[rustc_macro_transparency = "semitransparent"]
552+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
553553
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
554554
#[allow_internal_unstable(core_intrinsics)]
555555
pub macro Debug($item:item) { /* compiler built-in */ }

src/libcore/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub trait Hash {
202202
pub(crate) mod macros {
203203
/// Derive macro generating an impl of the trait `Hash`.
204204
#[rustc_builtin_macro]
205-
#[rustc_macro_transparency = "semitransparent"]
205+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
206206
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
207207
#[allow_internal_unstable(core_intrinsics)]
208208
pub macro Hash($item:item) { /* compiler built-in */ }

src/libcore/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,14 +1263,14 @@ pub(crate) mod builtin {
12631263

12641264
/// Unstable implementation detail of the `rustc` compiler, do not use.
12651265
#[rustc_builtin_macro]
1266-
#[rustc_macro_transparency = "semitransparent"]
1266+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
12671267
#[stable(feature = "rust1", since = "1.0.0")]
12681268
#[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
12691269
pub macro RustcDecodable($item:item) { /* compiler built-in */ }
12701270

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

src/libcore/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub trait Copy : Clone {
290290

291291
/// Derive macro generating an impl of the trait `Copy`.
292292
#[rustc_builtin_macro]
293-
#[rustc_macro_transparency = "semitransparent"]
293+
#[cfg_attr(boostrap_stdarch_ignore_this, rustc_macro_transparency = "semitransparent")]
294294
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
295295
#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]
296296
pub macro Copy($item:item) { /* compiler built-in */ }

src/librustc/hir/lowering/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,6 @@ impl LoweringContext<'_> {
984984
volatile: asm.volatile,
985985
alignstack: asm.alignstack,
986986
dialect: asm.dialect,
987-
ctxt: asm.ctxt,
988987
};
989988

990989
let outputs = asm.outputs

0 commit comments

Comments
 (0)