Skip to content

Commit 1edf201

Browse files
committed
Avoid some unnecessary symbol interning.
- `Ident::from_str_and_span` -> `Ident::new` when the string is pre-interned. - `Ident::from_str` -> `Ident::with_dummy_span` when the string is pre-interned. - `_d` and `_e` are unused.
1 parent 4a1f445 commit 1edf201

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

compiler/rustc_builtin_macros/src/alloc_error_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ pub(crate) fn expand(
6262
fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span) -> Stmt {
6363
let usize = cx.path_ident(span, Ident::new(sym::usize, span));
6464
let ty_usize = cx.ty_path(usize);
65-
let size = Ident::from_str_and_span("size", span);
66-
let align = Ident::from_str_and_span("align", span);
65+
let size = Ident::new(sym::size, span);
66+
let align = Ident::new(sym::align, span);
6767

6868
let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]);
6969
let layout_new = cx.expr_path(cx.path(span, layout_new));

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,10 @@ mod llvm_enzyme {
652652
exprs = ecx.expr_call(new_decl_span, bb_call_expr, thin_vec![exprs]);
653653
} else {
654654
let q = QSelf { ty: d_ret_ty, path_span: span, position: 0 };
655-
let y =
656-
ExprKind::Path(Some(P(q)), ecx.path_ident(span, Ident::from_str("default")));
655+
let y = ExprKind::Path(
656+
Some(P(q)),
657+
ecx.path_ident(span, Ident::with_dummy_span(kw::Default)),
658+
);
657659
let default_call_expr = ecx.expr(span, y);
658660
let default_call_expr =
659661
ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]);

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_hir::{
2222
TyPatKind,
2323
};
2424
use rustc_span::source_map::SourceMap;
25-
use rustc_span::{FileName, Ident, Span, Symbol, kw};
25+
use rustc_span::{FileName, Ident, Span, Symbol, kw, sym};
2626
use {rustc_ast as ast, rustc_hir as hir};
2727

2828
pub fn id_to_string(cx: &dyn rustc_hir::intravisit::HirTyCtxt<'_>, hir_id: HirId) -> String {
@@ -1517,7 +1517,7 @@ impl<'a> State<'a> {
15171517
self.bopen(ib);
15181518

15191519
// Print `let _t = $init;`:
1520-
let temp = Ident::from_str("_t");
1520+
let temp = Ident::with_dummy_span(sym::_t);
15211521
self.print_local(false, Some(init), None, |this| this.print_ident(temp));
15221522
self.word(";");
15231523

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ symbols! {
396396
__S,
397397
__awaitee,
398398
__try_var,
399-
_d,
400-
_e,
399+
_t,
401400
_task_context,
402401
a32,
403402
aarch64_target_feature,

src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
5656
.and_then(|trait_id| {
5757
cx.tcx.associated_items(trait_id).find_by_ident_and_kind(
5858
cx.tcx,
59-
Ident::from_str("Output"),
59+
Ident::with_dummy_span(sym::Output),
6060
ty::AssocTag::Type,
6161
trait_id,
6262
)

0 commit comments

Comments
 (0)