Skip to content

Commit 0965073

Browse files
committed
---
yaml --- r: 170365 b: refs/heads/try c: 2bbd2f9 h: refs/heads/master i: 170363: f91ca6b v: v3
1 parent 288eaa9 commit 0965073

File tree

15 files changed

+121
-139
lines changed

15 files changed

+121
-139
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 73a25f55ad748b4d3516417c711b99ce446591af
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: 964a5fabb7e32ac2b53678497a359e6eba2d5261
5+
refs/heads/try: 2bbd2f9ceafb86614b431cff4184f6e8ce7c973f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
420420
return ty::mk_trait(tcx, trait_ref, bounds);
421421
}
422422
'p' => {
423-
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
424-
debug!("parsed ty_param: did={}", did);
423+
assert_eq!(next(st), '[');
425424
let index = parse_u32(st);
426425
assert_eq!(next(st), '|');
427426
let space = parse_param_space(st);
428427
assert_eq!(next(st), '|');
429-
return ty::mk_param(tcx, space, index, did);
428+
let name = token::intern(parse_str(st, ']')[]);
429+
return ty::mk_param(tcx, space, index, name);
430430
}
431431
'~' => return ty::mk_uniq(tcx, parse_ty(st, |x,y| conv(x,y))),
432432
'*' => return ty::mk_ptr(tcx, parse_mt(st, |x,y| conv(x,y))),
@@ -507,7 +507,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
507507
'P' => {
508508
assert_eq!(next(st), '[');
509509
let trait_ref = parse_trait_ref(st, |x,y| conv(x,y));
510-
let name = token::str_to_ident(parse_str(st, ']').as_slice()).name;
510+
let name = token::intern(parse_str(st, ']').as_slice());
511511
return ty::mk_projection(tcx, trait_ref, name);
512512
}
513513
'e' => {

branches/try/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
135135
ty::ty_infer(_) => {
136136
cx.diag.handler().bug("cannot encode inference variable types");
137137
}
138-
ty::ty_param(ParamTy {space, idx: id, def_id: did}) => {
139-
mywrite!(w, "p{}|{}|{}|", (cx.ds)(did), id, space.to_uint())
138+
ty::ty_param(ParamTy {space, idx, name}) => {
139+
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), token::get_name(name))
140140
}
141141
ty::ty_struct(def, substs) => {
142142
mywrite!(w, "a[{}|", (cx.ds)(def));

branches/try/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl tr for def::Def {
448448
def::DefAssociatedPath(def::TyParamProvenance::FromParam(did), ident) =>
449449
def::DefAssociatedPath(def::TyParamProvenance::FromParam(did.tr(dcx)), ident),
450450
def::DefPrimTy(p) => def::DefPrimTy(p),
451-
def::DefTyParam(s, did, v) => def::DefTyParam(s, did.tr(dcx), v),
451+
def::DefTyParam(s, index, def_id, n) => def::DefTyParam(s, index, def_id.tr(dcx), n),
452452
def::DefUse(did) => def::DefUse(did.tr(dcx)),
453453
def::DefUpvar(nid1, nid2, nid3) => {
454454
def::DefUpvar(dcx.tr_id(nid1),

branches/try/src/librustc/middle/def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum Def {
3939
DefAssociatedPath(TyParamProvenance, ast::Ident),
4040
DefTrait(ast::DefId),
4141
DefPrimTy(ast::PrimTy),
42-
DefTyParam(ParamSpace, ast::DefId, u32),
42+
DefTyParam(ParamSpace, u32, ast::DefId, ast::Name),
4343
DefUse(ast::DefId),
4444
DefUpvar(ast::NodeId, // id of closed over local
4545
ast::NodeId, // expr node that creates the closure
@@ -130,7 +130,7 @@ impl Def {
130130
DefFn(id, _) | DefStaticMethod(id, _) | DefMod(id) |
131131
DefForeignMod(id) | DefStatic(id, _) |
132132
DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(id) |
133-
DefTyParam(_, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
133+
DefTyParam(_, _, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
134134
DefMethod(id, _, _) | DefConst(id) |
135135
DefAssociatedPath(TyParamProvenance::FromSelf(id), _) |
136136
DefAssociatedPath(TyParamProvenance::FromParam(id), _) => {

branches/try/src/librustc/middle/ty.rs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ use syntax::ast::{Visibility};
8686
use syntax::ast_util::{mod, is_local, lit_is_str, local_def, PostExpansionMethod};
8787
use syntax::attr::{mod, AttrMetaMethods};
8888
use syntax::codemap::Span;
89-
use syntax::parse::token::{mod, InternedString};
89+
use syntax::parse::token::{mod, InternedString, special_idents};
9090
use syntax::{ast, ast_map};
9191

9292
pub type Disr = u64;
@@ -1079,7 +1079,7 @@ pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
10791079
pub struct ParamTy {
10801080
pub space: subst::ParamSpace,
10811081
pub idx: u32,
1082-
pub def_id: DefId
1082+
pub name: ast::Name,
10831083
}
10841084

10851085
/// A [De Bruijn index][dbi] is a standard means of representing
@@ -2775,17 +2775,19 @@ pub fn mk_infer<'tcx>(cx: &ctxt<'tcx>, it: InferTy) -> Ty<'tcx> {
27752775
mk_t(cx, ty_infer(it))
27762776
}
27772777

2778-
pub fn mk_param<'tcx>(cx: &ctxt<'tcx>, space: subst::ParamSpace,
2779-
n: u32, k: DefId) -> Ty<'tcx> {
2780-
mk_t(cx, ty_param(ParamTy { space: space, idx: n, def_id: k }))
2778+
pub fn mk_param<'tcx>(cx: &ctxt<'tcx>,
2779+
space: subst::ParamSpace,
2780+
index: u32,
2781+
name: ast::Name) -> Ty<'tcx> {
2782+
mk_t(cx, ty_param(ParamTy { space: space, idx: index, name: name }))
27812783
}
27822784

2783-
pub fn mk_self_type<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId) -> Ty<'tcx> {
2784-
mk_param(cx, subst::SelfSpace, 0, did)
2785+
pub fn mk_self_type<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
2786+
mk_param(cx, subst::SelfSpace, 0, special_idents::type_self.name)
27852787
}
27862788

27872789
pub fn mk_param_from_def<'tcx>(cx: &ctxt<'tcx>, def: &TypeParameterDef) -> Ty<'tcx> {
2788-
mk_param(cx, def.space, def.index, def.def_id)
2790+
mk_param(cx, def.space, def.index, def.name)
27892791
}
27902792

27912793
pub fn mk_open<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_open(ty)) }
@@ -2854,21 +2856,21 @@ pub fn fold_ty<'tcx, F>(cx: &ctxt<'tcx>, t0: Ty<'tcx>,
28542856
impl ParamTy {
28552857
pub fn new(space: subst::ParamSpace,
28562858
index: u32,
2857-
def_id: ast::DefId)
2859+
name: ast::Name)
28582860
-> ParamTy {
2859-
ParamTy { space: space, idx: index, def_id: def_id }
2861+
ParamTy { space: space, idx: index, name: name }
28602862
}
28612863

2862-
pub fn for_self(trait_def_id: ast::DefId) -> ParamTy {
2863-
ParamTy::new(subst::SelfSpace, 0, trait_def_id)
2864+
pub fn for_self() -> ParamTy {
2865+
ParamTy::new(subst::SelfSpace, 0, special_idents::type_self.name)
28642866
}
28652867

28662868
pub fn for_def(def: &TypeParameterDef) -> ParamTy {
2867-
ParamTy::new(def.space, def.index, def.def_id)
2869+
ParamTy::new(def.space, def.index, def.name)
28682870
}
28692871

28702872
pub fn to_ty<'tcx>(self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
2871-
ty::mk_param(tcx, self.space, self.idx, self.def_id)
2873+
ty::mk_param(tcx, self.space, self.idx, self.name)
28722874
}
28732875

28742876
pub fn is_self(&self) -> bool {
@@ -6256,8 +6258,9 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
62566258
}
62576259
ty_param(p) => {
62586260
byte!(20);
6261+
hash!(p.space);
62596262
hash!(p.idx);
6260-
did(state, p.def_id);
6263+
hash!(token::get_name(p.name));
62616264
}
62626265
ty_open(_) => byte!(22),
62636266
ty_infer(_) => unreachable!(),
@@ -6312,17 +6315,11 @@ pub fn construct_parameter_environment<'tcx>(
63126315

63136316
// map T => T
63146317
let mut types = VecPerParamSpace::empty();
6315-
for &space in subst::ParamSpace::all().iter() {
6316-
push_types_from_defs(tcx, &mut types, space,
6317-
generics.types.get_slice(space));
6318-
}
6318+
push_types_from_defs(tcx, &mut types, generics.types.as_slice());
63196319

63206320
// map bound 'a => free 'a
63216321
let mut regions = VecPerParamSpace::empty();
6322-
for &space in subst::ParamSpace::all().iter() {
6323-
push_region_params(&mut regions, space, free_id,
6324-
generics.regions.get_slice(space));
6325-
}
6322+
push_region_params(&mut regions, free_id, generics.regions.as_slice());
63266323

63276324
let free_substs = Substs {
63286325
types: types,
@@ -6359,27 +6356,22 @@ pub fn construct_parameter_environment<'tcx>(
63596356
};
63606357

63616358
fn push_region_params(regions: &mut VecPerParamSpace<ty::Region>,
6362-
space: subst::ParamSpace,
63636359
free_id: ast::NodeId,
63646360
region_params: &[RegionParameterDef])
63656361
{
63666362
for r in region_params.iter() {
6367-
regions.push(space, ty::free_region_from_def(free_id, r));
6363+
regions.push(r.space, ty::free_region_from_def(free_id, r));
63686364
}
63696365
}
63706366

63716367
fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
63726368
types: &mut subst::VecPerParamSpace<Ty<'tcx>>,
6373-
space: subst::ParamSpace,
63746369
defs: &[TypeParameterDef<'tcx>]) {
6375-
for (i, def) in defs.iter().enumerate() {
6376-
debug!("construct_parameter_environment(): push_types_from_defs: \
6377-
space={} def={} index={}",
6378-
space,
6379-
def.repr(tcx),
6380-
i);
6381-
let ty = ty::mk_param(tcx, space, i as u32, def.def_id);
6382-
types.push(space, ty);
6370+
for def in defs.iter() {
6371+
debug!("construct_parameter_environment(): push_types_from_defs: def={}",
6372+
def.repr(tcx));
6373+
let ty = ty::mk_param_from_def(tcx, def);
6374+
types.push(def.space, ty);
63836375
}
63846376
}
63856377

branches/try/src/librustc/util/ppaux.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,17 +1328,8 @@ impl<'tcx> Repr<'tcx> for ty::ExplicitSelfCategory {
13281328
}
13291329

13301330
impl<'tcx> UserString<'tcx> for ParamTy {
1331-
fn user_string(&self, tcx: &ctxt) -> String {
1332-
let id = self.idx;
1333-
let did = self.def_id;
1334-
let ident = match tcx.ty_param_defs.borrow().get(&did.node) {
1335-
Some(def) => token::get_name(def.name).get().to_string(),
1336-
1337-
// This can only happen when a type mismatch error happens and
1338-
// the actual type has more type parameters than the expected one.
1339-
None => format!("<generic #{}>", id),
1340-
};
1341-
ident
1331+
fn user_string(&self, _tcx: &ctxt) -> String {
1332+
format!("{}", token::get_name(self.name))
13421333
}
13431334
}
13441335

branches/try/src/librustc_resolve/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,7 +3906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
39063906
// If the def is a ty param, and came from the parent
39073907
// item, it's ok
39083908
match def {
3909-
DefTyParam(_, did, _) if {
3909+
DefTyParam(_, _, did, _) if {
39103910
self.def_map.borrow().get(&did.node).cloned()
39113911
== Some(DefTyParamBinder(item_id))
39123912
} => {} // ok
@@ -3959,7 +3959,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
39593959
// If the def is a ty param, and came from the parent
39603960
// item, it's ok
39613961
match def {
3962-
DefTyParam(_, did, _) if {
3962+
DefTyParam(_, _, did, _) if {
39633963
self.def_map.borrow().get(&did.node).cloned()
39643964
== Some(DefTyParamBinder(item_id))
39653965
} => {} // ok
@@ -4265,8 +4265,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
42654265
seen_bindings.insert(name);
42664266

42674267
let def_like = DlDef(DefTyParam(space,
4268+
index as u32,
42684269
local_def(type_parameter.id),
4269-
index as u32));
4270+
name));
42704271
// Associate this type parameter with
42714272
// the item that bound it
42724273
self.record_def(type_parameter.id,
@@ -5161,7 +5162,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
51615162
path.span) {
51625163
Some((def, last_private)) => {
51635164
match def {
5164-
DefTyParam(_, did, _) => {
5165+
DefTyParam(_, _, did, _) => {
51655166
let def = DefAssociatedPath(TyParamProvenance::FromParam(did),
51665167
path.segments.last()
51675168
.unwrap().identifier);

branches/try/src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,17 +1118,16 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
11181118
def::DefTy(did, _) | def::DefStruct(did) => {
11191119
ast_path_to_ty(this, rscope, did, path).ty
11201120
}
1121-
def::DefTyParam(space, id, n) => {
1121+
def::DefTyParam(space, index, _, name) => {
11221122
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
1123-
ty::mk_param(tcx, space, n, id)
1123+
ty::mk_param(tcx, space, index, name)
11241124
}
1125-
def::DefSelfTy(id) => {
1125+
def::DefSelfTy(_) => {
11261126
// n.b.: resolve guarantees that the this type only appears in a
11271127
// trait, which we rely upon in various places when creating
11281128
// substs
11291129
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
1130-
let did = ast_util::local_def(id);
1131-
ty::mk_self_type(tcx, did)
1130+
ty::mk_self_type(tcx)
11321131
}
11331132
def::DefMod(id) => {
11341133
tcx.sess.span_fatal(ast_ty.span,

branches/try/src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ pub fn type_scheme_for_def<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
50655065
def::DefAssociatedTy(..) |
50665066
def::DefAssociatedPath(..) |
50675067
def::DefPrimTy(_) |
5068-
def::DefTyParam(..)=> {
5068+
def::DefTyParam(..) => {
50695069
fcx.ccx.tcx.sess.span_bug(sp, "expected value, found type");
50705070
}
50715071
def::DefMod(..) | def::DefForeignMod(..) => {
@@ -5635,7 +5635,8 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
56355635

56365636
pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
56375637
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
5638-
ty::mk_param(ccx.tcx, subst::FnSpace, n, local_def(0))
5638+
let name = token::intern(format!("P{}", n).as_slice());
5639+
ty::mk_param(ccx.tcx, subst::FnSpace, n, name)
56395640
}
56405641

56415642
let tcx = ccx.tcx;

branches/try/src/librustc_typeck/check/regionck.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,11 +1848,9 @@ fn param_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
18481848
// well-formed, then, A must be lower-bounded by `'a`, but we
18491849
// don't know that this holds from first principles.
18501850
for &(ref r, ref p) in rcx.region_param_pairs.iter() {
1851-
debug!("param_ty={}/{} p={}/{}",
1851+
debug!("param_ty={} p={}",
18521852
param_ty.repr(rcx.tcx()),
1853-
param_ty.def_id,
1854-
p.repr(rcx.tcx()),
1855-
p.def_id);
1853+
p.repr(rcx.tcx()));
18561854
if param_ty == *p {
18571855
param_bounds.push(*r);
18581856
}

0 commit comments

Comments
 (0)