Convert some InternedString
s to Symbols
.
This avoids the needs for various conversions, and makes the code slightly faster, because `Symbol` comparisons and hashing is faster.
This commit is contained in:
parent
c23a7aa778
commit
02edd14cde
21 changed files with 77 additions and 77 deletions
|
@ -19,7 +19,7 @@ use crate::ty::query::Providers;
|
|||
use crate::util::nodemap::{NodeMap, FxHashSet};
|
||||
|
||||
use errors::FatalError;
|
||||
use syntax_pos::{Span, DUMMY_SP, symbol::InternedString, MultiSpan};
|
||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
||||
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
||||
|
@ -628,9 +628,9 @@ impl Generics {
|
|||
own_counts
|
||||
}
|
||||
|
||||
pub fn get_named(&self, name: InternedString) -> Option<&GenericParam> {
|
||||
pub fn get_named(&self, name: Symbol) -> Option<&GenericParam> {
|
||||
for param in &self.params {
|
||||
if name == param.name.ident().as_interned_str() {
|
||||
if name == param.name.ident().name {
|
||||
return Some(param);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ use std::cell::{Cell, Ref, RefCell, RefMut};
|
|||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax_pos::symbol::InternedString;
|
||||
use syntax_pos::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use self::combine::CombineFields;
|
||||
|
@ -392,7 +392,7 @@ pub enum RegionVariableOrigin {
|
|||
Coercion(Span),
|
||||
|
||||
/// Region variables created as the values for early-bound regions
|
||||
EarlyBoundRegion(Span, InternedString),
|
||||
EarlyBoundRegion(Span, Symbol),
|
||||
|
||||
/// Region variables created for bound regions
|
||||
/// in a function or method that is called
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
use crate::ty::{self, Ty, TyVid};
|
||||
|
||||
|
@ -49,7 +49,7 @@ pub enum TypeVariableOriginKind {
|
|||
MiscVariable,
|
||||
NormalizeProjectionType,
|
||||
TypeInference,
|
||||
TypeParameterDefinition(InternedString),
|
||||
TypeParameterDefinition(Symbol),
|
||||
|
||||
/// One of the upvars or closure kind parameters in a `ClosureSubsts`
|
||||
/// (before it has been determined).
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::mir::interpret::ConstValue;
|
|||
use rustc_data_structures::unify::{NoError, EqUnifyValue, UnifyKey, UnifyValue, UnificationTable};
|
||||
use rustc_data_structures::unify::InPlace;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use std::cmp;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -90,7 +90,7 @@ pub struct ConstVariableOrigin {
|
|||
pub enum ConstVariableOriginKind {
|
||||
MiscVariable,
|
||||
ConstInference,
|
||||
ConstParameterDefinition(InternedString),
|
||||
ConstParameterDefinition(Symbol),
|
||||
SubstitutionPlaceholder,
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
},
|
||||
GenericParamDefKind::Lifetime => continue,
|
||||
};
|
||||
let name = param.name.as_symbol();
|
||||
let name = param.name;
|
||||
flags.push((name, Some(value)));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::ty::subst::{Subst, InternalSubsts};
|
|||
use std::borrow::Cow;
|
||||
use std::iter::{self};
|
||||
use syntax::ast::{self};
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -560,7 +560,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// are implemented
|
||||
let unsized_self_ty: Ty<'tcx> = self.mk_ty_param(
|
||||
::std::u32::MAX,
|
||||
InternedString::intern("RustaceansAreAwesome"),
|
||||
Symbol::intern("RustaceansAreAwesome"),
|
||||
);
|
||||
|
||||
// `Receiver[Self => U]`
|
||||
|
|
|
@ -250,7 +250,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||
Position::ArgumentNamed(s) if s == sym::from_desugaring => (),
|
||||
// So is `{A}` if A is a type parameter
|
||||
Position::ArgumentNamed(s) => match generics.params.iter().find(|param| {
|
||||
param.name.as_symbol() == s
|
||||
param.name == s
|
||||
}) {
|
||||
Some(_) => (),
|
||||
None => {
|
||||
|
@ -289,7 +289,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||
},
|
||||
GenericParamDefKind::Lifetime => return None
|
||||
};
|
||||
let name = param.name.as_symbol();
|
||||
let name = param.name;
|
||||
Some((name, value))
|
||||
}).collect::<FxHashMap<Symbol, String>>();
|
||||
let empty_string = String::new();
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::traits;
|
|||
use crate::traits::project::Normalized;
|
||||
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use crate::ty::{self, Lift, Ty, TyCtxt};
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
@ -261,11 +261,11 @@ impl fmt::Display for traits::QuantifierKind {
|
|||
/// for debug output in tests anyway.
|
||||
struct BoundNamesCollector {
|
||||
// Just sort by name because `BoundRegion::BrNamed` does not have a `BoundVar` index anyway.
|
||||
regions: BTreeSet<InternedString>,
|
||||
regions: BTreeSet<Symbol>,
|
||||
|
||||
// Sort by `BoundVar` index, so usually this should be equivalent to the order given
|
||||
// by the list of type parameters.
|
||||
types: BTreeMap<u32, InternedString>,
|
||||
types: BTreeMap<u32, Symbol>,
|
||||
|
||||
binder_index: ty::DebruijnIndex,
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
|
|||
match bound_ty.kind {
|
||||
ty::BoundTyKind::Param(name) => name,
|
||||
ty::BoundTyKind::Anon =>
|
||||
InternedString::intern(&format!("^{}", bound_ty.var.as_u32()),
|
||||
Symbol::intern(&format!("^{}", bound_ty.var.as_u32()),
|
||||
),
|
||||
}
|
||||
);
|
||||
|
@ -340,7 +340,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
|
|||
}
|
||||
|
||||
ty::BoundRegion::BrAnon(var) => {
|
||||
self.regions.insert(InternedString::intern(&format!("'^{}", var)));
|
||||
self.regions.insert(Symbol::intern(&format!("'^{}", var)));
|
||||
}
|
||||
|
||||
_ => (),
|
||||
|
|
|
@ -72,7 +72,7 @@ use syntax::ast;
|
|||
use syntax::attr;
|
||||
use syntax::source_map::MultiSpan;
|
||||
use syntax::feature_gate;
|
||||
use syntax::symbol::{Symbol, InternedString, kw, sym};
|
||||
use syntax::symbol::{Symbol, kw, sym};
|
||||
use syntax_pos::Span;
|
||||
|
||||
pub struct AllArenas {
|
||||
|
@ -949,7 +949,7 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
f64: mk(Float(ast::FloatTy::F64)),
|
||||
self_param: mk(ty::Param(ty::ParamTy {
|
||||
index: 0,
|
||||
name: kw::SelfUpper.as_interned_str(),
|
||||
name: kw::SelfUpper,
|
||||
})),
|
||||
|
||||
trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),
|
||||
|
@ -2552,7 +2552,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_ty_param(self, index: u32, name: InternedString) -> Ty<'tcx> {
|
||||
pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx> {
|
||||
self.mk_ty(Param(ParamTy { index, name: name }))
|
||||
}
|
||||
|
||||
|
@ -2560,7 +2560,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
pub fn mk_const_param(
|
||||
self,
|
||||
index: u32,
|
||||
name: InternedString,
|
||||
name: Symbol,
|
||||
ty: Ty<'tcx>
|
||||
) -> &'tcx Const<'tcx> {
|
||||
self.mk_const(ty::Const {
|
||||
|
|
|
@ -849,7 +849,7 @@ impl ty::EarlyBoundRegion {
|
|||
/// Does this early bound region have a name? Early bound regions normally
|
||||
/// always have names except when using anonymous lifetimes (`'_`).
|
||||
pub fn has_name(&self) -> bool {
|
||||
self.name != kw::UnderscoreLifetime.as_interned_str()
|
||||
self.name != kw::UnderscoreLifetime
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,7 +866,7 @@ pub enum GenericParamDefKind {
|
|||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub struct GenericParamDef {
|
||||
pub name: InternedString,
|
||||
pub name: Symbol,
|
||||
pub def_id: DefId,
|
||||
pub index: u32,
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use rustc_apfloat::Float;
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr::{SignedInt, UnsignedInt};
|
||||
use syntax::symbol::{kw, InternedString};
|
||||
use syntax::symbol::{kw, Symbol};
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::fmt::{self, Write as _};
|
||||
|
@ -992,7 +992,7 @@ pub struct FmtPrinterData<'a, 'tcx, F> {
|
|||
empty_path: bool,
|
||||
in_value: bool,
|
||||
|
||||
used_region_names: FxHashSet<InternedString>,
|
||||
used_region_names: FxHashSet<Symbol>,
|
||||
region_index: usize,
|
||||
binder_depth: usize,
|
||||
|
||||
|
@ -1332,16 +1332,16 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
|||
|
||||
match *region {
|
||||
ty::ReEarlyBound(ref data) => {
|
||||
data.name.as_symbol() != kw::Invalid &&
|
||||
data.name.as_symbol() != kw::UnderscoreLifetime
|
||||
data.name != kw::Invalid &&
|
||||
data.name != kw::UnderscoreLifetime
|
||||
}
|
||||
|
||||
ty::ReLateBound(_, br) |
|
||||
ty::ReFree(ty::FreeRegion { bound_region: br, .. }) |
|
||||
ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
|
||||
if let ty::BrNamed(_, name) = br {
|
||||
if name.as_symbol() != kw::Invalid &&
|
||||
name.as_symbol() != kw::UnderscoreLifetime {
|
||||
if name != kw::Invalid &&
|
||||
name != kw::UnderscoreLifetime {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1397,7 +1397,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
|
|||
// `explain_region()` or `note_and_explain_region()`.
|
||||
match *region {
|
||||
ty::ReEarlyBound(ref data) => {
|
||||
if data.name.as_symbol() != kw::Invalid {
|
||||
if data.name != kw::Invalid {
|
||||
p!(write("{}", data.name));
|
||||
return Ok(self);
|
||||
}
|
||||
|
@ -1406,8 +1406,8 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
|
|||
ty::ReFree(ty::FreeRegion { bound_region: br, .. }) |
|
||||
ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
|
||||
if let ty::BrNamed(_, name) = br {
|
||||
if name.as_symbol() != kw::Invalid &&
|
||||
name.as_symbol() != kw::UnderscoreLifetime {
|
||||
if name != kw::Invalid &&
|
||||
name != kw::UnderscoreLifetime {
|
||||
p!(write("{}", name));
|
||||
return Ok(self);
|
||||
}
|
||||
|
@ -1474,11 +1474,11 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||
where
|
||||
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
|
||||
{
|
||||
fn name_by_region_index(index: usize) -> InternedString {
|
||||
fn name_by_region_index(index: usize) -> Symbol {
|
||||
match index {
|
||||
0 => InternedString::intern("'r"),
|
||||
1 => InternedString::intern("'s"),
|
||||
i => InternedString::intern(&format!("'t{}", i-2)),
|
||||
0 => Symbol::intern("'r"),
|
||||
1 => Symbol::intern("'s"),
|
||||
i => Symbol::intern(&format!("'t{}", i-2)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||
where T: TypeFoldable<'tcx>
|
||||
{
|
||||
|
||||
struct LateBoundRegionNameCollector<'a>(&'a mut FxHashSet<InternedString>);
|
||||
struct LateBoundRegionNameCollector<'a>(&'a mut FxHashSet<Symbol>);
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector<'_> {
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
|
||||
match *r {
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::marker::PhantomData;
|
|||
use std::ops::Range;
|
||||
use rustc_target::spec::abi;
|
||||
use syntax::ast::{self, Ident};
|
||||
use syntax::symbol::{kw, InternedString};
|
||||
use syntax::symbol::{kw, Symbol};
|
||||
|
||||
use self::InferTy::*;
|
||||
use self::TyKind::*;
|
||||
|
@ -55,7 +55,7 @@ pub enum BoundRegion {
|
|||
///
|
||||
/// The `DefId` is needed to distinguish free regions in
|
||||
/// the event of shadowing.
|
||||
BrNamed(DefId, InternedString),
|
||||
BrNamed(DefId, Symbol),
|
||||
|
||||
/// Anonymous region for the implicit env pointer parameter
|
||||
/// to a closure
|
||||
|
@ -1123,16 +1123,16 @@ pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<FnSig<'tcx>>>;
|
|||
Hash, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub struct ParamTy {
|
||||
pub index: u32,
|
||||
pub name: InternedString,
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
impl<'tcx> ParamTy {
|
||||
pub fn new(index: u32, name: InternedString) -> ParamTy {
|
||||
pub fn new(index: u32, name: Symbol) -> ParamTy {
|
||||
ParamTy { index, name: name }
|
||||
}
|
||||
|
||||
pub fn for_self() -> ParamTy {
|
||||
ParamTy::new(0, kw::SelfUpper.as_interned_str())
|
||||
ParamTy::new(0, kw::SelfUpper)
|
||||
}
|
||||
|
||||
pub fn for_def(def: &ty::GenericParamDef) -> ParamTy {
|
||||
|
@ -1148,11 +1148,11 @@ impl<'tcx> ParamTy {
|
|||
Eq, PartialEq, Ord, PartialOrd, HashStable)]
|
||||
pub struct ParamConst {
|
||||
pub index: u32,
|
||||
pub name: InternedString,
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
impl<'tcx> ParamConst {
|
||||
pub fn new(index: u32, name: InternedString) -> ParamConst {
|
||||
pub fn new(index: u32, name: Symbol) -> ParamConst {
|
||||
ParamConst { index, name }
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ impl<'tcx> rustc_serialize::UseSpecializedDecodable for Region<'tcx> {}
|
|||
pub struct EarlyBoundRegion {
|
||||
pub def_id: DefId,
|
||||
pub index: u32,
|
||||
pub name: InternedString,
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
||||
|
@ -1389,7 +1389,7 @@ pub struct BoundTy {
|
|||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub enum BoundTyKind {
|
||||
Anon,
|
||||
Param(InternedString),
|
||||
Param(Symbol),
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(struct BoundTy { var, kind });
|
||||
|
|
|
@ -46,7 +46,7 @@ use std::iter;
|
|||
use std::ptr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Interner, InternedString};
|
||||
use syntax::symbol::{Interner, Symbol};
|
||||
use syntax_pos::{self, Span, FileName};
|
||||
|
||||
impl PartialEq for llvm::Metadata {
|
||||
|
@ -2127,7 +2127,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
|
|||
|
||||
fn get_parameter_names(cx: &CodegenCx<'_, '_>,
|
||||
generics: &ty::Generics)
|
||||
-> Vec<InternedString> {
|
||||
-> Vec<Symbol> {
|
||||
let mut names = generics.parent.map_or(vec![], |def_id| {
|
||||
get_parameter_names(cx, cx.tcx.generics_of(def_id))
|
||||
});
|
||||
|
|
|
@ -36,7 +36,7 @@ use std::ffi::{CStr, CString};
|
|||
|
||||
use syntax_pos::{self, Span, Pos};
|
||||
use syntax::ast;
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
|
@ -490,7 +490,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
|
||||
fn get_parameter_names(cx: &CodegenCx<'_, '_>,
|
||||
generics: &ty::Generics)
|
||||
-> Vec<InternedString> {
|
||||
-> Vec<Symbol> {
|
||||
let mut names = generics.parent.map_or(vec![], |def_id| {
|
||||
get_parameter_names(cx, cx.tcx.generics_of(def_id))
|
||||
});
|
||||
|
|
|
@ -18,14 +18,14 @@ use rustc::ty::print::RegionHighlightMode;
|
|||
use rustc_errors::DiagnosticBuilder;
|
||||
use syntax::symbol::kw;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax_pos::{Span, symbol::InternedString};
|
||||
use syntax_pos::{Span, symbol::Symbol};
|
||||
|
||||
/// A name for a particular region used in emitting diagnostics. This name could be a generated
|
||||
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
|
||||
#[derive(Debug, Clone)]
|
||||
crate struct RegionName {
|
||||
/// The name of the region (interned).
|
||||
crate name: InternedString,
|
||||
crate name: Symbol,
|
||||
/// Where the region comes from.
|
||||
crate source: RegionNameSource,
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl RegionName {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
crate fn name(&self) -> InternedString {
|
||||
crate fn name(&self) -> Symbol {
|
||||
self.name
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
}
|
||||
|
||||
ty::ReStatic => Some(RegionName {
|
||||
name: kw::StaticLifetime.as_interned_str(),
|
||||
name: kw::StaticLifetime,
|
||||
source: RegionNameSource::Static
|
||||
}),
|
||||
|
||||
|
@ -360,7 +360,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
error_region: &RegionKind,
|
||||
name: InternedString,
|
||||
name: Symbol,
|
||||
) -> Span {
|
||||
let scope = error_region.free_region_binding_scope(tcx);
|
||||
let node = tcx.hir().as_local_hir_id(scope).unwrap_or(hir::DUMMY_HIR_ID);
|
||||
|
@ -837,10 +837,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
}
|
||||
|
||||
/// Creates a synthetic region named `'1`, incrementing the counter.
|
||||
fn synthesize_region_name(&self, renctx: &mut RegionErrorNamingCtx) -> InternedString {
|
||||
fn synthesize_region_name(&self, renctx: &mut RegionErrorNamingCtx) -> Symbol {
|
||||
let c = renctx.counter;
|
||||
renctx.counter += 1;
|
||||
|
||||
InternedString::intern(&format!("'{:?}", c))
|
||||
Symbol::intern(&format!("'{:?}", c))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -790,7 +790,7 @@ fn for_each_late_bound_region_defined_on<'tcx>(
|
|||
owner: fn_def_id.index,
|
||||
local_id: *late_bound,
|
||||
};
|
||||
let name = tcx.hir().name(hir_id).as_interned_str();
|
||||
let name = tcx.hir().name(hir_id);
|
||||
let region_def_id = tcx.hir().local_def_id(hir_id);
|
||||
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
|
||||
scope: fn_def_id,
|
||||
|
|
|
@ -908,7 +908,7 @@ fn convert_path_expr<'a, 'tcx>(
|
|||
let generics = cx.tcx.generics_of(item_def_id);
|
||||
let local_def_id = cx.tcx.hir().local_def_id(hir_id);
|
||||
let index = generics.param_def_id_to_index[&local_def_id];
|
||||
let name = cx.tcx.hir().name(hir_id).as_interned_str();
|
||||
let name = cx.tcx.hir().name(hir_id);
|
||||
let val = ConstValue::Param(ty::ParamConst::new(index, name));
|
||||
ExprKind::Literal {
|
||||
literal: cx.tcx.mk_const(
|
||||
|
|
|
@ -131,7 +131,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
{
|
||||
let tcx = self.tcx();
|
||||
let lifetime_name = |def_id| {
|
||||
tcx.hir().name(tcx.hir().as_local_hir_id(def_id).unwrap()).as_interned_str()
|
||||
tcx.hir().name(tcx.hir().as_local_hir_id(def_id).unwrap())
|
||||
};
|
||||
|
||||
let r = match tcx.named_region(lifetime.hir_id) {
|
||||
|
@ -2023,7 +2023,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let item_def_id = tcx.hir().local_def_id(item_id);
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
tcx.mk_ty_param(index, tcx.hir().name(hir_id).as_interned_str())
|
||||
tcx.mk_ty_param(index, tcx.hir().name(hir_id))
|
||||
}
|
||||
Res::SelfTy(Some(_), None) => {
|
||||
// `Self` in trait or type alias.
|
||||
|
@ -2204,7 +2204,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let item_def_id = tcx.hir().local_def_id(item_id);
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&tcx.hir().local_def_id(hir_id)];
|
||||
let name = tcx.hir().name(hir_id).as_interned_str();
|
||||
let name = tcx.hir().name(hir_id);
|
||||
const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc::ty::subst::Subst;
|
|||
use crate::require_same_types;
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
@ -80,7 +80,7 @@ pub fn intrinsic_operation_unsafety(intrinsic: &str) -> hir::Unsafety {
|
|||
/// Remember to add all intrinsics here, in librustc_codegen_llvm/intrinsic.rs,
|
||||
/// and in libcore/intrinsics.rs
|
||||
pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
||||
let param = |n| tcx.mk_ty_param(n, InternedString::intern(&format!("P{}", n)));
|
||||
let param = |n| tcx.mk_ty_param(n, Symbol::intern(&format!("P{}", n)));
|
||||
let name = it.ident.as_str();
|
||||
|
||||
let mk_va_list_ty = |mutbl| {
|
||||
|
@ -387,7 +387,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
|||
/// Type-check `extern "platform-intrinsic" { ... }` functions.
|
||||
pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
||||
let param = |n| {
|
||||
let name = InternedString::intern(&format!("P{}", n));
|
||||
let name = Symbol::intern(&format!("P{}", n));
|
||||
tcx.mk_ty_param(n, name)
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ use syntax::ast;
|
|||
use syntax::ast::{Ident, MetaItemKind};
|
||||
use syntax::attr::{InlineAttr, OptimizeAttr, list_contains_name, mark_used};
|
||||
use syntax::feature_gate;
|
||||
use syntax::symbol::{InternedString, kw, Symbol, sym};
|
||||
use syntax::symbol::{kw, Symbol, sym};
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
use rustc::hir::def::{CtorKind, Res, DefKind};
|
||||
|
@ -265,7 +265,7 @@ fn type_param_predicates(
|
|||
let param_owner_def_id = tcx.hir().local_def_id(param_owner);
|
||||
let generics = tcx.generics_of(param_owner_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(param_id).as_interned_str());
|
||||
let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(param_id));
|
||||
|
||||
// Don't look for bounds where the type parameter isn't in scope.
|
||||
let parent = if item_def_id == param_owner_def_id {
|
||||
|
@ -961,7 +961,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
|||
|
||||
opt_self = Some(ty::GenericParamDef {
|
||||
index: 0,
|
||||
name: kw::SelfUpper.as_interned_str(),
|
||||
name: kw::SelfUpper,
|
||||
def_id: tcx.hir().local_def_id(param_id),
|
||||
pure_wrt_drop: false,
|
||||
kind: ty::GenericParamDefKind::Type {
|
||||
|
@ -1006,7 +1006,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
|||
early_lifetimes
|
||||
.enumerate()
|
||||
.map(|(i, param)| ty::GenericParamDef {
|
||||
name: param.name.ident().as_interned_str(),
|
||||
name: param.name.ident().name,
|
||||
index: own_start + i as u32,
|
||||
def_id: tcx.hir().local_def_id(param.hir_id),
|
||||
pure_wrt_drop: param.pure_wrt_drop,
|
||||
|
@ -1060,7 +1060,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
|||
|
||||
let param_def = ty::GenericParamDef {
|
||||
index: type_start + i as u32,
|
||||
name: param.name.ident().as_interned_str(),
|
||||
name: param.name.ident().name,
|
||||
def_id: tcx.hir().local_def_id(param.hir_id),
|
||||
pure_wrt_drop: param.pure_wrt_drop,
|
||||
kind,
|
||||
|
@ -1090,7 +1090,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
|||
.enumerate()
|
||||
.map(|(i, &arg)| ty::GenericParamDef {
|
||||
index: type_start + i as u32,
|
||||
name: InternedString::intern(arg),
|
||||
name: Symbol::intern(arg),
|
||||
def_id,
|
||||
pure_wrt_drop: false,
|
||||
kind: ty::GenericParamDefKind::Type {
|
||||
|
@ -1105,7 +1105,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
|||
params.extend(upvars.iter().zip((dummy_args.len() as u32)..).map(|(_, i)| {
|
||||
ty::GenericParamDef {
|
||||
index: type_start + i,
|
||||
name: InternedString::intern("<upvar>"),
|
||||
name: Symbol::intern("<upvar>"),
|
||||
def_id,
|
||||
pure_wrt_drop: false,
|
||||
kind: ty::GenericParamDefKind::Type {
|
||||
|
@ -2198,7 +2198,7 @@ fn explicit_predicates_of(
|
|||
let region = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
|
||||
def_id: tcx.hir().local_def_id(param.hir_id),
|
||||
index,
|
||||
name: param.name.ident().as_interned_str(),
|
||||
name: param.name.ident().name,
|
||||
}));
|
||||
index += 1;
|
||||
|
||||
|
@ -2221,7 +2221,7 @@ fn explicit_predicates_of(
|
|||
// type parameter (e.g., `<T: Foo>`).
|
||||
for param in &ast_generics.params {
|
||||
if let GenericParamKind::Type { .. } = param.kind {
|
||||
let name = param.name.ident().as_interned_str();
|
||||
let name = param.name.ident().name;
|
||||
let param_ty = ty::ParamTy::new(index, name).to_ty(tcx);
|
||||
index += 1;
|
||||
|
||||
|
|
|
@ -1682,7 +1682,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
|
|||
.filter_map(|param| match param.kind {
|
||||
ty::GenericParamDefKind::Lifetime => None,
|
||||
ty::GenericParamDefKind::Type { synthetic, .. } => {
|
||||
if param.name.as_symbol() == kw::SelfUpper {
|
||||
if param.name == kw::SelfUpper {
|
||||
assert_eq!(param.index, 0);
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue