about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2021-12-15 08:32:21 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2021-12-15 13:30:26 +1100
commitb4afb38f2f506e9f4d558449e2e303340d4fdb35 (patch)
treebfe83cb5041b17c091435c989e12fbd90e354811
parent0167c5303f681eacef0e15aa3315ab601438a3e5 (diff)
downloadrust-b4afb38f2f506e9f4d558449e2e303340d4fdb35.tar.gz
rust-b4afb38f2f506e9f4d558449e2e303340d4fdb35.zip
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`!
-rw-r--r--src/reorder.rs6
-rw-r--r--src/syntux/parser.rs8
2 files changed, 8 insertions, 6 deletions
diff --git a/src/reorder.rs b/src/reorder.rs
index 0732c8ee700..fe8e5c6b61e 100644
--- a/src/reorder.rs
+++ b/src/reorder.rs
@@ -31,9 +31,9 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
         (&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
             // `extern crate foo as bar;`
             //               ^^^ Comparing this.
-            let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
-            let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str);
-            let result = a_orig_name.cmp(&b_orig_name);
+            let a_orig_name = a_name.unwrap_or(a.ident.name);
+            let b_orig_name = b_name.unwrap_or(b.ident.name);
+            let result = a_orig_name.as_str().cmp(b_orig_name.as_str());
             if result != Ordering::Equal {
                 return result;
             }
diff --git a/src/syntux/parser.rs b/src/syntux/parser.rs
index d1bb2f80004..23d065c9cc9 100644
--- a/src/syntux/parser.rs
+++ b/src/syntux/parser.rs
@@ -95,15 +95,17 @@ pub(crate) enum ParserError {
 
 impl<'a> Parser<'a> {
     pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
-        let path_string = first_attr_value_str_by_name(attrs, sym::path)?.as_str();
+        let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
+        let path_str = path_sym.as_str();
+
         // On windows, the base path might have the form
         // `\\?\foo\bar` in which case it does not tolerate
         // mixed `/` and `\` separators, so canonicalize
         // `/` to `\`.
         #[cfg(windows)]
-        let path_string = path_string.replace("/", "\\");
+        let path_str = path_str.replace("/", "\\");
 
-        Some(path.join(&*path_string))
+        Some(path.join(path_str))
     }
 
     pub(crate) fn parse_file_as_module(