Skip to content

Commit 87131a3

Browse files
Ariel Ben-Yehudaarielb1
authored andcommitted
---
yaml --- r: 233151 b: refs/heads/beta c: 764310e h: refs/heads/master i: 233149: 93d829b 233147: 142c2ba 233143: 9d6ca5e 233135: faf5d73 233119: 56bc7ca 233087: b3a54c3 v: v3
1 parent ef8fcdf commit 87131a3

File tree

47 files changed

+655
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+655
-551
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 03ee3f5c204cb9b20c58a5cd2d61dc792727dad7
26+
refs/heads/beta: 764310e7bb90ec14a6c6a399e703f6b455ba52d3
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/metadata/csearch.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::TraitDe
222222
decoder::get_trait_def(&*cdata, def.node, tcx)
223223
}
224224

225+
pub fn get_adt_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> &'tcx ty::ADTDef<'tcx> {
226+
let cstore = &tcx.sess.cstore;
227+
let cdata = cstore.get_crate_data(def.krate);
228+
decoder::get_adt_def(&*cdata, def.node, tcx)
229+
}
230+
225231
pub fn get_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
226232
-> ty::GenericPredicates<'tcx>
227233
{

branches/beta/src/librustc/metadata/decoder.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
390390
}
391391
}
392392

393+
pub fn get_adt_def<'tcx>(cdata: Cmd,
394+
item_id: ast::NodeId,
395+
tcx: &ty::ctxt<'tcx>) -> &'tcx ty::ADTDef<'tcx>
396+
{
397+
tcx.intern_adt_def(ast::DefId { krate: cdata.cnum, node: item_id })
398+
}
399+
393400
pub fn get_predicates<'tcx>(cdata: Cmd,
394401
item_id: ast::NodeId,
395402
tcx: &ty::ctxt<'tcx>)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,10 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
468468
'c' => return tcx.types.char,
469469
't' => {
470470
assert_eq!(next(st), '[');
471-
let def = parse_def_(st, NominalType, conv);
471+
let did = parse_def_(st, NominalType, conv);
472472
let substs = parse_substs_(st, conv);
473473
assert_eq!(next(st), ']');
474+
let def = st.tcx.lookup_adt_def(did);
474475
return tcx.mk_enum(def, st.tcx.mk_substs(substs));
475476
}
476477
'x' => {
@@ -558,7 +559,8 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
558559
let did = parse_def_(st, NominalType, conv);
559560
let substs = parse_substs_(st, conv);
560561
assert_eq!(next(st), ']');
561-
return st.tcx.mk_struct(did, st.tcx.mk_substs(substs));
562+
let def = st.tcx.lookup_adt_def(did);
563+
return st.tcx.mk_struct(def, st.tcx.mk_substs(substs));
562564
}
563565
'k' => {
564566
assert_eq!(next(st), '[');

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
8686
}
8787
}
8888
ty::TyEnum(def, substs) => {
89-
mywrite!(w, "t[{}|", (cx.ds)(def));
89+
mywrite!(w, "t[{}|", (cx.ds)(def.did));
9090
enc_substs(w, cx, substs);
9191
mywrite!(w, "]");
9292
}
@@ -138,7 +138,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
138138
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), name)
139139
}
140140
ty::TyStruct(def, substs) => {
141-
mywrite!(w, "a[{}|", (cx.ds)(def));
141+
mywrite!(w, "a[{}|", (cx.ds)(def.did));
142142
enc_substs(w, cx, substs);
143143
mywrite!(w, "]");
144144
}

branches/beta/src/librustc/middle/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
546546
fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
547547
e: &ast::Expr, node_ty: Ty<'tcx>) {
548548
match node_ty.sty {
549-
ty::TyStruct(did, _) |
550-
ty::TyEnum(did, _) if v.tcx.has_dtor(did) => {
549+
ty::TyStruct(def, _) |
550+
ty::TyEnum(def, _) if def.has_dtor(v.tcx) => {
551551
v.add_qualif(ConstQualif::NEEDS_DROP);
552552
if v.mode != Mode::Var {
553553
v.tcx.sess.span_err(e.span,

branches/beta/src/librustc/middle/check_match.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
234234
match p.node {
235235
ast::PatIdent(ast::BindByValue(ast::MutImmutable), ident, None) => {
236236
let pat_ty = cx.tcx.pat_ty(p);
237-
if let ty::TyEnum(def_id, _) = pat_ty.sty {
237+
if let ty::TyEnum(edef, _) = pat_ty.sty {
238238
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
239239
if let Some(DefLocal(_)) = def {
240-
if cx.tcx.enum_variants(def_id).iter().any(|variant|
240+
if cx.tcx.enum_variants(edef.did).iter().any(|variant|
241241
variant.name == ident.node.name
242242
&& variant.args.is_empty()
243243
) {
@@ -501,8 +501,8 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
501501
///
502502
/// left_ty: struct X { a: (bool, &'static str), b: usize}
503503
/// pats: [(false, "foo"), 42] => X { a: (false, "foo"), b: 42 }
504-
fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
505-
pats: Vec<&Pat>, left_ty: Ty) -> P<Pat> {
504+
fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
505+
pats: Vec<&Pat>, left_ty: Ty<'tcx>) -> P<Pat> {
506506
let pats_len = pats.len();
507507
let mut pats = pats.into_iter().map(|p| P((*p).clone()));
508508
let pat = match left_ty.sty {
@@ -511,9 +511,9 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
511511
ty::TyEnum(cid, _) | ty::TyStruct(cid, _) => {
512512
let (vid, is_structure) = match ctor {
513513
&Variant(vid) =>
514-
(vid, cx.tcx.enum_variant_with_id(cid, vid).arg_names.is_some()),
514+
(vid, cx.tcx.enum_variant_with_id(cid.did, vid).arg_names.is_some()),
515515
_ =>
516-
(cid, !cx.tcx.is_tuple_struct(cid))
516+
(cid.did, !cid.is_tuple_struct(cx.tcx))
517517
};
518518
if is_structure {
519519
let fields = cx.tcx.lookup_struct_fields(vid);
@@ -606,8 +606,8 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
606606
_ => vec!(Single)
607607
},
608608

609-
ty::TyEnum(eid, _) =>
610-
cx.tcx.enum_variants(eid)
609+
ty::TyEnum(edef, _) =>
610+
cx.tcx.enum_variants(edef.did)
611611
.iter()
612612
.map(|va| Variant(va.id))
613613
.collect(),
@@ -817,13 +817,13 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
817817
ty::TyStr => 0,
818818
_ => 1
819819
},
820-
ty::TyEnum(eid, _) => {
820+
ty::TyEnum(edef, _) => {
821821
match *ctor {
822-
Variant(id) => cx.tcx.enum_variant_with_id(eid, id).args.len(),
822+
Variant(id) => cx.tcx.enum_variant_with_id(edef.did, id).args.len(),
823823
_ => unreachable!()
824824
}
825825
}
826-
ty::TyStruct(cid, _) => cx.tcx.lookup_struct_fields(cid).len(),
826+
ty::TyStruct(cdef, _) => cx.tcx.lookup_struct_fields(cdef.did).len(),
827827
ty::TyArray(_, n) => n,
828828
_ => 0
829829
}

branches/beta/src/librustc/middle/dead.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
101101

102102
fn handle_field_access(&mut self, lhs: &ast::Expr, name: ast::Name) {
103103
match self.tcx.expr_ty_adjusted(lhs).sty {
104-
ty::TyStruct(id, _) => {
105-
let fields = self.tcx.lookup_struct_fields(id);
104+
ty::TyStruct(def, _) => {
105+
let fields = self.tcx.lookup_struct_fields(def.did);
106106
let field_id = fields.iter()
107107
.find(|field| field.name == name).unwrap().id;
108108
self.live_symbols.insert(field_id.node);
@@ -113,8 +113,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
113113

114114
fn handle_tup_field_access(&mut self, lhs: &ast::Expr, idx: usize) {
115115
match self.tcx.expr_ty_adjusted(lhs).sty {
116-
ty::TyStruct(id, _) => {
117-
let fields = self.tcx.lookup_struct_fields(id);
116+
ty::TyStruct(def, _) => {
117+
let fields = self.tcx.lookup_struct_fields(def.did);
118118
let field_id = fields[idx].id;
119119
self.live_symbols.insert(field_id.node);
120120
},

branches/beta/src/librustc/middle/expr_use_visitor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
695695
// Select just those fields of the `with`
696696
// expression that will actually be used
697697
let with_fields = match with_cmt.ty.sty {
698-
ty::TyStruct(did, substs) => {
699-
self.tcx().struct_fields(did, substs)
698+
ty::TyStruct(def, substs) => {
699+
self.tcx().struct_fields(def.did, substs)
700700
}
701701
_ => {
702702
// the base expression should always evaluate to a
@@ -708,7 +708,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
708708
with_expr.span,
709709
"with expression doesn't evaluate to a struct");
710710
}
711-
assert!(self.tcx().sess.has_errors());
712711
vec!()
713712
}
714713
};

branches/beta/src/librustc/middle/fast_reject.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ pub fn simplify_type(tcx: &ty::ctxt,
5353
ty::TyInt(int_type) => Some(IntSimplifiedType(int_type)),
5454
ty::TyUint(uint_type) => Some(UintSimplifiedType(uint_type)),
5555
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
56-
ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
56+
ty::TyEnum(def, _) => Some(EnumSimplifiedType(def.did)),
5757
ty::TyStr => Some(StrSimplifiedType),
5858
ty::TyArray(..) | ty::TySlice(_) => Some(VecSimplifiedType),
5959
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
6060
ty::TyTrait(ref trait_info) => {
6161
Some(TraitSimplifiedType(trait_info.principal_def_id()))
6262
}
63-
ty::TyStruct(def_id, _) => {
64-
Some(StructSimplifiedType(def_id))
63+
ty::TyStruct(def, _) => {
64+
Some(StructSimplifiedType(def.did))
6565
}
6666
ty::TyRef(_, mt) => {
6767
// since we introduce auto-refs during method lookup, we

branches/beta/src/librustc/middle/implicator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
144144
self.accumulate_from_object_ty(ty, t.bounds.region_bound, required_region_bounds)
145145
}
146146

147-
ty::TyEnum(def_id, substs) |
148-
ty::TyStruct(def_id, substs) => {
149-
let item_scheme = self.tcx().lookup_item_type(def_id);
150-
self.accumulate_from_adt(ty, def_id, &item_scheme.generics, substs)
147+
ty::TyEnum(def, substs) |
148+
ty::TyStruct(def, substs) => {
149+
let item_scheme = def.type_scheme(self.tcx());
150+
self.accumulate_from_adt(ty, def.did, &item_scheme.generics, substs)
151151
}
152152

153153
ty::TyArray(t, _) |

branches/beta/src/librustc/middle/stability.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
415415
ast::ExprField(ref base_e, ref field) => {
416416
span = field.span;
417417
match tcx.expr_ty_adjusted(base_e).sty {
418-
ty::TyStruct(did, _) => {
419-
tcx.lookup_struct_fields(did)
418+
ty::TyStruct(def, _) => {
419+
tcx.lookup_struct_fields(def.did)
420420
.iter()
421421
.find(|f| f.name == field.node.name)
422422
.unwrap_or_else(|| {
@@ -432,8 +432,8 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
432432
ast::ExprTupField(ref base_e, ref field) => {
433433
span = field.span;
434434
match tcx.expr_ty_adjusted(base_e).sty {
435-
ty::TyStruct(did, _) => {
436-
tcx.lookup_struct_fields(did)
435+
ty::TyStruct(def, _) => {
436+
tcx.lookup_struct_fields(def.did)
437437
.get(field.node)
438438
.unwrap_or_else(|| {
439439
tcx.sess.span_bug(field.span,
@@ -450,8 +450,8 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
450450
ast::ExprStruct(_, ref expr_fields, _) => {
451451
let type_ = tcx.expr_ty(e);
452452
match type_.sty {
453-
ty::TyStruct(did, _) => {
454-
let struct_fields = tcx.lookup_struct_fields(did);
453+
ty::TyStruct(def, _) => {
454+
let struct_fields = tcx.lookup_struct_fields(def.did);
455455
// check the stability of each field that appears
456456
// in the construction expression.
457457
for field in expr_fields {
@@ -505,11 +505,11 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &ast::Pat,
505505
debug!("check_pat(pat = {:?})", pat);
506506
if is_internal(tcx, pat.span) { return; }
507507

508-
let did = match tcx.pat_ty_opt(pat) {
509-
Some(&ty::TyS { sty: ty::TyStruct(did, _), .. }) => did,
508+
let def = match tcx.pat_ty_opt(pat) {
509+
Some(&ty::TyS { sty: ty::TyStruct(def, _), .. }) => def,
510510
Some(_) | None => return,
511511
};
512-
let struct_fields = tcx.lookup_struct_fields(did);
512+
let struct_fields = tcx.lookup_struct_fields(def.did);
513513
match pat.node {
514514
// Foo(a, b, c)
515515
ast::PatEnum(_, Some(ref pat_fields)) => {

branches/beta/src/librustc/middle/traits/coherence.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool
278278
match ty.sty {
279279
ty::TyBox(..) | ty::TyRef(..) =>
280280
true,
281-
ty::TyEnum(def_id, _) | ty::TyStruct(def_id, _) =>
282-
tcx.has_attr(def_id, "fundamental"),
281+
ty::TyEnum(def, _) | ty::TyStruct(def, _) => def.is_fundamental()
282+
,
283283
ty::TyTrait(ref data) =>
284284
tcx.has_attr(data.principal_def_id(), "fundamental"),
285285
_ =>
@@ -316,9 +316,9 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
316316
infer_is_local.0
317317
}
318318

319-
ty::TyEnum(def_id, _) |
320-
ty::TyStruct(def_id, _) => {
321-
def_id.krate == ast::LOCAL_CRATE
319+
ty::TyEnum(def, _) |
320+
ty::TyStruct(def, _) => {
321+
def.did.krate == ast::LOCAL_CRATE
322322
}
323323

324324
ty::TyBox(_) => { // Box<T>

branches/beta/src/librustc/middle/traits/select.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,17 +1721,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17211721
ok_if(substs.upvar_tys.clone())
17221722
}
17231723

1724-
ty::TyStruct(def_id, substs) => {
1724+
ty::TyStruct(def, substs) => {
17251725
let types: Vec<Ty> =
1726-
self.tcx().struct_fields(def_id, substs).iter()
1727-
.map(|f| f.mt.ty)
1728-
.collect();
1726+
self.tcx().struct_fields(def.did, substs).iter()
1727+
.map(|f| f.mt.ty)
1728+
.collect();
17291729
nominal(bound, types)
17301730
}
17311731

1732-
ty::TyEnum(def_id, substs) => {
1732+
ty::TyEnum(def, substs) => {
17331733
let types: Vec<Ty> =
1734-
self.tcx().substd_enum_variants(def_id, substs)
1734+
self.tcx().substd_enum_variants(def.did, substs)
17351735
.iter()
17361736
.flat_map(|variant| &variant.args)
17371737
.cloned()
@@ -1861,25 +1861,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18611861
}
18621862

18631863
// for `PhantomData<T>`, we pass `T`
1864-
ty::TyStruct(def_id, substs)
1865-
if Some(def_id) == self.tcx().lang_items.phantom_data() =>
1866-
{
1864+
ty::TyStruct(def, substs) if def.is_phantom_data() => {
18671865
substs.types.get_slice(TypeSpace).to_vec()
18681866
}
18691867

1870-
ty::TyStruct(def_id, substs) => {
1871-
self.tcx().struct_fields(def_id, substs)
1868+
ty::TyStruct(def, substs) => {
1869+
self.tcx().struct_fields(def.did, substs)
18721870
.iter()
18731871
.map(|f| f.mt.ty)
18741872
.collect()
18751873
}
18761874

1877-
ty::TyEnum(def_id, substs) => {
1878-
self.tcx().substd_enum_variants(def_id, substs)
1879-
.iter()
1880-
.flat_map(|variant| &variant.args)
1881-
.map(|&ty| ty)
1882-
.collect()
1875+
ty::TyEnum(def, substs) => {
1876+
self.tcx().substd_enum_variants(def.did, substs)
1877+
.iter()
1878+
.flat_map(|variant| &variant.args)
1879+
.map(|&ty| ty)
1880+
.collect()
18831881
}
18841882
}
18851883
}
@@ -2523,9 +2521,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25232521
}
25242522

25252523
// Struct<T> -> Struct<U>.
2526-
(&ty::TyStruct(def_id, substs_a), &ty::TyStruct(_, substs_b)) => {
2527-
let fields = tcx.lookup_struct_fields(def_id).iter().map(|f| {
2528-
tcx.lookup_field_type_unsubstituted(def_id, f.id)
2524+
(&ty::TyStruct(def, substs_a), &ty::TyStruct(_, substs_b)) => {
2525+
let fields = tcx.lookup_struct_fields(def.did).iter().map(|f| {
2526+
tcx.lookup_field_type_unsubstituted(def.did, f.id)
25292527
}).collect::<Vec<_>>();
25302528

25312529
// The last field of the structure has to exist and contain type parameters.
@@ -2572,7 +2570,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25722570
let param_b = *substs_b.types.get(TypeSpace, i);
25732571
new_substs.types.get_mut_slice(TypeSpace)[i] = param_b;
25742572
}
2575-
let new_struct = tcx.mk_struct(def_id, tcx.mk_substs(new_substs));
2573+
let new_struct = tcx.mk_struct(def, tcx.mk_substs(new_substs));
25762574
let origin = infer::Misc(obligation.cause.span);
25772575
if self.infcx.sub_types(false, origin, new_struct, target).is_err() {
25782576
return Err(Unimplemented);

0 commit comments

Comments
 (0)