Skip to content

Commit a41a692

Browse files
committed
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr` This was originally proposed in #74554 (comment). 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`
2 parents 8f54061 + b1c934e commit a41a692

File tree

140 files changed

+354
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+354
-415
lines changed

compiler/rustc_ast/src/util/literal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ impl LitKind {
3535
LitKind::Bool(symbol == kw::True)
3636
}
3737
token::Byte => {
38-
return unescape_byte(&symbol.as_str())
38+
return unescape_byte(symbol.as_str())
3939
.map(LitKind::Byte)
4040
.map_err(|_| LitError::LexerError);
4141
}
4242
token::Char => {
43-
return unescape_char(&symbol.as_str())
43+
return unescape_char(symbol.as_str())
4444
.map(LitKind::Char)
4545
.map_err(|_| LitError::LexerError);
4646
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12781278
}
12791279

12801280
pub(super) fn lower_abi(&mut self, abi: StrLit) -> abi::Abi {
1281-
abi::lookup(&abi.symbol_unescaped.as_str()).unwrap_or_else(|| {
1281+
abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|| {
12821282
self.error_on_invalid_abi(abi);
12831283
abi::Abi::Rust
12841284
})

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ impl<'a> AstValidator<'a> {
580580

581581
/// An item in `extern { ... }` cannot use non-ascii identifier.
582582
fn check_foreign_item_ascii_only(&self, ident: Ident) {
583-
let symbol_str = ident.as_str();
584-
if !symbol_str.is_ascii() {
583+
if !ident.as_str().is_ascii() {
585584
let n = 83942;
586585
self.err_handler()
587586
.struct_span_err(

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a> PostExpansionVisitor<'a> {
6161
fn check_abi(&self, abi: ast::StrLit) {
6262
let ast::StrLit { symbol_unescaped, span, .. } = abi;
6363

64-
match &*symbol_unescaped.as_str() {
64+
match symbol_unescaped.as_str() {
6565
// Stable
6666
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
6767
| "system" => {}

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn literal_to_string(lit: token::Lit) -> String {
204204
};
205205

206206
if let Some(suffix) = suffix {
207-
out.push_str(&suffix.as_str())
207+
out.push_str(suffix.as_str())
208208
}
209209

210210
out
@@ -384,7 +384,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
384384
}
385385

386386
fn print_symbol(&mut self, sym: Symbol, style: ast::StrStyle) {
387-
self.print_string(&sym.as_str(), style);
387+
self.print_string(sym.as_str(), style);
388388
}
389389

390390
fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) {

compiler/rustc_attr/src/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ where
236236

237237
// These unwraps are safe because `get` ensures the meta item
238238
// is a name/value pair string literal.
239-
issue_num = match &*issue.unwrap().as_str() {
239+
issue_num = match issue.unwrap().as_str() {
240240
"none" => None,
241241
issue => {
242242
let emit_diag = |msg: &str| {
@@ -301,7 +301,7 @@ where
301301

302302
match (feature, reason, issue) {
303303
(Some(feature), reason, Some(_)) => {
304-
if !rustc_lexer::is_ident(&feature.as_str()) {
304+
if !rustc_lexer::is_ident(feature.as_str()) {
305305
handle_errors(
306306
&sess.parse_sess,
307307
attr.span,
@@ -535,7 +535,7 @@ pub fn eval_condition(
535535
return false;
536536
}
537537
};
538-
let min_version = match parse_version(&min_version.as_str(), false) {
538+
let min_version = match parse_version(min_version.as_str(), false) {
539539
Some(ver) => ver,
540540
None => {
541541
sess.span_diagnostic

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
416416
tcx,
417417
generics,
418418
&mut err,
419-
&param.name.as_str(),
419+
param.name.as_str(),
420420
"Copy",
421421
None,
422422
);

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
206206
{
207207
let local_info = &self.body.local_decls[local].local_info;
208208
if let Some(box LocalInfo::StaticRef { def_id, .. }) = *local_info {
209-
buf.push_str(&self.infcx.tcx.item_name(def_id).as_str());
209+
buf.push_str(self.infcx.tcx.item_name(def_id).as_str());
210210
} else {
211211
unreachable!();
212212
}
@@ -318,7 +318,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
318318
let decl = &self.body.local_decls[local];
319319
match self.local_names[local] {
320320
Some(name) if !decl.from_compiler_desugaring() => {
321-
buf.push_str(&name.as_str());
321+
buf.push_str(name.as_str());
322322
Ok(())
323323
}
324324
_ => Err(()),

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
573573
template_snippet.as_ref().map(|s| Symbol::intern(s)),
574574
template_sp,
575575
));
576-
let template_str = &template_str.as_str();
576+
let template_str = template_str.as_str();
577577

578578
if let Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) = ecx.sess.asm_arch {
579579
let find_span = |needle: &str| -> Span {

compiler/rustc_builtin_macros/src/concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn expand_concat(
2121
match e.kind {
2222
ast::ExprKind::Lit(ref lit) => match lit.kind {
2323
ast::LitKind::Str(ref s, _) | ast::LitKind::Float(ref s, _) => {
24-
accumulator.push_str(&s.as_str());
24+
accumulator.push_str(s.as_str());
2525
}
2626
ast::LitKind::Char(c) => {
2727
accumulator.push(c);

0 commit comments

Comments
 (0)