Skip to content

Commit

Permalink
Remove the AsRef impl for SymbolStr.
Browse files Browse the repository at this point in the history
Because it's highly magical, which goes against the goal of keeping
`SymbolStr` simple. Plus it's only used in a handful of places that
only require minor changes.
  • Loading branch information
nnethercote committed Nov 1, 2019
1 parent b9cef69 commit d0db290
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/command.rs
Expand Up @@ -53,7 +53,7 @@ impl Command {
}

pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
self.arg(&arg.as_str());
self.arg(&*arg.as_str());
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/parse/parser/module.rs
Expand Up @@ -210,7 +210,7 @@ impl<'a> Parser<'a> {
// `/` to `\`.
#[cfg(windows)]
let s = s.replace("/", "\\");
Some(dir_path.join(s))
Some(dir_path.join(&*s))
} else {
None
}
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<'a> Parser<'a> {

fn push_directory(&mut self, id: Ident, attrs: &[Attribute]) {
if let Some(path) = attr::first_attr_value_str_by_name(attrs, sym::path) {
self.directory.path.to_mut().push(&path.as_str());
self.directory.path.to_mut().push(&*path.as_str());
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
} else {
// We have to push on the current module name in the case of relative
Expand All @@ -325,10 +325,10 @@ impl<'a> Parser<'a> {
// directory path to `/x/y/z`, not `/x/z` with a relative offset of `y`.
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
if let Some(ident) = relative.take() { // remove the relative offset
self.directory.path.to_mut().push(ident.as_str());
self.directory.path.to_mut().push(&*ident.as_str());
}
}
self.directory.path.to_mut().push(&id.as_str());
self.directory.path.to_mut().push(&*id.as_str());
}
}
}
10 changes: 0 additions & 10 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -1099,16 +1099,6 @@ pub struct SymbolStr {
string: &'static str,
}

impl<U: ?Sized> std::convert::AsRef<U> for SymbolStr
where
str: std::convert::AsRef<U>
{
#[inline]
fn as_ref(&self) -> &U {
self.string.as_ref()
}
}

// This impl allows a `SymbolStr` to be directly equated with a `String` or
// `&str`.
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {
Expand Down

0 comments on commit d0db290

Please sign in to comment.