Skip to content

Commit e0299c6

Browse files
committed
---
yaml --- r: 170359 b: refs/heads/try c: 82787c2 h: refs/heads/master i: 170357: f765ec5 170355: 2321f38 170351: a0c3b7f v: v3
1 parent 93c7458 commit e0299c6

File tree

12 files changed

+44
-80
lines changed

12 files changed

+44
-80
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: 4404592f3631233c2f160c3f9a315764a4fcfba9
5+
refs/heads/try: 82787c2252267561777303bcc4e4d0394c34e5c9
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/decoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
245245
}
246246

247247
fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
248-
-> ty::TraitRef<'tcx> {
248+
-> Rc<ty::TraitRef<'tcx>> {
249249
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
250250
|_, did| translate_def_id(cdata, did))
251251
}
252252

253253
fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
254-
-> ty::TraitRef<'tcx> {
254+
-> Rc<ty::TraitRef<'tcx>> {
255255
let tp = reader::get_doc(doc, tag_item_trait_ref);
256256
doc_trait_ref(tp, tcx, cdata)
257257
}
@@ -394,7 +394,7 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
394394
unsafety: unsafety,
395395
generics: generics,
396396
bounds: bounds,
397-
trait_ref: Rc::new(item_trait_ref(item_doc, tcx, cdata)),
397+
trait_ref: item_trait_ref(item_doc, tcx, cdata),
398398
associated_type_names: associated_type_names,
399399
}
400400
}
@@ -441,7 +441,7 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
441441
{
442442
let item_doc = lookup_item(id, cdata.data());
443443
reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
444-
Rc::new(doc_trait_ref(tp, tcx, cdata))
444+
doc_trait_ref(tp, tcx, cdata)
445445
})
446446
}
447447

@@ -937,7 +937,7 @@ pub fn get_supertraits<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
937937
// FIXME(#8559): The builtin bounds shouldn't be encoded in the first place.
938938
let trait_ref = doc_trait_ref(trait_doc, tcx, cdata);
939939
if tcx.lang_items.to_builtin_kind(trait_ref.def_id).is_none() {
940-
results.push(Rc::new(trait_ref));
940+
results.push(trait_ref);
941941
}
942942
true
943943
});

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn parse_bare_fn_ty_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: u
180180

181181
pub fn parse_trait_ref_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: uint,
182182
tcx: &ty::ctxt<'tcx>, conv: conv_did)
183-
-> ty::TraitRef<'tcx> {
183+
-> Rc<ty::TraitRef<'tcx>> {
184184
debug!("parse_trait_ref_data {}", data_log_string(data, pos));
185185
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
186186
parse_trait_ref(&mut st, conv)
@@ -377,10 +377,10 @@ fn parse_str(st: &mut PState, term: char) -> String {
377377
}
378378

379379
fn parse_trait_ref<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
380-
-> ty::TraitRef<'tcx> {
380+
-> Rc<ty::TraitRef<'tcx>> {
381381
let def = parse_def(st, NominalType, |x,y| conv(x,y));
382-
let substs = parse_substs(st, |x,y| conv(x,y));
383-
ty::TraitRef {def_id: def, substs: st.tcx.mk_substs(substs)}
382+
let substs = st.tcx.mk_substs(parse_substs(st, |x,y| conv(x,y)));
383+
Rc::new(ty::TraitRef {def_id: def, substs: substs})
384384
}
385385

386386
fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
@@ -689,7 +689,7 @@ pub fn parse_predicate<'a,'tcx>(st: &mut PState<'a, 'tcx>,
689689
-> ty::Predicate<'tcx>
690690
{
691691
match next(st) {
692-
't' => ty::Binder(Rc::new(parse_trait_ref(st, conv))).as_predicate(),
692+
't' => ty::Binder(parse_trait_ref(st, conv)).as_predicate(),
693693
'e' => ty::Binder(ty::EquatePredicate(parse_ty(st, |x,y| conv(x,y)),
694694
parse_ty(st, |x,y| conv(x,y)))).as_predicate(),
695695
'r' => ty::Binder(ty::OutlivesPredicate(parse_region(st, |x,y| conv(x,y)),
@@ -708,7 +708,7 @@ fn parse_projection_predicate<'a,'tcx>(
708708
{
709709
ty::ProjectionPredicate {
710710
projection_ty: ty::ProjectionTy {
711-
trait_ref: Rc::new(parse_trait_ref(st, |x,y| conv(x,y))),
711+
trait_ref: parse_trait_ref(st, |x,y| conv(x,y)),
712712
item_name: token::str_to_ident(parse_str(st, '|').as_slice()).name,
713713
},
714714
ty: parse_ty(st, |x,y| conv(x,y)),
@@ -795,7 +795,7 @@ fn parse_bounds<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
795795
}
796796
'I' => {
797797
param_bounds.trait_bounds.push(
798-
ty::Binder(Rc::new(parse_trait_ref(st, |x,y| conv(x,y)))));
798+
ty::Binder(parse_trait_ref(st, |x,y| conv(x,y))));
799799
}
800800
'P' => {
801801
param_bounds.projection_bounds.push(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
9191
ty::ty_trait(box ty::TyTrait { ref principal,
9292
ref bounds }) => {
9393
mywrite!(w, "x[");
94-
enc_trait_ref(w, cx, &principal.0);
94+
enc_trait_ref(w, cx, &*principal.0);
9595
enc_existential_bounds(w, cx, bounds);
9696
mywrite!(w, "]");
9797
}
@@ -151,7 +151,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
151151
}
152152
ty::ty_projection(ref data) => {
153153
mywrite!(w, "P[");
154-
enc_trait_ref(w, cx, &data.trait_ref);
154+
enc_trait_ref(w, cx, &*data.trait_ref);
155155
mywrite!(w, "{}]", token::get_name(data.item_name));
156156
}
157157
ty::ty_err => {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
11201120
this.emit_enum_variant("UnsizeVtable", 2, 4, |this| {
11211121
this.emit_enum_variant_arg(0, |this| {
11221122
try!(this.emit_struct_field("principal", 0, |this| {
1123-
Ok(this.emit_trait_ref(ecx, &principal.0))
1123+
Ok(this.emit_trait_ref(ecx, &*principal.0))
11241124
}));
11251125
this.emit_struct_field("bounds", 1, |this| {
11261126
Ok(this.emit_existential_bounds(ecx, b))
@@ -1546,28 +1546,28 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
15461546

15471547
fn read_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
15481548
-> Rc<ty::TraitRef<'tcx>> {
1549-
Rc::new(self.read_opaque(|this, doc| {
1549+
self.read_opaque(|this, doc| {
15501550
let ty = tydecode::parse_trait_ref_data(
15511551
doc.data,
15521552
dcx.cdata.cnum,
15531553
doc.start,
15541554
dcx.tcx,
15551555
|s, a| this.convert_def_id(dcx, s, a));
15561556
Ok(ty)
1557-
}).unwrap())
1557+
}).unwrap()
15581558
}
15591559

15601560
fn read_poly_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
15611561
-> ty::PolyTraitRef<'tcx> {
1562-
ty::Binder(Rc::new(self.read_opaque(|this, doc| {
1562+
ty::Binder(self.read_opaque(|this, doc| {
15631563
let ty = tydecode::parse_trait_ref_data(
15641564
doc.data,
15651565
dcx.cdata.cnum,
15661566
doc.start,
15671567
dcx.tcx,
15681568
|s, a| this.convert_def_id(dcx, s, a));
15691569
Ok(ty)
1570-
}).unwrap()))
1570+
}).unwrap())
15711571
}
15721572

15731573
fn read_type_param_def<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
@@ -1786,7 +1786,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
17861786
Ok(this.read_poly_trait_ref(dcx))
17871787
}));
17881788
Ok(ty::TyTrait {
1789-
principal: ty::Binder((*principal.0).clone()),
1789+
principal: principal,
17901790
bounds: try!(this.read_struct_field("bounds", 1, |this| {
17911791
Ok(this.read_existential_bounds(dcx))
17921792
})),

branches/try/src/librustc/middle/infer/combine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
596596

597597
(&ty::ty_projection(ref a_data), &ty::ty_projection(ref b_data)) => {
598598
if a_data.item_name == b_data.item_name {
599-
let trait_ref = try!(this.trait_refs(&a_data.trait_ref, &b_data.trait_ref));
600-
Ok(ty::mk_projection(tcx, trait_ref, a_data.item_name))
599+
let trait_ref = try!(this.trait_refs(&*a_data.trait_ref, &*b_data.trait_ref));
600+
Ok(ty::mk_projection(tcx, Rc::new(trait_ref), a_data.item_name))
601601
} else {
602602
Err(ty::terr_sorts(expected_found(this, a, b)))
603603
}

branches/try/src/librustc/middle/traits/fulfill.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
422422
// somewhat constrained, and we cannot verify
423423
// that constraint, so yield an error.
424424
let ty_projection = ty::mk_projection(tcx,
425-
(*trait_ref.0).clone(),
426-
data.0.projection_ty.item_name);
425+
trait_ref.0.clone(),
426+
data.0.projection_ty.item_name);
427427

428428
debug!("process_predicate: falling back to projection {}",
429429
ty_projection.repr(selcx.tcx()));

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

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,13 +1352,13 @@ pub enum sty<'tcx> {
13521352

13531353
ty_closure(Box<ClosureTy<'tcx>>),
13541354
ty_trait(Box<TyTrait<'tcx>>),
1355-
ty_struct(DefId, &'tcx Substs<'tcx>),
1355+
ty_struct(DefId, Substs<'tcx>),
13561356

13571357
ty_unboxed_closure(DefId, &'tcx Region, &'tcx Substs<'tcx>),
13581358

13591359
ty_tup(Vec<Ty<'tcx>>),
13601360

1361-
ty_projection(Box<TyProjection<'tcx>>),
1361+
ty_projection(ProjectionTy<'tcx>),
13621362
ty_param(ParamTy), // type parameter
13631363

13641364
ty_open(Ty<'tcx>), // A deref'ed fat pointer, i.e., a dynamically sized value
@@ -1375,8 +1375,7 @@ pub enum sty<'tcx> {
13751375

13761376
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
13771377
pub struct TyTrait<'tcx> {
1378-
// Principal trait reference.
1379-
pub principal: ty::Binder<TraitRef<'tcx>>,
1378+
pub principal: ty::PolyTraitRef<'tcx>,
13801379
pub bounds: ExistentialBounds
13811380
}
13821381

@@ -1448,12 +1447,6 @@ impl<'tcx> PolyTraitRef<'tcx> {
14481447
// Note that we preserve binding levels
14491448
Binder(TraitPredicate { trait_ref: self.0.clone() })
14501449
}
1451-
1452-
pub fn remove_rc(&self) -> ty::Binder<ty::TraitRef<'tcx>> {
1453-
// Annoyingly, we can't easily put a `Rc` into a `sty` structure,
1454-
// and hence we have to remove the rc to put this into a `TyTrait`.
1455-
ty::Binder((*self.0).clone())
1456-
}
14571450
}
14581451

14591452
/// Binder is a binder for higher-ranked lifetimes. It is part of the
@@ -1833,15 +1826,6 @@ pub struct ProjectionTy<'tcx> {
18331826
pub item_name: ast::Name,
18341827
}
18351828

1836-
// Annoying: a version of `ProjectionTy` that avoids the `Rc`, because
1837-
// it is difficult to place an `Rc` in the `sty` struct. Eventually
1838-
// these two types ought to be unified.
1839-
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
1840-
pub struct TyProjection<'tcx> {
1841-
pub trait_ref: ty::TraitRef<'tcx>,
1842-
pub item_name: ast::Name,
1843-
}
1844-
18451829
pub trait ToPolyTraitRef<'tcx> {
18461830
fn to_poly_trait_ref(&self) -> PolyTraitRef<'tcx>;
18471831
}
@@ -2690,10 +2674,9 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
26902674
}
26912675

26922676
pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
2693-
principal: ty::Binder<ty::TraitRef<'tcx>>,
2677+
principal: ty::PolyTraitRef<'tcx>,
26942678
bounds: ExistentialBounds)
26952679
-> Ty<'tcx> {
2696-
// take a copy of substs so that we own the vectors inside
26972680
let inner = box TyTrait {
26982681
principal: principal,
26992682
bounds: bounds
@@ -2702,11 +2685,11 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
27022685
}
27032686

27042687
pub fn mk_projection<'tcx>(cx: &ctxt<'tcx>,
2705-
trait_ref: ty::TraitRef<'tcx>,
2688+
trait_ref: Rc<ty::TraitRef<'tcx>>,
27062689
item_name: ast::Name)
27072690
-> Ty<'tcx> {
27082691
// take a copy of substs so that we own the vectors inside
2709-
let inner = box TyProjection { trait_ref: trait_ref, item_name: item_name };
2692+
let inner = ProjectionTy { trait_ref: trait_ref, item_name: item_name };
27102693
mk_t(cx, ty_projection(inner))
27112694
}
27122695

@@ -2776,7 +2759,7 @@ pub fn maybe_walk_ty<'tcx>(ty: Ty<'tcx>, f: |Ty<'tcx>| -> bool) {
27762759
maybe_walk_ty(*subty, |x| f(x));
27772760
}
27782761
}
2779-
ty_projection(box TyProjection { ref trait_ref, .. }) => {
2762+
ty_projection(ProjectionTy { ref trait_ref, .. }) => {
27802763
for subty in trait_ref.substs.types.iter() {
27812764
maybe_walk_ty(*subty, |x| f(x));
27822765
}
@@ -5783,7 +5766,7 @@ pub fn each_bound_trait_and_supertraits<'tcx, F>(tcx: &ctxt<'tcx>,
57835766

57845767
pub fn object_region_bounds<'tcx>(
57855768
tcx: &ctxt<'tcx>,
5786-
opt_principal: Option<&Binder<TraitRef<'tcx>>>, // None for closures
5769+
opt_principal: Option<&PolyTraitRef<'tcx>>, // None for closures
57875770
others: BuiltinBounds)
57885771
-> Vec<ty::Region>
57895772
{
@@ -6913,14 +6896,6 @@ impl<'tcx> Repr<'tcx> for ty::ProjectionPredicate<'tcx> {
69136896
}
69146897
}
69156898

6916-
impl<'tcx> Repr<'tcx> for ty::TyProjection<'tcx> {
6917-
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
6918-
format!("TyProjection({}, {})",
6919-
self.trait_ref.repr(tcx),
6920-
self.item_name.repr(tcx))
6921-
}
6922-
}
6923-
69246899
pub trait HasProjectionTypes {
69256900
fn has_projection_types(&self) -> bool;
69266901
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ProjectionTy<'tcx> {
436436
}
437437
}
438438

439-
impl<'tcx> TypeFoldable<'tcx> for ty::TyProjection<'tcx> {
440-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TyProjection<'tcx> {
441-
ty::TyProjection {
442-
trait_ref: self.trait_ref.fold_with(folder),
443-
item_name: self.item_name,
444-
}
445-
}
446-
}
447-
448439
impl<'tcx> TypeFoldable<'tcx> for ty::GenericBounds<'tcx> {
449440
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::GenericBounds<'tcx> {
450441
ty::GenericBounds {

0 commit comments

Comments
 (0)