Skip to content

Commit eae9b3b

Browse files
committed
---
yaml --- r: 164619 b: refs/heads/auto c: 1205fd8 h: refs/heads/master i: 164617: 9100c7e 164615: 4dfe073 v: v3
1 parent 9474cc5 commit eae9b3b

Some content is hidden

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

49 files changed

+463
-546
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: ed4952ef392952dc4a7d0241386daf575dea5d6e
13+
refs/heads/auto: 1205fd88df2b87c682f2e98e30ba9e2d8d44d656
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
429429
{
430430
let item_doc = lookup_item(id, cdata.data());
431431
reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
432-
Rc::new(ty::bind(doc_trait_ref(tp, tcx, cdata)))
432+
Rc::new(ty::Binder(doc_trait_ref(tp, tcx, cdata)))
433433
})
434434
}
435435

@@ -704,7 +704,7 @@ pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::Nod
704704
let name = item_name(&*intr, item);
705705
let (ctor_ty, arg_tys, arg_names) = match ctor_ty.sty {
706706
ty::ty_bare_fn(ref f) =>
707-
(Some(ctor_ty), f.sig.inputs.clone(), None),
707+
(Some(ctor_ty), f.sig.0.inputs.clone(), None),
708708
_ => { // Nullary or struct enum variant.
709709
let mut arg_names = Vec::new();
710710
let arg_tys = get_struct_fields(intr.clone(), cdata, did.node)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
414414
}
415415
'x' => {
416416
assert_eq!(next(st), '[');
417-
let trait_ref = ty::bind(parse_trait_ref(st, |x,y| conv(x,y)));
417+
let trait_ref = ty::Binder(parse_trait_ref(st, |x,y| conv(x,y)));
418418
let bounds = parse_existential_bounds(st, |x,y| conv(x,y));
419419
assert_eq!(next(st), ']');
420420
return ty::mk_trait(st.tcx, trait_ref, bounds);
@@ -603,7 +603,7 @@ fn parse_bare_fn_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
603603
}
604604
}
605605

606-
fn parse_sig<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> ty::FnSig<'tcx> {
606+
fn parse_sig<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> ty::PolyFnSig<'tcx> {
607607
assert_eq!(next(st), '[');
608608
let mut inputs = Vec::new();
609609
while peek(st) != ']' {
@@ -622,9 +622,9 @@ fn parse_sig<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> ty::FnSig<'
622622
}
623623
_ => ty::FnConverging(parse_ty(st, |x,y| conv(x,y)))
624624
};
625-
ty::FnSig {inputs: inputs,
626-
output: output,
627-
variadic: variadic}
625+
ty::Binder(ty::FnSig {inputs: inputs,
626+
output: output,
627+
variadic: variadic})
628628
}
629629

630630
// Rust metadata parsing
@@ -669,7 +669,7 @@ pub fn parse_predicate<'a,'tcx>(st: &mut PState<'a, 'tcx>,
669669
-> ty::Predicate<'tcx>
670670
{
671671
match next(st) {
672-
't' => ty::Predicate::Trait(Rc::new(ty::bind(parse_trait_ref(st, conv)))),
672+
't' => ty::Predicate::Trait(Rc::new(ty::Binder(parse_trait_ref(st, conv)))),
673673
'e' => ty::Predicate::Equate(parse_ty(st, |x,y| conv(x,y)),
674674
parse_ty(st, |x,y| conv(x,y))),
675675
'r' => ty::Predicate::RegionOutlives(parse_region(st, |x,y| conv(x,y)),
@@ -764,7 +764,7 @@ fn parse_bounds<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
764764
}
765765
'I' => {
766766
param_bounds.trait_bounds.push(
767-
Rc::new(ty::bind(parse_trait_ref(st, |x,y| conv(x,y)))));
767+
Rc::new(ty::Binder(parse_trait_ref(st, |x,y| conv(x,y)))));
768768
}
769769
'.' => {
770770
return param_bounds;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn enc_sty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
251251
ty::ty_trait(box ty::TyTrait { ref principal,
252252
ref bounds }) => {
253253
mywrite!(w, "x[");
254-
enc_trait_ref(w, cx, &principal.value);
254+
enc_trait_ref(w, cx, &principal.0);
255255
enc_existential_bounds(w, cx, bounds);
256256
mywrite!(w, "]");
257257
}
@@ -351,18 +351,18 @@ pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
351351
}
352352

353353
fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
354-
fsig: &ty::FnSig<'tcx>) {
354+
fsig: &ty::PolyFnSig<'tcx>) {
355355
mywrite!(w, "[");
356-
for ty in fsig.inputs.iter() {
356+
for ty in fsig.0.inputs.iter() {
357357
enc_ty(w, cx, *ty);
358358
}
359359
mywrite!(w, "]");
360-
if fsig.variadic {
360+
if fsig.0.variadic {
361361
mywrite!(w, "V");
362362
} else {
363363
mywrite!(w, "N");
364364
}
365-
match fsig.output {
365+
match fsig.0.output {
366366
ty::FnConverging(result_type) => {
367367
enc_ty(w, cx, result_type);
368368
}
@@ -401,7 +401,7 @@ pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
401401

402402
for tp in bs.trait_bounds.iter() {
403403
mywrite!(w, "I");
404-
enc_trait_ref(w, cx, &tp.value);
404+
enc_trait_ref(w, cx, &tp.0);
405405
}
406406

407407
mywrite!(w, ".");
@@ -425,7 +425,7 @@ pub fn enc_predicate<'a, 'tcx>(w: &mut SeekableMemWriter,
425425
match *p {
426426
ty::Predicate::Trait(ref trait_ref) => {
427427
mywrite!(w, "t");
428-
enc_trait_ref(w, cx, &trait_ref.value);
428+
enc_trait_ref(w, cx, &trait_ref.0);
429429
}
430430
ty::Predicate::Equate(a, b) => {
431431
mywrite!(w, "e");

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
887887
this.emit_enum_variant("MethodTypeParam", 2, 1, |this| {
888888
this.emit_struct("MethodParam", 2, |this| {
889889
try!(this.emit_struct_field("trait_ref", 0, |this| {
890-
Ok(this.emit_trait_ref(ecx, &p.trait_ref.value))
890+
Ok(this.emit_trait_ref(ecx, &p.trait_ref.0))
891891
}));
892892
try!(this.emit_struct_field("method_num", 0, |this| {
893893
this.emit_uint(p.method_num)
@@ -901,7 +901,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
901901
this.emit_enum_variant("MethodTraitObject", 3, 1, |this| {
902902
this.emit_struct("MethodObject", 2, |this| {
903903
try!(this.emit_struct_field("trait_ref", 0, |this| {
904-
Ok(this.emit_trait_ref(ecx, &o.trait_ref.value))
904+
Ok(this.emit_trait_ref(ecx, &o.trait_ref.0))
905905
}));
906906
try!(this.emit_struct_field("object_trait_id", 0, |this| {
907907
Ok(this.emit_def_id(o.object_trait_id))
@@ -1113,7 +1113,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
11131113
this.emit_enum_variant("UnsizeVtable", 2, 4, |this| {
11141114
this.emit_enum_variant_arg(0, |this| {
11151115
try!(this.emit_struct_field("principal", 0, |this| {
1116-
Ok(this.emit_trait_ref(ecx, &principal.value))
1116+
Ok(this.emit_trait_ref(ecx, &principal.0))
11171117
}));
11181118
this.emit_struct_field("bounds", 1, |this| {
11191119
Ok(this.emit_existential_bounds(ecx, b))
@@ -1277,7 +1277,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12771277
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
12781278
rbml_w.id(id);
12791279
rbml_w.tag(c::tag_table_val, |rbml_w| {
1280-
rbml_w.emit_trait_ref(ecx, &trait_ref.value);
1280+
rbml_w.emit_trait_ref(ecx, &trait_ref.0);
12811281
})
12821282
})
12831283
}
@@ -1552,7 +1552,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
15521552

15531553
fn read_poly_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
15541554
-> Rc<ty::PolyTraitRef<'tcx>> {
1555-
Rc::new(ty::bind(self.read_opaque(|this, doc| {
1555+
Rc::new(ty::Binder(self.read_opaque(|this, doc| {
15561556
let ty = tydecode::parse_trait_ref_data(
15571557
doc.data,
15581558
dcx.cdata.cnum,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl OverloadedCallType {
265265
}
266266
Some(ref trait_ref) => (*trait_ref).clone(),
267267
};
268-
OverloadedCallType::from_trait_id(tcx, trait_ref.value.def_id)
268+
OverloadedCallType::from_trait_id(tcx, trait_ref.def_id())
269269
}
270270

271271
fn from_unboxed_closure(tcx: &ty::ctxt, closure_did: ast::DefId)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
6060
ty::ty_vec(..) => Some(VecSimplifiedType),
6161
ty::ty_ptr(_) => Some(PtrSimplifiedType),
6262
ty::ty_trait(ref trait_info) => {
63-
Some(TraitSimplifiedType(trait_info.principal.value.def_id))
63+
Some(TraitSimplifiedType(trait_info.principal.def_id()))
6464
}
6565
ty::ty_struct(def_id, _) => {
6666
Some(StructSimplifiedType(def_id))
@@ -83,10 +83,10 @@ pub fn simplify_type(tcx: &ty::ctxt,
8383
Some(TupleSimplifiedType(tys.len()))
8484
}
8585
ty::ty_closure(ref f) => {
86-
Some(FunctionSimplifiedType(f.sig.inputs.len()))
86+
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
8787
}
8888
ty::ty_bare_fn(ref f) => {
89-
Some(FunctionSimplifiedType(f.sig.inputs.len()))
89+
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
9090
}
9191
ty::ty_param(_) => {
9292
if can_simplify_params {

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

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub trait Combine<'tcx> {
195195
b: &ty::BareFnTy<'tcx>) -> cres<'tcx, ty::BareFnTy<'tcx>> {
196196
let unsafety = try!(self.unsafeties(a.unsafety, b.unsafety));
197197
let abi = try!(self.abi(a.abi, b.abi));
198-
let sig = try!(self.fn_sigs(&a.sig, &b.sig));
198+
let sig = try!(self.binders(&a.sig, &b.sig));
199199
Ok(ty::BareFnTy {unsafety: unsafety,
200200
abi: abi,
201201
sig: sig})
@@ -222,7 +222,7 @@ pub trait Combine<'tcx> {
222222
let unsafety = try!(self.unsafeties(a.unsafety, b.unsafety));
223223
let onceness = try!(self.oncenesses(a.onceness, b.onceness));
224224
let bounds = try!(self.existential_bounds(a.bounds, b.bounds));
225-
let sig = try!(self.fn_sigs(&a.sig, &b.sig));
225+
let sig = try!(self.binders(&a.sig, &b.sig));
226226
let abi = try!(self.abi(a.abi, b.abi));
227227
Ok(ty::ClosureTy {
228228
unsafety: unsafety,
@@ -234,7 +234,43 @@ pub trait Combine<'tcx> {
234234
})
235235
}
236236

237-
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>>;
237+
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::FnSig<'tcx>> {
238+
if a.variadic != b.variadic {
239+
return Err(ty::terr_variadic_mismatch(expected_found(self, a.variadic, b.variadic)));
240+
}
241+
242+
let inputs = try!(argvecs(self,
243+
a.inputs.as_slice(),
244+
b.inputs.as_slice()));
245+
246+
let output = try!(match (a.output, b.output) {
247+
(ty::FnConverging(a_ty), ty::FnConverging(b_ty)) =>
248+
Ok(ty::FnConverging(try!(self.tys(a_ty, b_ty)))),
249+
(ty::FnDiverging, ty::FnDiverging) =>
250+
Ok(ty::FnDiverging),
251+
(a, b) =>
252+
Err(ty::terr_convergence_mismatch(
253+
expected_found(self, a != ty::FnDiverging, b != ty::FnDiverging))),
254+
});
255+
256+
return Ok(ty::FnSig {inputs: inputs,
257+
output: output,
258+
variadic: a.variadic});
259+
260+
261+
fn argvecs<'tcx, C: Combine<'tcx>>(combiner: &C,
262+
a_args: &[Ty<'tcx>],
263+
b_args: &[Ty<'tcx>])
264+
-> cres<'tcx, Vec<Ty<'tcx>>>
265+
{
266+
if a_args.len() == b_args.len() {
267+
a_args.iter().zip(b_args.iter())
268+
.map(|(a, b)| combiner.args(*a, *b)).collect()
269+
} else {
270+
Err(ty::terr_arg_count)
271+
}
272+
}
273+
}
238274

239275
fn args(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
240276
self.contratys(a, b).and_then(|t| Ok(t))
@@ -312,14 +348,36 @@ pub trait Combine<'tcx> {
312348
}
313349
}
314350

315-
fn poly_trait_refs(&self,
316-
a: &ty::PolyTraitRef<'tcx>,
317-
b: &ty::PolyTraitRef<'tcx>)
318-
-> cres<'tcx, ty::PolyTraitRef<'tcx>>;
351+
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
352+
where T : Combineable<'tcx>;
319353
// this must be overridden to do correctly, so as to account for higher-ranked
320354
// behavior
321355
}
322356

357+
pub trait Combineable<'tcx> : Repr<'tcx> + TypeFoldable<'tcx> {
358+
fn combine<C:Combine<'tcx>>(combiner: &C, a: &Self, b: &Self) -> cres<'tcx, Self>;
359+
}
360+
361+
impl<'tcx> Combineable<'tcx> for ty::TraitRef<'tcx> {
362+
fn combine<C:Combine<'tcx>>(combiner: &C,
363+
a: &ty::TraitRef<'tcx>,
364+
b: &ty::TraitRef<'tcx>)
365+
-> cres<'tcx, ty::TraitRef<'tcx>>
366+
{
367+
combiner.trait_refs(a, b)
368+
}
369+
}
370+
371+
impl<'tcx> Combineable<'tcx> for ty::FnSig<'tcx> {
372+
fn combine<C:Combine<'tcx>>(combiner: &C,
373+
a: &ty::FnSig<'tcx>,
374+
b: &ty::FnSig<'tcx>)
375+
-> cres<'tcx, ty::FnSig<'tcx>>
376+
{
377+
combiner.fn_sigs(a, b)
378+
}
379+
}
380+
323381
#[deriving(Clone)]
324382
pub struct CombineFields<'a, 'tcx: 'a> {
325383
pub infcx: &'a InferCtxt<'a, 'tcx>,
@@ -424,7 +482,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
424482
(&ty::ty_trait(ref a_),
425483
&ty::ty_trait(ref b_)) => {
426484
debug!("Trying to match traits {} and {}", a, b);
427-
let principal = try!(this.poly_trait_refs(&a_.principal, &b_.principal));
485+
let principal = try!(this.binders(&a_.principal, &b_.principal));
428486
let bounds = try!(this.existential_bounds(a_.bounds, b_.bounds));
429487
Ok(ty::mk_trait(tcx, principal, bounds))
430488
}

branches/auto/src/librustc/middle/infer/equate.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,10 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
133133
}
134134
}
135135

136-
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
137-
-> cres<'tcx, ty::FnSig<'tcx>>
136+
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
137+
where T : Combineable<'tcx>
138138
{
139-
try!(self.sub().fn_sigs(a, b));
140-
self.sub().fn_sigs(b, a)
141-
}
142-
143-
fn poly_trait_refs(&self, a: &ty::PolyTraitRef<'tcx>, b: &ty::PolyTraitRef<'tcx>)
144-
-> cres<'tcx, ty::PolyTraitRef<'tcx>>
145-
{
146-
try!(self.sub().poly_trait_refs(a, b));
147-
self.sub().poly_trait_refs(b, a)
139+
try!(self.sub().binders(a, b));
140+
self.sub().binders(b, a)
148141
}
149142
}

branches/auto/src/librustc/middle/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ impl<'tcx> Resolvable<'tcx> for Rc<ty::PolyTraitRef<'tcx>> {
16531653
Rc::new(infcx.resolve_type_vars_if_possible(&**self))
16541654
}
16551655
fn contains_error(&self) -> bool {
1656-
ty::trait_ref_contains_error(&self.value)
1656+
ty::trait_ref_contains_error(&self.0)
16571657
}
16581658
}
16591659

branches/auto/src/librustc/middle/infer/glb.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,9 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
121121
super_lattice_tys(self, a, b)
122122
}
123123

124-
fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>)
125-
-> cres<'tcx, ty::FnSig<'tcx>> {
126-
self.higher_ranked_glb(a, b)
127-
}
128-
129-
fn poly_trait_refs(&self, a: &ty::PolyTraitRef<'tcx>, b: &ty::PolyTraitRef<'tcx>)
130-
-> cres<'tcx, ty::PolyTraitRef<'tcx>> {
124+
fn binders<T>(&self, a: &ty::Binder<T>, b: &ty::Binder<T>) -> cres<'tcx, ty::Binder<T>>
125+
where T : Combineable<'tcx>
126+
{
131127
self.higher_ranked_glb(a, b)
132128
}
133129
}

0 commit comments

Comments
 (0)