@@ -47,22 +47,22 @@ mod util;
47
47
/// provides the required vtable, or else finding a bound that is in
48
48
/// scope. The eventual result is usually a `Selection` (defined below).
49
49
#[ deriving( Clone ) ]
50
- pub struct Obligation < ' tcx > {
50
+ pub struct Obligation < ' tcx , T > {
51
51
pub cause : ObligationCause < ' tcx > ,
52
52
pub recursion_depth : uint ,
53
- pub trait_ref : Rc < ty :: TraitRef < ' tcx > > ,
53
+ pub trait_ref : T ,
54
54
}
55
55
56
+ pub type TraitObligation < ' tcx > = Obligation < ' tcx , Rc < ty:: TraitRef < ' tcx > > > ;
57
+
56
58
/// Why did we incur this obligation? Used for error reporting.
57
- #[ deriving( Clone ) ]
59
+ #[ deriving( Copy , Clone ) ]
58
60
pub struct ObligationCause < ' tcx > {
59
61
pub span : Span ,
60
62
pub code : ObligationCauseCode < ' tcx >
61
63
}
62
64
63
- impl < ' tcx > Copy for ObligationCause < ' tcx > { }
64
-
65
- #[ deriving( Clone ) ]
65
+ #[ deriving( Copy , Clone ) ]
66
66
pub enum ObligationCauseCode < ' tcx > {
67
67
/// Not well classified or should be obvious from span.
68
68
MiscObligation ,
@@ -95,11 +95,11 @@ pub enum ObligationCauseCode<'tcx> {
95
95
ObjectSized ,
96
96
}
97
97
98
- pub type Obligations < ' tcx > = subst:: VecPerParamSpace < Obligation < ' tcx > > ;
98
+ pub type Obligations < ' tcx , O > = subst:: VecPerParamSpace < Obligation < ' tcx , O > > ;
99
99
100
- impl < ' tcx > Copy for ObligationCauseCode < ' tcx > { }
100
+ pub type TraitObligations < ' tcx > = subst :: VecPerParamSpace < TraitObligation < ' tcx > > ;
101
101
102
- pub type Selection < ' tcx > = Vtable < ' tcx , Obligation < ' tcx > > ;
102
+ pub type Selection < ' tcx > = Vtable < ' tcx , TraitObligation < ' tcx > > ;
103
103
104
104
#[ deriving( Clone , Show ) ]
105
105
pub enum SelectionError < ' tcx > {
@@ -109,7 +109,7 @@ pub enum SelectionError<'tcx> {
109
109
}
110
110
111
111
pub struct FulfillmentError < ' tcx > {
112
- pub obligation : Obligation < ' tcx > ,
112
+ pub obligation : TraitObligation < ' tcx > ,
113
113
pub code : FulfillmentErrorCode < ' tcx >
114
114
}
115
115
@@ -230,7 +230,7 @@ pub fn select_inherent_impl<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
230
230
impl_def_id : ast:: DefId ,
231
231
self_ty : Ty < ' tcx > )
232
232
-> SelectionResult < ' tcx ,
233
- VtableImplData < ' tcx , Obligation < ' tcx > > >
233
+ VtableImplData < ' tcx , TraitObligation < ' tcx > > >
234
234
{
235
235
// This routine is only suitable for inherent impls. This is
236
236
// because it does not attempt to unify the output type parameters
@@ -279,7 +279,7 @@ pub fn obligations_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
279
279
cause : ObligationCause < ' tcx > ,
280
280
generic_bounds : & ty:: GenericBounds < ' tcx > ,
281
281
type_substs : & subst:: VecPerParamSpace < Ty < ' tcx > > )
282
- -> subst:: VecPerParamSpace < Obligation < ' tcx > >
282
+ -> subst:: VecPerParamSpace < TraitObligation < ' tcx > >
283
283
{
284
284
util:: obligations_for_generics ( tcx, cause, 0 , generic_bounds, type_substs)
285
285
}
@@ -288,23 +288,27 @@ pub fn obligation_for_builtin_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
288
288
cause : ObligationCause < ' tcx > ,
289
289
source_ty : Ty < ' tcx > ,
290
290
builtin_bound : ty:: BuiltinBound )
291
- -> Result < Obligation < ' tcx > , ErrorReported >
291
+ -> Result < TraitObligation < ' tcx > , ErrorReported >
292
292
{
293
293
util:: obligation_for_builtin_bound ( tcx, cause, builtin_bound, 0 , source_ty)
294
294
}
295
295
296
- impl < ' tcx > Obligation < ' tcx > {
297
- pub fn new ( cause : ObligationCause < ' tcx > , trait_ref : Rc < ty:: TraitRef < ' tcx > > )
298
- -> Obligation < ' tcx > {
296
+ impl < ' tcx , O > Obligation < ' tcx , O > {
297
+ pub fn new ( cause : ObligationCause < ' tcx > ,
298
+ trait_ref : O )
299
+ -> Obligation < ' tcx , O >
300
+ {
299
301
Obligation { cause : cause,
300
302
recursion_depth : 0 ,
301
303
trait_ref : trait_ref }
302
304
}
303
305
304
- pub fn misc ( span : Span , trait_ref : Rc < ty :: TraitRef < ' tcx > > ) -> Obligation < ' tcx > {
306
+ pub fn misc ( span : Span , trait_ref : O ) -> Obligation < ' tcx , O > {
305
307
Obligation :: new ( ObligationCause :: misc ( span) , trait_ref)
306
308
}
309
+ }
307
310
311
+ impl < ' tcx > Obligation < ' tcx , Rc < ty:: TraitRef < ' tcx > > > {
308
312
pub fn self_ty ( & self ) -> Ty < ' tcx > {
309
313
self . trait_ref . self_ty ( )
310
314
}
@@ -406,7 +410,8 @@ impl<N> VtableBuiltinData<N> {
406
410
}
407
411
408
412
impl < ' tcx > FulfillmentError < ' tcx > {
409
- fn new ( obligation : Obligation < ' tcx > , code : FulfillmentErrorCode < ' tcx > )
413
+ fn new ( obligation : TraitObligation < ' tcx > ,
414
+ code : FulfillmentErrorCode < ' tcx > )
410
415
-> FulfillmentError < ' tcx >
411
416
{
412
417
FulfillmentError { obligation : obligation, code : code }
0 commit comments