Skip to content

Commit e57c0db

Browse files
committed
Eliminate Symbol::gensymed.
1 parent f6637f3 commit e57c0db

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

Diff for: src/libsyntax/std_inject.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,13 @@ pub fn maybe_inject_crates_ref(
6363

6464
// .rev() to preserve ordering above in combination with insert(0, ...)
6565
let alt_std_name = alt_std_name.map(Symbol::intern);
66-
for orig_name in names.iter().rev() {
67-
let orig_name = Symbol::intern(orig_name);
68-
let mut rename = orig_name;
66+
for orig_name_str in names.iter().rev() {
6967
// HACK(eddyb) gensym the injected crates on the Rust 2018 edition,
7068
// so they don't accidentally interfere with the new import paths.
71-
if rust_2018 {
72-
rename = orig_name.gensymed();
73-
}
74-
let orig_name = if rename != orig_name {
75-
Some(orig_name)
69+
let (rename, orig_name) = if rust_2018 {
70+
(Symbol::gensym(orig_name_str), Some(Symbol::intern(orig_name_str)))
7671
} else {
77-
None
72+
(Symbol::intern(orig_name_str), None)
7873
};
7974
krate.module.items.insert(0, P(ast::Item {
8075
attrs: vec![attr::mk_attr_outer(

Diff for: src/libsyntax_ext/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn expand_test_or_bench(
127127
])
128128
};
129129

130-
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name.gensymed(), sp),
130+
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp).gensym(),
131131
vec![
132132
// #[cfg(test)]
133133
cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![

Diff for: src/libsyntax_pos/symbol.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ impl Ident {
677677
}
678678

679679
pub fn gensym(self) -> Ident {
680-
Ident::new(self.name.gensymed(), self.span)
680+
let name = with_interner(|interner| interner.gensymed(self.name));
681+
Ident::new(name, self.span)
681682
}
682683

683684
pub fn gensym_if_underscore(self) -> Ident {
@@ -787,10 +788,6 @@ impl Symbol {
787788
with_interner(|interner| interner.gensym(string))
788789
}
789790

790-
pub fn gensymed(self) -> Self {
791-
with_interner(|interner| interner.gensymed(self))
792-
}
793-
794791
pub fn as_str(self) -> LocalInternedString {
795792
with_interner(|interner| unsafe {
796793
LocalInternedString {

0 commit comments

Comments
 (0)