@@ -51,13 +51,8 @@ fn lookup_vtables(fcx: @fn_ctxt,
51
51
match * bound {
52
52
ty:: bound_trait( i_ty) => {
53
53
let i_ty = ty:: subst ( tcx, substs, i_ty) ;
54
- match lookup_vtable ( fcx, expr, * ty, i_ty, allow_unsafe,
55
- is_early) {
56
- None => { }
57
- Some ( vtable) => {
58
- result. push ( vtable) ;
59
- }
60
- }
54
+ result. push ( lookup_vtable ( fcx, expr, * ty, i_ty,
55
+ allow_unsafe, is_early) ) ;
61
56
}
62
57
_ => ( )
63
58
}
@@ -96,7 +91,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
96
91
trait_ty : ty:: t ,
97
92
allow_unsafe : bool ,
98
93
is_early : bool )
99
- -> Option < vtable_origin >
94
+ -> vtable_origin
100
95
{
101
96
102
97
debug ! ( "lookup_vtable(ty=%s, trait_ty=%s)" ,
@@ -118,7 +113,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
118
113
// The type has unconstrained type variables in it, so we can't
119
114
// do early resolution on it. Return some completely bogus vtable
120
115
// information: we aren't storing it anyways.
121
- return Some ( vtable_param ( 0 , 0 ) ) ;
116
+ return vtable_param ( 0 , 0 ) ;
122
117
}
123
118
} ;
124
119
@@ -140,7 +135,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
140
135
idid) ;
141
136
relate_trait_tys ( fcx, expr,
142
137
trait_ty, ity) ;
143
- return Some ( vtable_param ( n, n_bound) ) ;
138
+ return vtable_param ( n, n_bound) ;
144
139
}
145
140
}
146
141
_ => tcx. sess . impossible_case (
@@ -175,7 +170,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
175
170
}
176
171
}
177
172
}
178
- return Some ( vtable_trait ( did, substs. tps ) ) ;
173
+ return vtable_trait ( did, substs. tps ) ;
179
174
}
180
175
181
176
_ => {
@@ -308,7 +303,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
308
303
None => {
309
304
assert is_early;
310
305
// Bail out with a bogus answer
311
- return Some ( vtable_param ( 0 , 0 ) ) ;
306
+ return vtable_param ( 0 , 0 ) ;
312
307
}
313
308
} ;
314
309
@@ -346,20 +341,23 @@ fn lookup_vtable(fcx: @fn_ctxt,
346
341
347
342
match found. len ( ) {
348
343
0 => { /* fallthrough */ }
349
- 1 => { return Some ( found[ 0 ] ) ; }
344
+ 1 => { return found[ 0 ] ; }
350
345
_ => {
351
346
if !is_early {
352
347
fcx. ccx . tcx . sess . span_err (
353
348
expr. span ,
354
349
~"multiple applicable methods in scope") ;
355
350
}
356
- return Some ( found[ 0 ] ) ;
351
+ return found[ 0 ] ;
357
352
}
358
353
}
359
354
}
360
355
}
361
356
362
- return None ;
357
+ tcx. sess . span_fatal (
358
+ expr. span ,
359
+ fmt ! ( "failed to find an implementation of trait %s for %s" ,
360
+ ty_to_str( tcx, trait_ty) , ty_to_str( tcx, ty) ) ) ;
363
361
}
364
362
365
363
fn fixup_ty ( fcx : @fn_ctxt ,
@@ -461,26 +459,13 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
461
459
Look up vtables for the type we're casting to,
462
460
passing in the source and target type
463
461
*/
464
- let ty = fcx. expr_ty ( src) ;
465
- let vtable_opt = lookup_vtable ( fcx, ex, ty, target_ty, true ,
466
- is_early) ;
467
- match vtable_opt {
468
- None => {
469
- fcx. tcx ( ) . sess . span_err (
470
- ex. span ,
471
- fmt ! ( "failed to find an implementation of trait %s \
472
- for %s",
473
- ty_to_str( fcx. tcx( ) , target_ty) ,
474
- ty_to_str( fcx. tcx( ) , ty) ) ) ;
475
- }
476
- Some ( vtable) => {
477
- /*
478
- Map this expression to that vtable (that is: "ex has
479
- vtable <vtable>")
480
- */
481
- if !is_early { cx. vtable_map . insert ( ex. id , @~[ vtable] ) ; }
482
- }
483
- }
462
+ let vtable = lookup_vtable ( fcx, ex, fcx. expr_ty ( src) ,
463
+ target_ty, true , is_early) ;
464
+ /*
465
+ Map this expression to that vtable (that is: "ex has
466
+ vtable <vtable>")
467
+ */
468
+ if !is_early { cx. vtable_map . insert ( ex. id , @~[ vtable] ) ; }
484
469
}
485
470
_ => ( )
486
471
}
0 commit comments