@@ -257,16 +257,13 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
257
257
258
258
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
259
259
pub fn has_error_field ( self , ty : Ty < ' tcx > ) -> bool {
260
- match ty. sty {
261
- ty:: Adt ( def, substs) => {
262
- for field in def. all_fields ( ) {
263
- let field_ty = field. ty ( self , substs) ;
264
- if let Error = field_ty. sty {
265
- return true ;
266
- }
260
+ if let ty:: Adt ( def, substs) = ty. sty {
261
+ for field in def. all_fields ( ) {
262
+ let field_ty = field. ty ( self , substs) ;
263
+ if let Error = field_ty. sty {
264
+ return true ;
267
265
}
268
266
}
269
- _ => ( ) ,
270
267
}
271
268
false
272
269
}
@@ -421,7 +418,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
421
418
let ty = self . type_of ( adt_did) ;
422
419
self . for_each_relevant_impl ( drop_trait, ty, |impl_did| {
423
420
if let Some ( item) = self . associated_items ( impl_did) . next ( ) {
424
- if let Ok ( ( ) ) = validate ( self , impl_did) {
421
+ if validate ( self , impl_did) . is_ok ( ) {
425
422
dtor_did = Some ( item. def_id ) ;
426
423
}
427
424
}
@@ -906,20 +903,17 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
906
903
let ( param_env, ty) = query. into_parts ( ) ;
907
904
908
905
let needs_drop = |ty : Ty < ' tcx > | -> bool {
909
- match tcx. try_needs_drop_raw ( DUMMY_SP , param_env. and ( ty) ) {
910
- Ok ( v) => v,
911
- Err ( mut bug) => {
912
- // Cycles should be reported as an error by `check_representable`.
913
- //
914
- // Consider the type as not needing drop in the meanwhile to
915
- // avoid further errors.
916
- //
917
- // In case we forgot to emit a bug elsewhere, delay our
918
- // diagnostic to get emitted as a compiler bug.
919
- bug. delay_as_bug ( ) ;
920
- false
921
- }
922
- }
906
+ tcx. try_needs_drop_raw ( DUMMY_SP , param_env. and ( ty) ) . unwrap_or_else ( |mut bug| {
907
+ // Cycles should be reported as an error by `check_representable`.
908
+ //
909
+ // Consider the type as not needing drop in the meanwhile to
910
+ // avoid further errors.
911
+ //
912
+ // In case we forgot to emit a bug elsewhere, delay our
913
+ // diagnostic to get emitted as a compiler bug.
914
+ bug. delay_as_bug ( ) ;
915
+ false
916
+ } )
923
917
} ;
924
918
925
919
assert ! ( !ty. needs_infer( ) ) ;
0 commit comments