Skip to content

Commit

Permalink
auto merge of #17221 : bkoropoff/rust/strinterner-unsafe, r=sfackler
Browse files Browse the repository at this point in the history
The `StrInterner::clear()` method takes self immutably but can invalidate references returned by `StrInterner::get_ref`. Since `get_ref` is unused, just remove it.

Closes #17181
  • Loading branch information
bors committed Sep 15, 2014
2 parents 382fc45 + 26d716a commit 63eaba2
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/libsyntax/util/interner.rs
Expand Up @@ -19,7 +19,6 @@ use std::cell::RefCell;
use std::cmp::Equiv;
use std::fmt;
use std::hash::Hash;
use std::mem;
use std::rc::Rc;

pub struct Interner<T> {
Expand Down Expand Up @@ -192,16 +191,6 @@ impl StrInterner {
(*self.vect.borrow().get(idx.uint())).clone()
}

/// Returns this string with lifetime tied to the interner. Since
/// strings may never be removed from the interner, this is safe.
pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str {
let vect = self.vect.borrow();
let s: &str = vect.get(idx.uint()).as_slice();
unsafe {
mem::transmute(s)
}
}

pub fn len(&self) -> uint {
self.vect.borrow().len()
}
Expand Down

0 comments on commit 63eaba2

Please sign in to comment.