Skip to content

Commit ec9c949

Browse files
committed
Use pre-interned symbols in a couple of places
1 parent d63a8d9 commit ec9c949

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def::Res;
1111
use rustc_hir::definitions::DefPathData;
1212
use rustc_span::hygiene::ExpnId;
1313
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
14-
use rustc_span::symbol::{sym, Ident, Symbol};
14+
use rustc_span::symbol::{sym, Ident};
1515
use rustc_span::DUMMY_SP;
1616

1717
impl<'hir> LoweringContext<'_, 'hir> {
@@ -1204,11 +1204,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
12041204
};
12051205

12061206
let fields = self.arena.alloc_from_iter(
1207-
e1.iter().map(|e| ("start", e)).chain(e2.iter().map(|e| ("end", e))).map(|(s, e)| {
1208-
let expr = self.lower_expr(&e);
1209-
let ident = Ident::new(Symbol::intern(s), self.lower_span(e.span));
1210-
self.expr_field(ident, expr, e.span)
1211-
}),
1207+
e1.iter().map(|e| (sym::start, e)).chain(e2.iter().map(|e| (sym::end, e))).map(
1208+
|(s, e)| {
1209+
let expr = self.lower_expr(&e);
1210+
let ident = Ident::new(s, self.lower_span(e.span));
1211+
self.expr_field(ident, expr, e.span)
1212+
},
1213+
),
12121214
);
12131215

12141216
hir::ExprKind::Struct(

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::ty::print::Print;
1212
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
1313
use rustc_middle::ty::{self, Const, DefIdTree, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder};
1414
use rustc_span::symbol::kw;
15-
use rustc_span::Span;
15+
use rustc_span::{sym, Span};
1616
use std::borrow::Cow;
1717

1818
struct FindHirNodeVisitor<'a, 'tcx> {
@@ -1003,9 +1003,9 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
10031003
| ty::Opaque(..)
10041004
| ty::Projection(_)
10051005
| ty::Never => t.super_fold_with(self),
1006-
ty::Array(ty, c) => self
1007-
.tcx()
1008-
.mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, Symbol::intern("N")))),
1006+
ty::Array(ty, c) => {
1007+
self.tcx().mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, sym::N)))
1008+
}
10091009
// We don't want to hide type params that haven't been resolved yet.
10101010
// This would be the type that will be written out with the type param
10111011
// name in the output.

compiler/rustc_span/src/symbol.rs

+3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ symbols! {
208208
LinkedList,
209209
LintPass,
210210
Mutex,
211+
N,
211212
None,
212213
Ok,
213214
Option,
@@ -327,6 +328,7 @@ symbols! {
327328
array,
328329
arrays,
329330
as_ptr,
331+
as_ref,
330332
as_str,
331333
asm,
332334
asm_const,
@@ -592,6 +594,7 @@ symbols! {
592594
enable,
593595
enclosing_scope,
594596
encode,
597+
end,
595598
env,
596599
eq,
597600
ermsb_target_feature,

compiler/rustc_typeck/src/check/method/suggest.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty::print::with_crate_prefix;
1515
use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable};
1616
use rustc_span::lev_distance;
1717
use rustc_span::symbol::{kw, sym, Ident};
18-
use rustc_span::{source_map, FileName, MultiSpan, Span, Symbol};
18+
use rustc_span::{source_map, FileName, MultiSpan, Span};
1919
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
2020
use rustc_trait_selection::traits::{
2121
FulfillmentError, Obligation, ObligationCause, ObligationCauseCode,
@@ -1524,8 +1524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15241524
// Explicitly ignore the `Pin::as_ref()` method as `Pin` does not
15251525
// implement the `AsRef` trait.
15261526
let skip = skippable.contains(&did)
1527-
|| (("Pin::new" == *pre)
1528-
&& (Symbol::intern("as_ref") == item_name.name));
1527+
|| (("Pin::new" == *pre) && (sym::as_ref == item_name.name));
15291528
// Make sure the method is defined for the *actual* receiver: we don't
15301529
// want to treat `Box<Self>` as a receiver if it only works because of
15311530
// an autoderef to `&self`

0 commit comments

Comments
 (0)