1
1
use rustc_middle:: bug;
2
- use rustc_middle:: ty:: layout:: { LayoutCx , LayoutError , LayoutOf , TyAndLayout , ValidityRequirement } ;
2
+ use rustc_middle:: ty:: layout:: {
3
+ HasTyCtxt , LayoutCx , LayoutError , LayoutOf , TyAndLayout , ValidityRequirement ,
4
+ } ;
3
5
use rustc_middle:: ty:: { ParamEnvAnd , Ty , TyCtxt } ;
4
6
use rustc_target:: abi:: { Abi , FieldsShape , Scalar , Variants } ;
5
7
@@ -30,7 +32,7 @@ pub fn check_validity_requirement<'tcx>(
30
32
return Ok ( !layout. abi . is_uninhabited ( ) ) ;
31
33
}
32
34
33
- let layout_cx = LayoutCx { tcx, param_env : param_env_and_ty. param_env } ;
35
+ let layout_cx = LayoutCx :: new ( tcx, param_env_and_ty. param_env ) ;
34
36
if kind == ValidityRequirement :: Uninit || tcx. sess . opts . unstable_opts . strict_init_checks {
35
37
check_validity_requirement_strict ( layout, & layout_cx, kind)
36
38
} else {
@@ -42,12 +44,12 @@ pub fn check_validity_requirement<'tcx>(
42
44
/// for details.
43
45
fn check_validity_requirement_strict < ' tcx > (
44
46
ty : TyAndLayout < ' tcx > ,
45
- cx : & LayoutCx < ' tcx , TyCtxt < ' tcx > > ,
47
+ cx : & LayoutCx < ' tcx > ,
46
48
kind : ValidityRequirement ,
47
49
) -> Result < bool , & ' tcx LayoutError < ' tcx > > {
48
50
let machine = CompileTimeMachine :: new ( CanAccessMutGlobal :: No , CheckAlignment :: Error ) ;
49
51
50
- let mut cx = InterpCx :: new ( cx. tcx , rustc_span:: DUMMY_SP , cx. param_env , machine) ;
52
+ let mut cx = InterpCx :: new ( cx. tcx ( ) , rustc_span:: DUMMY_SP , cx. param_env , machine) ;
51
53
52
54
let allocated = cx
53
55
. allocate ( ty, MemoryKind :: Machine ( crate :: const_eval:: MemoryKind :: Heap ) )
@@ -80,7 +82,7 @@ fn check_validity_requirement_strict<'tcx>(
80
82
/// function for details.
81
83
fn check_validity_requirement_lax < ' tcx > (
82
84
this : TyAndLayout < ' tcx > ,
83
- cx : & LayoutCx < ' tcx , TyCtxt < ' tcx > > ,
85
+ cx : & LayoutCx < ' tcx > ,
84
86
init_kind : ValidityRequirement ,
85
87
) -> Result < bool , & ' tcx LayoutError < ' tcx > > {
86
88
let scalar_allows_raw_init = move |s : Scalar | -> bool {
0 commit comments