@@ -26,7 +26,7 @@ use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyC
26
26
use rustc_session:: config:: EntryFnType ;
27
27
use rustc_session:: Limit ;
28
28
use rustc_span:: source_map:: { dummy_spanned, respan, Spanned } ;
29
- use rustc_span:: { Span , DUMMY_SP } ;
29
+ use rustc_span:: { ErrorGuaranteed , Span , DUMMY_SP } ;
30
30
use rustc_trait_selection:: traits;
31
31
use std:: ops:: Range ;
32
32
use std:: path:: PathBuf ;
@@ -37,7 +37,7 @@ fn custom_coerce_unsize_info<'tcx>(
37
37
param_env : ty:: ParamEnv < ' tcx > ,
38
38
source_ty : Ty < ' tcx > ,
39
39
target_ty : Ty < ' tcx > ,
40
- ) -> CustomCoerceUnsized {
40
+ ) -> Result < CustomCoerceUnsized , ErrorGuaranteed > {
41
41
let trait_ref = ty:: TraitRef :: from_lang_item (
42
42
tcx. tcx ,
43
43
LangItem :: CoerceUnsized ,
@@ -49,7 +49,7 @@ fn custom_coerce_unsize_info<'tcx>(
49
49
Ok ( traits:: ImplSource :: UserDefined ( traits:: ImplSourceUserDefinedData {
50
50
impl_def_id,
51
51
..
52
- } ) ) => tcx. coerce_unsized_info ( impl_def_id) . custom_kind . unwrap ( ) ,
52
+ } ) ) => Ok ( tcx. coerce_unsized_info ( impl_def_id) ? . custom_kind . unwrap ( ) ) ,
53
53
impl_source => {
54
54
bug ! ( "invalid `CoerceUnsized` impl_source: {:?}" , impl_source) ;
55
55
}
@@ -867,7 +867,13 @@ pub fn find_vtable_types_for_unsizing<'tcx>(
867
867
assert_eq ! ( source_adt_def, target_adt_def) ;
868
868
869
869
let CustomCoerceUnsized :: Struct ( coerce_index) =
870
- custom_coerce_unsize_info ( tcx, param_env, source_ty, target_ty) ;
870
+ match custom_coerce_unsize_info ( tcx, param_env, source_ty, target_ty) {
871
+ Ok ( ccu) => ccu,
872
+ Err ( e) => {
873
+ let e = Ty :: new_error ( tcx. tcx , e) ;
874
+ return ( e, e) ;
875
+ }
876
+ } ;
871
877
872
878
let source_fields = & source_adt_def. non_enum_variant ( ) . fields ;
873
879
let target_fields = & target_adt_def. non_enum_variant ( ) . fields ;
0 commit comments