Auto merge of #49695 - michaelwoerister:unhygienic-ty-min, r=nikomatsakis
Use InternedString instead of Symbol for type parameter types (2) Reduced alternative to #49266. Let's see if this causes a performance regression.
This commit is contained in:
commit
88ebd97d65
16 changed files with 52 additions and 35 deletions
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::symbol::InternedString;
|
||||
use syntax_pos::Span;
|
||||
use ty::{self, Ty};
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ pub enum TypeVariableOrigin {
|
|||
MiscVariable(Span),
|
||||
NormalizeProjectionType(Span),
|
||||
TypeInference(Span),
|
||||
TypeParameterDefinition(Span, ast::Name),
|
||||
TypeParameterDefinition(Span, InternedString),
|
||||
|
||||
/// one of the upvars or closure kind parameters in a `ClosureSubsts`
|
||||
/// (before it has been determined)
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
for param in generics.types.iter() {
|
||||
let name = param.name.as_str().to_string();
|
||||
let name = param.name.to_string();
|
||||
let ty = trait_ref.substs.type_for_def(param);
|
||||
let ty_str = ty.to_string();
|
||||
flags.push((name.clone(),
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
|
|||
let trait_str = tcx.item_path_str(trait_ref.def_id);
|
||||
let generics = tcx.generics_of(trait_ref.def_id);
|
||||
let generic_map = generics.types.iter().map(|param| {
|
||||
(param.name.as_str().to_string(),
|
||||
(param.name.to_string(),
|
||||
trait_ref.substs.type_for_def(param).to_string())
|
||||
}).collect::<FxHashMap<String, String>>();
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ use std::iter;
|
|||
use std::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::MultiSpan;
|
||||
use syntax::feature_gate;
|
||||
use syntax::symbol::{Symbol, keywords};
|
||||
use syntax::symbol::{Symbol, keywords, InternedString};
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
|
|
@ -2430,12 +2430,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn mk_param(self,
|
||||
index: u32,
|
||||
name: Name) -> Ty<'tcx> {
|
||||
name: InternedString) -> Ty<'tcx> {
|
||||
self.mk_ty(TyParam(ParamTy { idx: index, name: name }))
|
||||
}
|
||||
|
||||
pub fn mk_self_type(self) -> Ty<'tcx> {
|
||||
self.mk_param(0, keywords::SelfType.name())
|
||||
self.mk_param(0, keywords::SelfType.name().as_str())
|
||||
}
|
||||
|
||||
pub fn mk_param_from_def(self, def: &ty::TypeParameterDef) -> Ty<'tcx> {
|
||||
|
|
|
|||
|
|
@ -671,7 +671,16 @@ macro_rules! define_maps {
|
|||
map: LockGuard<'_, QueryMap<$tcx, Self>>,
|
||||
dep_node: DepNode)
|
||||
-> Result<($V, DepNodeIndex), CycleError<$tcx>> {
|
||||
debug_assert!(!tcx.dep_graph.dep_node_exists(&dep_node));
|
||||
// If the following assertion triggers, it can have two reasons:
|
||||
// 1. Something is wrong with DepNode creation, either here or
|
||||
// in DepGraph::try_mark_green()
|
||||
// 2. Two distinct query keys get mapped to the same DepNode
|
||||
// (see for example #48923)
|
||||
assert!(!tcx.dep_graph.dep_node_exists(&dep_node),
|
||||
"Forcing query with already existing DepNode.\n\
|
||||
- query-key: {:?}\n\
|
||||
- dep-node: {:?}",
|
||||
key, dep_node);
|
||||
|
||||
profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
|
||||
let res = Self::start_job(tcx,
|
||||
|
|
|
|||
|
|
@ -712,7 +712,7 @@ pub struct FloatVarValue(pub ast::FloatTy);
|
|||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct TypeParameterDef {
|
||||
pub name: Name,
|
||||
pub name: InternedString,
|
||||
pub def_id: DefId,
|
||||
pub index: u32,
|
||||
pub has_default: bool,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::iter;
|
|||
use std::cmp::Ordering;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax::symbol::keywords;
|
||||
use syntax::symbol::{keywords, InternedString};
|
||||
|
||||
use serialize;
|
||||
|
||||
|
|
@ -864,16 +864,16 @@ impl<'tcx> PolyFnSig<'tcx> {
|
|||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub struct ParamTy {
|
||||
pub idx: u32,
|
||||
pub name: Name,
|
||||
pub name: InternedString,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> ParamTy {
|
||||
pub fn new(index: u32, name: Name) -> ParamTy {
|
||||
pub fn new(index: u32, name: InternedString) -> ParamTy {
|
||||
ParamTy { idx: index, name: name }
|
||||
}
|
||||
|
||||
pub fn for_self() -> ParamTy {
|
||||
ParamTy::new(0, keywords::SelfType.name())
|
||||
ParamTy::new(0, keywords::SelfType.name().as_str())
|
||||
}
|
||||
|
||||
pub fn for_def(def: &ty::TypeParameterDef) -> ParamTy {
|
||||
|
|
@ -885,7 +885,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
|
|||
}
|
||||
|
||||
pub fn is_self(&self) -> bool {
|
||||
if self.name == keywords::SelfType.name() {
|
||||
if self.name == keywords::SelfType.name().as_str() {
|
||||
assert_eq!(self.idx, 0);
|
||||
true
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -729,7 +729,7 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W>
|
|||
}
|
||||
TyParam(p) => {
|
||||
self.hash(p.idx);
|
||||
self.hash(p.name.as_str());
|
||||
self.hash(p.name);
|
||||
}
|
||||
TyProjection(ref data) => {
|
||||
self.def_id(data.item_def_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue