@@ -35,7 +35,6 @@ use crate::type_error_struct;
35
35
use hir:: def_id:: LOCAL_CRATE ;
36
36
use rustc_errors:: { struct_span_err, Applicability , DiagnosticBuilder , ErrorGuaranteed } ;
37
37
use rustc_hir as hir;
38
- use rustc_hir:: lang_items:: LangItem ;
39
38
use rustc_middle:: mir:: Mutability ;
40
39
use rustc_middle:: ty:: adjustment:: AllowTwoPhase ;
41
40
use rustc_middle:: ty:: cast:: { CastKind , CastTy } ;
@@ -47,7 +46,6 @@ use rustc_session::Session;
47
46
use rustc_span:: symbol:: sym;
48
47
use rustc_span:: Span ;
49
48
use rustc_trait_selection:: infer:: InferCtxtExt ;
50
- use rustc_trait_selection:: traits;
51
49
use rustc_trait_selection:: traits:: error_reporting:: report_object_safety_error;
52
50
53
51
/// Reifies a cast check to be checked once we have full type information for
@@ -97,7 +95,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
97
95
return Err ( reported) ;
98
96
}
99
97
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) {
101
99
return Ok ( Some ( PointerKind :: Thin ) ) ;
102
100
}
103
101
@@ -705,7 +703,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
705
703
706
704
debug ! ( "check_cast({}, {:?} as {:?})" , self . expr. hir_id, self . expr_ty, self . cast_ty) ;
707
705
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 )
709
707
&& !self . cast_ty . has_infer_types ( )
710
708
{
711
709
self . report_cast_to_unsized_type ( fcx) ;
@@ -1084,10 +1082,3 @@ impl<'a, 'tcx> CastCheck<'tcx> {
1084
1082
) ;
1085
1083
}
1086
1084
}
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