Skip to content

Commit b4afb38

Browse files
committed
Remove SymbolStr.
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
1 parent 0167c53 commit b4afb38

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/reorder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
3131
(&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
3232
// `extern crate foo as bar;`
3333
// ^^^ Comparing this.
34-
let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
35-
let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str);
36-
let result = a_orig_name.cmp(&b_orig_name);
34+
let a_orig_name = a_name.unwrap_or(a.ident.name);
35+
let b_orig_name = b_name.unwrap_or(b.ident.name);
36+
let result = a_orig_name.as_str().cmp(b_orig_name.as_str());
3737
if result != Ordering::Equal {
3838
return result;
3939
}

src/syntux/parser.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ pub(crate) enum ParserError {
9595

9696
impl<'a> Parser<'a> {
9797
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
98-
let path_string = first_attr_value_str_by_name(attrs, sym::path)?.as_str();
98+
let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
99+
let path_str = path_sym.as_str();
100+
99101
// On windows, the base path might have the form
100102
// `\\?\foo\bar` in which case it does not tolerate
101103
// mixed `/` and `\` separators, so canonicalize
102104
// `/` to `\`.
103105
#[cfg(windows)]
104-
let path_string = path_string.replace("/", "\\");
106+
let path_str = path_str.replace("/", "\\");
105107

106-
Some(path.join(&*path_string))
108+
Some(path.join(path_str))
107109
}
108110

109111
pub(crate) fn parse_file_as_module(

0 commit comments

Comments
 (0)