Skip to content

Commit 5641a9d

Browse files
committed
[DO NOT MERGE] Remove backwards-compatibility hack for $name idents
Fixes rust-lang#74616 There are still a large number of outstanding regressions, so this PR can't be merged yet. I'm opening it to generate a newer 'try' build for crater authors to test with. Eventually, we'll want to do a crater run for this PR.
1 parent 0301700 commit 5641a9d

File tree

4 files changed

+10
-45
lines changed

4 files changed

+10
-45
lines changed

src/librustc_ast/token.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ use crate::tokenstream::TokenTree;
1111
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_macros::HashStable_Generic;
14-
use rustc_span::hygiene::ExpnKind;
15-
use rustc_span::source_map::SourceMap;
1614
use rustc_span::symbol::{kw, sym};
1715
use rustc_span::symbol::{Ident, Symbol};
18-
use rustc_span::{self, FileName, RealFileName, Span, DUMMY_SP};
16+
use rustc_span::{self, Span, DUMMY_SP};
1917
use std::borrow::Cow;
2018
use std::{fmt, mem};
2119

@@ -810,31 +808,6 @@ impl Nonterminal {
810808
}
811809
false
812810
}
813-
814-
// See issue #74616 for details
815-
pub fn ident_name_compatibility_hack(
816-
&self,
817-
orig_span: Span,
818-
source_map: &SourceMap,
819-
) -> Option<(Ident, bool)> {
820-
if let NtIdent(ident, is_raw) = self {
821-
if let ExpnKind::Macro(_, macro_name) = orig_span.ctxt().outer_expn_data().kind {
822-
let filename = source_map.span_to_filename(orig_span);
823-
if let FileName::Real(RealFileName::Named(path)) = filename {
824-
if (path.ends_with("time-macros-impl/src/lib.rs")
825-
&& macro_name == sym::impl_macros)
826-
|| (path.ends_with("js-sys/src/lib.rs") && macro_name == sym::arrays)
827-
{
828-
let snippet = source_map.span_to_snippet(orig_span);
829-
if snippet.as_deref() == Ok("$name") {
830-
return Some((*ident, *is_raw));
831-
}
832-
}
833-
}
834-
}
835-
}
836-
None
837-
}
838811
}
839812

840813
impl PartialEq for Nonterminal {

src/librustc_expand/proc_macro_server.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,13 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
173173
}
174174

175175
Interpolated(nt) => {
176-
if let Some((name, is_raw)) =
177-
nt.ident_name_compatibility_hack(span, sess.source_map())
178-
{
179-
TokenTree::Ident(Ident::new(sess, name.name, is_raw, name.span))
180-
} else {
181-
let stream = nt_to_tokenstream(&nt, sess, span);
182-
TokenTree::Group(Group {
183-
delimiter: Delimiter::None,
184-
stream,
185-
span: DelimSpan::from_single(span),
186-
flatten: nt.pretty_printing_compatibility_hack(),
187-
})
188-
}
176+
let stream = nt_to_tokenstream(&nt, sess, span);
177+
TokenTree::Group(Group {
178+
delimiter: Delimiter::None,
179+
stream,
180+
span: DelimSpan::from_single(span),
181+
flatten: nt.pretty_printing_compatibility_hack(),
182+
})
189183
}
190184

191185
OpenDelim(..) | CloseDelim(..) => unreachable!(),

src/librustc_span/symbol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ symbols! {
258258
arith_offset,
259259
arm_target_feature,
260260
array,
261-
arrays,
262261
as_str,
263262
asm,
264263
assert,
@@ -573,7 +572,6 @@ symbols! {
573572
ignore,
574573
impl_header_lifetime_elision,
575574
impl_lint_pass,
576-
impl_macros,
577575
impl_trait_in_bindings,
578576
import_shadowing,
579577
in_band_lifetimes,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl/src/lib.rs:5:21: 5:27 (#5) }, Ident { ident: "One", span: $DIR/time-macros-impl/src/lib.rs:5:28: 5:31 (#5) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:27:18: 27:21 (#0) }], span: $DIR/time-macros-impl/src/lib.rs:5:31: 5:38 (#5) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl/src/lib.rs:5:38: 5:39 (#5) }]
2-
Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys/src/lib.rs:5:21: 5:27 (#9) }, Ident { ident: "Two", span: $DIR/js-sys/src/lib.rs:5:28: 5:31 (#9) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:28:13: 28:16 (#0) }], span: $DIR/js-sys/src/lib.rs:5:31: 5:38 (#9) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys/src/lib.rs:5:38: 5:39 (#9) }]
1+
Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl/src/lib.rs:5:21: 5:27 (#5) }, Ident { ident: "One", span: $DIR/time-macros-impl/src/lib.rs:5:28: 5:31 (#5) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:27:18: 27:21 (#0) }], span: $DIR/time-macros-impl/src/lib.rs:5:32: 5:37 (#5) }], span: $DIR/time-macros-impl/src/lib.rs:5:31: 5:38 (#5) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl/src/lib.rs:5:38: 5:39 (#5) }]
2+
Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys/src/lib.rs:5:21: 5:27 (#9) }, Ident { ident: "Two", span: $DIR/js-sys/src/lib.rs:5:28: 5:31 (#9) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:28:13: 28:16 (#0) }], span: $DIR/js-sys/src/lib.rs:5:32: 5:37 (#9) }], span: $DIR/js-sys/src/lib.rs:5:31: 5:38 (#9) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys/src/lib.rs:5:38: 5:39 (#9) }]
33
Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/group-compat-hack.rs:21:21: 21:27 (#13) }, Ident { ident: "Three", span: $DIR/group-compat-hack.rs:21:28: 21:33 (#13) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:29:12: 29:15 (#0) }], span: $DIR/group-compat-hack.rs:21:34: 21:39 (#13) }], span: $DIR/group-compat-hack.rs:21:33: 21:40 (#13) }, Punct { ch: ';', spacing: Alone, span: $DIR/group-compat-hack.rs:21:40: 21:41 (#13) }]

0 commit comments

Comments
 (0)