@@ -35,7 +35,6 @@ use crate::type_error_struct;
3535use hir:: def_id:: LOCAL_CRATE ;
3636use rustc_errors:: { struct_span_err, Applicability , DiagnosticBuilder , ErrorGuaranteed } ;
3737use rustc_hir as hir;
38- use rustc_hir:: lang_items:: LangItem ;
3938use rustc_middle:: mir:: Mutability ;
4039use rustc_middle:: ty:: adjustment:: AllowTwoPhase ;
4140use rustc_middle:: ty:: cast:: { CastKind , CastTy } ;
@@ -47,7 +46,6 @@ use rustc_session::Session;
4746use rustc_span:: symbol:: sym;
4847use rustc_span:: Span ;
4948use rustc_trait_selection:: infer:: InferCtxtExt ;
50- use rustc_trait_selection:: traits;
5149use rustc_trait_selection:: traits:: error_reporting:: report_object_safety_error;
5250
5351/// Reifies a cast check to be checked once we have full type information for
@@ -97,7 +95,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9795 return Err ( reported) ;
9896 }
9997
100- if self . type_is_known_to_be_sized_modulo_regions ( t, span) {
98+ if self . type_is_sized_modulo_regions ( self . param_env , t, span) {
10199 return Ok ( Some ( PointerKind :: Thin ) ) ;
102100 }
103101
@@ -705,7 +703,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
705703
706704 debug ! ( "check_cast({}, {:?} as {:?})" , self . expr. hir_id, self . expr_ty, self . cast_ty) ;
707705
708- if !fcx. type_is_known_to_be_sized_modulo_regions ( self . cast_ty , self . span )
706+ if !fcx. type_is_sized_modulo_regions ( fcx . param_env , self . cast_ty , self . span )
709707 && !self . cast_ty . has_infer_types ( )
710708 {
711709 self . report_cast_to_unsized_type ( fcx) ;
@@ -1084,10 +1082,3 @@ impl<'a, 'tcx> CastCheck<'tcx> {
10841082 ) ;
10851083 }
10861084}
1087-
1088- impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
1089- fn type_is_known_to_be_sized_modulo_regions ( & self , ty : Ty < ' tcx > , span : Span ) -> bool {
1090- let lang_item = self . tcx . require_lang_item ( LangItem :: Sized , None ) ;
1091- traits:: type_known_to_meet_bound_modulo_regions ( self , self . param_env , ty, lang_item, span)
1092- }
1093- }
0 commit comments