Skip to content

Commit d0db290

Browse files
committed
Remove the AsRef impl for SymbolStr.
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.
1 parent b9cef69 commit d0db290

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

Diff for: src/librustc_codegen_ssa/back/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Command {
5353
}
5454

5555
pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
56-
self.arg(&arg.as_str());
56+
self.arg(&*arg.as_str());
5757
self
5858
}
5959

Diff for: src/libsyntax/parse/parser/module.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a> Parser<'a> {
210210
// `/` to `\`.
211211
#[cfg(windows)]
212212
let s = s.replace("/", "\\");
213-
Some(dir_path.join(s))
213+
Some(dir_path.join(&*s))
214214
} else {
215215
None
216216
}
@@ -314,7 +314,7 @@ impl<'a> Parser<'a> {
314314

315315
fn push_directory(&mut self, id: Ident, attrs: &[Attribute]) {
316316
if let Some(path) = attr::first_attr_value_str_by_name(attrs, sym::path) {
317-
self.directory.path.to_mut().push(&path.as_str());
317+
self.directory.path.to_mut().push(&*path.as_str());
318318
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
319319
} else {
320320
// We have to push on the current module name in the case of relative
@@ -325,10 +325,10 @@ impl<'a> Parser<'a> {
325325
// directory path to `/x/y/z`, not `/x/z` with a relative offset of `y`.
326326
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
327327
if let Some(ident) = relative.take() { // remove the relative offset
328-
self.directory.path.to_mut().push(ident.as_str());
328+
self.directory.path.to_mut().push(&*ident.as_str());
329329
}
330330
}
331-
self.directory.path.to_mut().push(&id.as_str());
331+
self.directory.path.to_mut().push(&*id.as_str());
332332
}
333333
}
334334
}

Diff for: src/libsyntax_pos/symbol.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1099,16 +1099,6 @@ pub struct SymbolStr {
10991099
string: &'static str,
11001100
}
11011101

1102-
impl<U: ?Sized> std::convert::AsRef<U> for SymbolStr
1103-
where
1104-
str: std::convert::AsRef<U>
1105-
{
1106-
#[inline]
1107-
fn as_ref(&self) -> &U {
1108-
self.string.as_ref()
1109-
}
1110-
}
1111-
11121102
// This impl allows a `SymbolStr` to be directly equated with a `String` or
11131103
// `&str`.
11141104
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {

0 commit comments

Comments
 (0)