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:
bors 2021-12-19 09:31:37 +00:00
commit a41a6925ba
140 changed files with 354 additions and 415 deletions

View file

@ -171,7 +171,7 @@ fn get_features(
}
if let Some(allowed) = sess.opts.debugging_opts.allow_features.as_ref() {
if allowed.iter().all(|f| name.as_str() != *f) {
if allowed.iter().all(|f| name.as_str() != f) {
struct_span_err!(
span_handler,
mi.span(),

View file

@ -103,10 +103,10 @@ crate fn mod_dir_path(
if let DirOwnership::Owned { relative } = &mut dir_ownership {
if let Some(ident) = relative.take() {
// Remove the relative offset.
dir_path.push(&*ident.as_str());
dir_path.push(ident.as_str());
}
}
dir_path.push(&*ident.as_str());
dir_path.push(ident.as_str());
(dir_path, dir_ownership)
}
@ -170,8 +170,8 @@ fn mod_file_path_from_attr(
) -> Option<PathBuf> {
// Extract path string from first `#[path = "path_string"]` attribute.
let first_path = attrs.iter().find(|at| at.has_name(sym::path))?;
let path_string = match first_path.value_str() {
Some(s) => s.as_str(),
let path_sym = match first_path.value_str() {
Some(s) => s,
None => {
// This check is here mainly to catch attempting to use a macro,
// such as #[path = concat!(...)]. This isn't currently supported
@ -189,14 +189,16 @@ fn mod_file_path_from_attr(
}
};
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(dir_path.join(&*path_string))
Some(dir_path.join(path_str))
}
/// Returns a path to a module.

View file

@ -331,9 +331,9 @@ pub struct Ident {
impl Ident {
fn new(sess: &ParseSess, sym: Symbol, is_raw: bool, span: Span) -> Ident {
let sym = nfc_normalize(&sym.as_str());
let sym = nfc_normalize(sym.as_str());
let string = sym.as_str();
if !rustc_lexer::is_ident(&string) {
if !rustc_lexer::is_ident(string) {
panic!("`{:?}` is not a valid identifier", string)
}
if is_raw && !sym.can_be_raw() {