Skip to content

StrInterner exposes unsafe functions as safe #17181

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

Closed
tbu- opened this issue Sep 12, 2014 · 1 comment · Fixed by #17221
Closed

StrInterner exposes unsafe functions as safe #17181

tbu- opened this issue Sep 12, 2014 · 1 comment · Fixed by #17221

Comments

@tbu-
Copy link
Contributor

tbu- commented Sep 12, 2014

The StrInterner from librustc has two conflicting methods:

/// Returns this string with lifetime tied to the interner.
/// Since strings may never be removed from the interner,
/// this is safe.
fn get_ref<'a>(&'a self, idx: Name) -> &'a str;

And

fn clear(&self);
@bkoropoff
Copy link
Contributor

I'll take a crack at this if you haven't already

bkoropoff added a commit to bkoropoff/rust that referenced this issue Sep 13, 2014
The string slices returned by `get_ref` can actually be
invalidated by calling `clear`.  Since this method is unused,
it is easiest to simply remove it.

Closes rust-lang#17181
bors added a commit that referenced this issue Sep 15, 2014
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants