Rollup merge of #92743 - bjorn3:less_symbol_intern, r=camelid

Use pre-interned symbols in a couple of places

Re-open of https://github.com/rust-lang/rust/pull/92733 as bors glitched.
This commit is contained in:
Matthias Krüger 2022-01-15 02:25:17 +01:00 committed by GitHub
commit 8326f3f317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 13 deletions

View File

@ -11,7 +11,7 @@ use rustc_hir::def::Res;
use rustc_hir::definitions::DefPathData; use rustc_hir::definitions::DefPathData;
use rustc_span::hygiene::ExpnId; use rustc_span::hygiene::ExpnId;
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned}; use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::symbol::{sym, Ident};
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;
impl<'hir> LoweringContext<'_, 'hir> { impl<'hir> LoweringContext<'_, 'hir> {
@ -1204,11 +1204,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
}; };
let fields = self.arena.alloc_from_iter( let fields = self.arena.alloc_from_iter(
e1.iter().map(|e| ("start", e)).chain(e2.iter().map(|e| ("end", e))).map(|(s, e)| { e1.iter().map(|e| (sym::start, e)).chain(e2.iter().map(|e| (sym::end, e))).map(
let expr = self.lower_expr(&e); |(s, e)| {
let ident = Ident::new(Symbol::intern(s), self.lower_span(e.span)); let expr = self.lower_expr(&e);
self.expr_field(ident, expr, e.span) let ident = Ident::new(s, self.lower_span(e.span));
}), self.expr_field(ident, expr, e.span)
},
),
); );
hir::ExprKind::Struct( hir::ExprKind::Struct(

View File

@ -12,7 +12,7 @@ use rustc_middle::ty::print::Print;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind}; use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, Const, DefIdTree, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder}; use rustc_middle::ty::{self, Const, DefIdTree, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder};
use rustc_span::symbol::kw; use rustc_span::symbol::kw;
use rustc_span::Span; use rustc_span::{sym, Span};
use std::borrow::Cow; use std::borrow::Cow;
struct FindHirNodeVisitor<'a, 'tcx> { struct FindHirNodeVisitor<'a, 'tcx> {
@ -1003,9 +1003,9 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
| ty::Opaque(..) | ty::Opaque(..)
| ty::Projection(_) | ty::Projection(_)
| ty::Never => t.super_fold_with(self), | ty::Never => t.super_fold_with(self),
ty::Array(ty, c) => self ty::Array(ty, c) => {
.tcx() self.tcx().mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, sym::N)))
.mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, Symbol::intern("N")))), }
// We don't want to hide type params that haven't been resolved yet. // We don't want to hide type params that haven't been resolved yet.
// This would be the type that will be written out with the type param // This would be the type that will be written out with the type param
// name in the output. // name in the output.

View File

@ -208,6 +208,7 @@ symbols! {
LinkedList, LinkedList,
LintPass, LintPass,
Mutex, Mutex,
N,
None, None,
Ok, Ok,
Option, Option,
@ -327,6 +328,7 @@ symbols! {
array, array,
arrays, arrays,
as_ptr, as_ptr,
as_ref,
as_str, as_str,
asm, asm,
asm_const, asm_const,
@ -593,6 +595,7 @@ symbols! {
enable, enable,
enclosing_scope, enclosing_scope,
encode, encode,
end,
env, env,
eq, eq,
ermsb_target_feature, ermsb_target_feature,

View File

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