Skip to content

Commit

Permalink
Eliminate Symbol::gensymed.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed May 20, 2019
1 parent f6637f3 commit e57c0db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
13 changes: 4 additions & 9 deletions src/libsyntax/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,13 @@ pub fn maybe_inject_crates_ref(

// .rev() to preserve ordering above in combination with insert(0, ...)
let alt_std_name = alt_std_name.map(Symbol::intern);
for orig_name in names.iter().rev() {
let orig_name = Symbol::intern(orig_name);
let mut rename = orig_name;
for orig_name_str in names.iter().rev() {
// HACK(eddyb) gensym the injected crates on the Rust 2018 edition,
// so they don't accidentally interfere with the new import paths.
if rust_2018 {
rename = orig_name.gensymed();
}
let orig_name = if rename != orig_name {
Some(orig_name)
let (rename, orig_name) = if rust_2018 {
(Symbol::gensym(orig_name_str), Some(Symbol::intern(orig_name_str)))
} else {
None
(Symbol::intern(orig_name_str), None)
};
krate.module.items.insert(0, P(ast::Item {
attrs: vec![attr::mk_attr_outer(
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn expand_test_or_bench(
])
};

let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name.gensymed(), sp),
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name, sp).gensym(),
vec![
// #[cfg(test)]
cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![
Expand Down
7 changes: 2 additions & 5 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ impl Ident {
}

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

pub fn gensym_if_underscore(self) -> Ident {
Expand Down Expand Up @@ -787,10 +788,6 @@ impl Symbol {
with_interner(|interner| interner.gensym(string))
}

pub fn gensymed(self) -> Self {
with_interner(|interner| interner.gensymed(self))
}

pub fn as_str(self) -> LocalInternedString {
with_interner(|interner| unsafe {
LocalInternedString {
Expand Down

0 comments on commit e57c0db

Please sign in to comment.