Skip to content

Commit 0451083

Browse files
Use InternedString instead of Symbol for type parameters.
1 parent 0776b37 commit 0451083

File tree

12 files changed

+30
-30
lines changed

12 files changed

+30
-30
lines changed

src/librustc/infer/type_variable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use syntax::ast;
11+
use syntax::symbol::InternedString;
1212
use syntax_pos::Span;
1313
use ty::{self, Ty};
1414

@@ -53,7 +53,7 @@ pub enum TypeVariableOrigin {
5353
MiscVariable(Span),
5454
NormalizeProjectionType(Span),
5555
TypeInference(Span),
56-
TypeParameterDefinition(Span, ast::Name),
56+
TypeParameterDefinition(Span, InternedString),
5757

5858
/// one of the upvars or closure kind parameters in a `ClosureSubsts`
5959
/// (before it has been determined)

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
380380
}
381381

382382
for param in generics.types.iter() {
383-
let name = param.name.as_str().to_string();
383+
let name = param.name.to_string();
384384
let ty = trait_ref.substs.type_for_def(param);
385385
let ty_str = ty.to_string();
386386
flags.push((name.clone(),

src/librustc/traits/on_unimplemented.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
289289
let trait_str = tcx.item_path_str(trait_ref.def_id);
290290
let generics = tcx.generics_of(trait_ref.def_id);
291291
let generic_map = generics.types.iter().map(|param| {
292-
(param.name.as_str().to_string(),
292+
(param.name.to_string(),
293293
trait_ref.substs.type_for_def(param).to_string())
294294
}).collect::<FxHashMap<String, String>>();
295295

src/librustc/ty/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ use std::iter;
6969
use std::sync::mpsc;
7070
use std::sync::Arc;
7171
use syntax::abi;
72-
use syntax::ast::{self, Name, NodeId};
72+
use syntax::ast::{self, NodeId};
7373
use syntax::attr;
7474
use syntax::codemap::MultiSpan;
7575
use syntax::feature_gate;
76-
use syntax::symbol::{Symbol, keywords};
76+
use syntax::symbol::{Symbol, keywords, InternedString};
7777
use syntax_pos::Span;
7878

7979
use hir;
@@ -2221,12 +2221,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
22212221

22222222
pub fn mk_param(self,
22232223
index: u32,
2224-
name: Name) -> Ty<'tcx> {
2224+
name: InternedString) -> Ty<'tcx> {
22252225
self.mk_ty(TyParam(ParamTy { idx: index, name: name }))
22262226
}
22272227

22282228
pub fn mk_self_type(self) -> Ty<'tcx> {
2229-
self.mk_param(0, keywords::SelfType.name())
2229+
self.mk_param(0, keywords::SelfType.name().as_str())
22302230
}
22312231

22322232
pub fn mk_param_from_def(self, def: &ty::TypeParameterDef) -> Ty<'tcx> {

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ pub struct FloatVarValue(pub ast::FloatTy);
699699

700700
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
701701
pub struct TypeParameterDef {
702-
pub name: Name,
702+
pub name: InternedString,
703703
pub def_id: DefId,
704704
pub index: u32,
705705
pub has_default: bool,

src/librustc/ty/sty.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::iter;
2323
use std::cmp::Ordering;
2424
use syntax::abi;
2525
use syntax::ast::{self, Name};
26-
use syntax::symbol::keywords;
26+
use syntax::symbol::{keywords, InternedString};
2727

2828
use serialize;
2929

@@ -861,16 +861,16 @@ impl<'tcx> PolyFnSig<'tcx> {
861861
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
862862
pub struct ParamTy {
863863
pub idx: u32,
864-
pub name: Name,
864+
pub name: InternedString,
865865
}
866866

867867
impl<'a, 'gcx, 'tcx> ParamTy {
868-
pub fn new(index: u32, name: Name) -> ParamTy {
868+
pub fn new(index: u32, name: InternedString) -> ParamTy {
869869
ParamTy { idx: index, name: name }
870870
}
871871

872872
pub fn for_self() -> ParamTy {
873-
ParamTy::new(0, keywords::SelfType.name())
873+
ParamTy::new(0, keywords::SelfType.name().as_str())
874874
}
875875

876876
pub fn for_def(def: &ty::TypeParameterDef) -> ParamTy {
@@ -882,7 +882,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
882882
}
883883

884884
pub fn is_self(&self) -> bool {
885-
if self.name == keywords::SelfType.name() {
885+
if self.name == keywords::SelfType.name().as_str() {
886886
assert_eq!(self.idx, 0);
887887
true
888888
} else {

src/librustc/ty/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W>
714714
}
715715
TyParam(p) => {
716716
self.hash(p.idx);
717-
self.hash(p.name.as_str());
717+
self.hash(p.name);
718718
}
719719
TyProjection(ref data) => {
720720
self.def_id(data.item_def_id);

src/librustc_trans/debuginfo/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use std::ptr;
4242

4343
use syntax_pos::{self, Span, Pos};
4444
use syntax::ast;
45-
use syntax::symbol::Symbol;
45+
use syntax::symbol::{Symbol, InternedString};
4646
use rustc::ty::layout::{self, LayoutOf};
4747

4848
pub mod gdb;
@@ -393,7 +393,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
393393
substs.types().zip(names).map(|(ty, name)| {
394394
let actual_type = cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
395395
let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
396-
let name = CString::new(name.as_str().as_bytes()).unwrap();
396+
let name = CString::new(name.as_bytes()).unwrap();
397397
unsafe {
398398
llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
399399
DIB(cx),
@@ -412,7 +412,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
412412
return create_DIArray(DIB(cx), &template_params[..]);
413413
}
414414

415-
fn get_type_parameter_names(cx: &CodegenCx, generics: &ty::Generics) -> Vec<ast::Name> {
415+
fn get_type_parameter_names(cx: &CodegenCx, generics: &ty::Generics) -> Vec<InternedString> {
416416
let mut names = generics.parent.map_or(vec![], |def_id| {
417417
get_type_parameter_names(cx, cx.tcx.generics_of(def_id))
418418
});

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
978978
let item_def_id = tcx.hir.local_def_id(item_id);
979979
let generics = tcx.generics_of(item_def_id);
980980
let index = generics.type_param_to_index[&tcx.hir.local_def_id(node_id)];
981-
tcx.mk_param(index, tcx.hir.name(node_id))
981+
tcx.mk_param(index, tcx.hir.name(node_id).as_str())
982982
}
983983
Def::SelfTy(_, Some(def_id)) => {
984984
// Self in impl (we know the concrete type).

src/librustc_typeck/check/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
7676
/// and in libcore/intrinsics.rs
7777
pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
7878
it: &hir::ForeignItem) {
79-
let param = |n| tcx.mk_param(n, Symbol::intern(&format!("P{}", n)));
79+
let param = |n| tcx.mk_param(n, Symbol::intern(&format!("P{}", n)).as_str());
8080
let name = it.name.as_str();
8181
let (n_tps, inputs, output) = if name.starts_with("atomic_") {
8282
let split : Vec<&str> = name.split('_').collect();
@@ -341,7 +341,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
341341
pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
342342
it: &hir::ForeignItem) {
343343
let param = |n| {
344-
let name = Symbol::intern(&format!("P{}", n));
344+
let name = Symbol::intern(&format!("P{}", n)).as_str();
345345
tcx.mk_param(n, name)
346346
};
347347

src/librustc_typeck/check/wfcheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ fn reject_shadowing_type_parameters(tcx: TyCtxt, def_id: DefId) {
643643
// local so it should be okay to just unwrap everything.
644644
let trait_def_id = impl_params[&method_param.name];
645645
let trait_decl_span = tcx.def_span(trait_def_id);
646-
error_194(tcx, type_span, trait_decl_span, method_param.name);
646+
error_194(tcx, type_span, trait_decl_span, &method_param.name[..]);
647647
}
648648
}
649649
}
@@ -739,7 +739,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast:
739739
err
740740
}
741741

742-
fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: ast::Name) {
742+
fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) {
743743
struct_span_err!(tcx.sess, span, E0194,
744744
"type parameter `{}` shadows another type parameter of the same name",
745745
name)

src/librustc_typeck/collect.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
240240
let param_owner_def_id = tcx.hir.local_def_id(param_owner);
241241
let generics = tcx.generics_of(param_owner_def_id);
242242
let index = generics.type_param_to_index[&def_id];
243-
let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id));
243+
let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id).as_str());
244244

245245
// Don't look for bounds where the type parameter isn't in scope.
246246
let parent = if item_def_id == param_owner_def_id {
@@ -838,7 +838,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
838838

839839
opt_self = Some(ty::TypeParameterDef {
840840
index: 0,
841-
name: keywords::SelfType.name(),
841+
name: keywords::SelfType.name().as_str(),
842842
def_id: tcx.hir.local_def_id(param_id),
843843
has_default: false,
844844
object_lifetime_default: rl::Set1::Empty,
@@ -914,7 +914,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
914914

915915
ty::TypeParameterDef {
916916
index: type_start + i as u32,
917-
name: p.name,
917+
name: p.name.as_str(),
918918
def_id: tcx.hir.local_def_id(p.id),
919919
has_default: p.default.is_some(),
920920
object_lifetime_default:
@@ -933,7 +933,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
933933
// add a dummy parameter for the closure kind
934934
types.push(ty::TypeParameterDef {
935935
index: type_start,
936-
name: Symbol::intern("<closure_kind>"),
936+
name: Symbol::intern("<closure_kind>").as_str(),
937937
def_id,
938938
has_default: false,
939939
object_lifetime_default: rl::Set1::Empty,
@@ -944,7 +944,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
944944
// add a dummy parameter for the closure signature
945945
types.push(ty::TypeParameterDef {
946946
index: type_start + 1,
947-
name: Symbol::intern("<closure_signature>"),
947+
name: Symbol::intern("<closure_signature>").as_str(),
948948
def_id,
949949
has_default: false,
950950
object_lifetime_default: rl::Set1::Empty,
@@ -955,7 +955,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
955955
tcx.with_freevars(node_id, |fv| {
956956
types.extend(fv.iter().zip(2..).map(|(_, i)| ty::TypeParameterDef {
957957
index: type_start + i,
958-
name: Symbol::intern("<upvar>"),
958+
name: Symbol::intern("<upvar>").as_str(),
959959
def_id,
960960
has_default: false,
961961
object_lifetime_default: rl::Set1::Empty,
@@ -1435,7 +1435,7 @@ fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
14351435
// Collect the predicates that were written inline by the user on each
14361436
// type parameter (e.g., `<T:Foo>`).
14371437
for param in ast_generics.ty_params() {
1438-
let param_ty = ty::ParamTy::new(index, param.name).to_ty(tcx);
1438+
let param_ty = ty::ParamTy::new(index, param.name.as_str()).to_ty(tcx);
14391439
index += 1;
14401440

14411441
let bounds = compute_bounds(&icx,

0 commit comments

Comments
 (0)