@@ -155,10 +155,10 @@ enum BuiltinBoundConditions<'tcx> {
155
155
}
156
156
157
157
#[ deriving( Show ) ]
158
- enum EvaluationResult {
158
+ enum EvaluationResult < ' tcx > {
159
159
EvaluatedToOk ,
160
- EvaluatedToErr ,
161
160
EvaluatedToAmbig ,
161
+ EvaluatedToErr ( SelectionError < ' tcx > ) ,
162
162
}
163
163
164
164
impl < ' cx , ' tcx > SelectionContext < ' cx , ' tcx > {
@@ -272,7 +272,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
272
272
bound : ty:: BuiltinBound ,
273
273
previous_stack : & ObligationStack < ' o , ' tcx > ,
274
274
ty : Ty < ' tcx > )
275
- -> EvaluationResult
275
+ -> EvaluationResult < ' tcx >
276
276
{
277
277
let obligation =
278
278
util:: obligation_for_builtin_bound (
@@ -295,7 +295,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
295
295
fn evaluate_obligation_recursively < ' o > ( & mut self ,
296
296
previous_stack : Option < & ObligationStack < ' o , ' tcx > > ,
297
297
obligation : & Obligation < ' tcx > )
298
- -> EvaluationResult
298
+ -> EvaluationResult < ' tcx >
299
299
{
300
300
debug ! ( "evaluate_obligation_recursively({})" ,
301
301
obligation. repr( self . tcx( ) ) ) ;
@@ -310,7 +310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
310
310
311
311
fn evaluate_stack < ' o > ( & mut self ,
312
312
stack : & ObligationStack < ' o , ' tcx > )
313
- -> EvaluationResult
313
+ -> EvaluationResult < ' tcx >
314
314
{
315
315
// In intercrate mode, whenever any of the types are unbound,
316
316
// there can always be an impl. Even if there are no impls in
@@ -381,7 +381,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
381
381
match self . candidate_from_obligation ( stack) {
382
382
Ok ( Some ( c) ) => self . winnow_candidate ( stack, & c) ,
383
383
Ok ( None ) => EvaluatedToAmbig ,
384
- Err ( _ ) => EvaluatedToErr ,
384
+ Err ( e ) => EvaluatedToErr ( e ) ,
385
385
}
386
386
}
387
387
@@ -812,27 +812,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
812
812
fn winnow_candidate < ' o > ( & mut self ,
813
813
stack : & ObligationStack < ' o , ' tcx > ,
814
814
candidate : & Candidate < ' tcx > )
815
- -> EvaluationResult
815
+ -> EvaluationResult < ' tcx >
816
816
{
817
817
debug ! ( "winnow_candidate: candidate={}" , candidate. repr( self . tcx( ) ) ) ;
818
818
self . infcx . probe ( || {
819
819
let candidate = ( * candidate) . clone ( ) ;
820
820
match self . confirm_candidate ( stack. obligation , candidate) {
821
821
Ok ( selection) => self . winnow_selection ( Some ( stack) , selection) ,
822
- Err ( _ ) => EvaluatedToErr ,
822
+ Err ( error ) => EvaluatedToErr ( error ) ,
823
823
}
824
824
} )
825
825
}
826
826
827
827
fn winnow_selection < ' o > ( & mut self ,
828
828
stack : Option < & ObligationStack < ' o , ' tcx > > ,
829
829
selection : Selection < ' tcx > )
830
- -> EvaluationResult
830
+ -> EvaluationResult < ' tcx >
831
831
{
832
832
let mut result = EvaluatedToOk ;
833
833
for obligation in selection. iter_nested ( ) {
834
834
match self . evaluate_obligation_recursively ( stack, obligation) {
835
- EvaluatedToErr => { return EvaluatedToErr ; }
835
+ EvaluatedToErr ( e ) => { return EvaluatedToErr ( e ) ; }
836
836
EvaluatedToAmbig => { result = EvaluatedToAmbig ; }
837
837
EvaluatedToOk => { }
838
838
}
@@ -1847,11 +1847,18 @@ impl<'o, 'tcx> Repr<'tcx> for ObligationStack<'o, 'tcx> {
1847
1847
}
1848
1848
}
1849
1849
1850
- impl EvaluationResult {
1850
+ impl < ' tcx > EvaluationResult < ' tcx > {
1851
1851
fn may_apply ( & self ) -> bool {
1852
1852
match * self {
1853
- EvaluatedToOk | EvaluatedToAmbig => true ,
1854
- EvaluatedToErr => false ,
1853
+ EvaluatedToOk |
1854
+ EvaluatedToAmbig |
1855
+ EvaluatedToErr ( Overflow ) |
1856
+ EvaluatedToErr ( OutputTypeParameterMismatch ( ..) ) => {
1857
+ true
1858
+ }
1859
+ EvaluatedToErr ( Unimplemented ) => {
1860
+ false
1861
+ }
1855
1862
}
1856
1863
}
1857
1864
}
0 commit comments