Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
This commit is contained in:
commit
a41a6925ba
140 changed files with 354 additions and 415 deletions
|
@ -1,4 +1,3 @@
|
|||
use std::cmp::Reverse;
|
||||
use std::ptr;
|
||||
|
||||
use rustc_ast::{self as ast, Path};
|
||||
|
@ -784,7 +783,7 @@ impl<'a> Resolver<'a> {
|
|||
});
|
||||
|
||||
// Make sure error reporting is deterministic.
|
||||
suggestions.sort_by_cached_key(|suggestion| suggestion.candidate.as_str());
|
||||
suggestions.sort_by(|a, b| a.candidate.as_str().partial_cmp(b.candidate.as_str()).unwrap());
|
||||
|
||||
match find_best_match_for_name(
|
||||
&suggestions.iter().map(|suggestion| suggestion.candidate).collect::<Vec<Symbol>>(),
|
||||
|
@ -1186,7 +1185,7 @@ impl<'a> Resolver<'a> {
|
|||
("", " from prelude")
|
||||
} else if b.is_extern_crate()
|
||||
&& !b.is_import()
|
||||
&& self.session.opts.externs.get(&ident.as_str()).is_some()
|
||||
&& self.session.opts.externs.get(ident.as_str()).is_some()
|
||||
{
|
||||
("", " passed with `--extern`")
|
||||
} else if add_built_in {
|
||||
|
@ -1481,12 +1480,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||
return None;
|
||||
}
|
||||
|
||||
// Sort extern crate names in reverse order to get
|
||||
// Sort extern crate names in *reverse* order to get
|
||||
// 1) some consistent ordering for emitted diagnostics, and
|
||||
// 2) `std` suggestions before `core` suggestions.
|
||||
let mut extern_crate_names =
|
||||
self.r.extern_prelude.iter().map(|(ident, _)| ident.name).collect::<Vec<_>>();
|
||||
extern_crate_names.sort_by_key(|name| Reverse(name.as_str()));
|
||||
extern_crate_names.sort_by(|a, b| b.as_str().partial_cmp(a.as_str()).unwrap());
|
||||
|
||||
for name in extern_crate_names.into_iter() {
|
||||
// Replace first ident with a crate name and check if that is valid.
|
||||
|
|
|
@ -231,7 +231,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
|
||||
let is_assoc_fn = self.self_type_is_available(span);
|
||||
// Emit help message for fake-self from other languages (e.g., `this` in Javascript).
|
||||
if ["this", "my"].contains(&&*item_str.as_str()) && is_assoc_fn {
|
||||
if ["this", "my"].contains(&item_str.as_str()) && is_assoc_fn {
|
||||
err.span_suggestion_short(
|
||||
span,
|
||||
"you might have meant to use `self` here instead",
|
||||
|
@ -1358,7 +1358,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
|
||||
let name = path[path.len() - 1].ident.name;
|
||||
// Make sure error reporting is deterministic.
|
||||
names.sort_by_cached_key(|suggestion| suggestion.candidate.as_str());
|
||||
names.sort_by(|a, b| a.candidate.as_str().partial_cmp(b.candidate.as_str()).unwrap());
|
||||
|
||||
match find_best_match_for_name(
|
||||
&names.iter().map(|suggestion| suggestion.candidate).collect::<Vec<Symbol>>(),
|
||||
|
@ -1377,7 +1377,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
fn likely_rust_type(path: &[Segment]) -> Option<Symbol> {
|
||||
let name = path[path.len() - 1].ident.as_str();
|
||||
// Common Java types
|
||||
Some(match &*name {
|
||||
Some(match name {
|
||||
"byte" => sym::u8, // In Java, bytes are signed, but in practice one almost always wants unsigned bytes.
|
||||
"short" => sym::i16,
|
||||
"boolean" => sym::bool,
|
||||
|
@ -2345,7 +2345,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
_ => None,
|
||||
});
|
||||
}
|
||||
suggest_existing(err, &name.as_str()[..], suggs);
|
||||
suggest_existing(err, name.as_str(), suggs);
|
||||
}
|
||||
[] => {
|
||||
let mut suggs = Vec::new();
|
||||
|
|
|
@ -689,11 +689,11 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
hir_id: hir::HirId,
|
||||
) {
|
||||
let name = match fk {
|
||||
intravisit::FnKind::ItemFn(id, _, _, _) => id.as_str(),
|
||||
intravisit::FnKind::Method(id, _, _) => id.as_str(),
|
||||
intravisit::FnKind::Closure => Symbol::intern("closure").as_str(),
|
||||
intravisit::FnKind::ItemFn(id, _, _, _) => id.name,
|
||||
intravisit::FnKind::Method(id, _, _) => id.name,
|
||||
intravisit::FnKind::Closure => sym::closure,
|
||||
};
|
||||
let name: &str = &name;
|
||||
let name = name.as_str();
|
||||
let span = span!(Level::DEBUG, "visit_fn", name);
|
||||
let _enter = span.enter();
|
||||
match fk {
|
||||
|
|
|
@ -3481,7 +3481,7 @@ fn names_to_string(names: &[Symbol]) -> String {
|
|||
if Ident::with_dummy_span(*name).is_raw_guess() {
|
||||
result.push_str("r#");
|
||||
}
|
||||
result.push_str(&name.as_str());
|
||||
result.push_str(name.as_str());
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
|
|||
path_str.push_str("::");
|
||||
}
|
||||
if segment.ident.name != kw::PathRoot {
|
||||
path_str.push_str(&segment.ident.as_str())
|
||||
path_str.push_str(segment.ident.as_str())
|
||||
}
|
||||
}
|
||||
Symbol::intern(&path_str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue