Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move gensym operations from `Symbol` to `Ident` #60903

Merged
merged 3 commits into from May 21, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Eliminate `Symbol::gensymed`.

  • Loading branch information...
nnethercote committed May 17, 2019
commit e57c0dbeb72cf631930429a20badd41290bb0608
@@ -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(
@@ -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![
@@ -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 {
@@ -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 {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.