mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
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`!
This commit is contained in:
parent
0167c5303f
commit
b4afb38f2f
@ -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;
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user