diff --git a/cilly/src/v2/asm.rs b/cilly/src/v2/asm.rs index 7058e83..71ecd3d 100644 --- a/cilly/src/v2/asm.rs +++ b/cilly/src/v2/asm.rs @@ -431,13 +431,12 @@ impl Assembly { let def_class = def.class(); let ref_idx = self.alloc_methodref(mref); // Check that this def is unique - if !self.method_defs.contains_key(&MethodDefIdx(ref_idx)){ + if !self.method_defs.contains_key(&MethodDefIdx(ref_idx)) { self.class_defs - .get_mut(&def_class) - .expect("Method added without a class") - .add_def(MethodDefIdx(ref_idx)); + .get_mut(&def_class) + .expect("Method added without a class") + .add_def(MethodDefIdx(ref_idx)); } - self.method_defs.insert(MethodDefIdx(ref_idx), def); diff --git a/cilly/src/v2/c_exporter/mod.rs b/cilly/src/v2/c_exporter/mod.rs index dd9d5ed..0e57a8c 100644 --- a/cilly/src/v2/c_exporter/mod.rs +++ b/cilly/src/v2/c_exporter/mod.rs @@ -35,7 +35,6 @@ fn local_name(locals: &[LocalDef], asm: &Assembly, loc: u32) -> String { .count() > 1 { - return format!("L{loc}"); } match locals[loc as usize].0 { @@ -981,14 +980,13 @@ impl CExporter { let locals: Vec<_> = def.iter_locals(asm).copied().collect(); for (idx, (lname, local_type)) in locals.iter().enumerate() { // If the name of this local is found multiple times, use the L form. - + writeln!( method_defs, "{local_type} {lname};", lname = local_name(&locals, asm, idx as u32), local_type = nonvoid_c_type(asm[*local_type], asm), )?; - } let blocks = def.blocks(asm).unwrap().to_vec(); for block in blocks { diff --git a/cilly/src/v2/class.rs b/cilly/src/v2/class.rs index 808ad92..5ee6acd 100644 --- a/cilly/src/v2/class.rs +++ b/cilly/src/v2/class.rs @@ -499,7 +499,7 @@ impl ClassDef { assert_eq!(self.generics, 0); ClassRef::new(self.name, None, self.is_valuetype, vec![].into()) } - pub fn add_def(&mut self,val:MethodDefIdx){ + pub fn add_def(&mut self, val: MethodDefIdx) { self.methods.push(val); assert_unique(self.methods(), "add_def failed: method were not unique!"); } @@ -583,8 +583,6 @@ impl ClassDef { assert_eq!(self.access(), translated.access()); } - - pub fn align(&self) -> Option { self.align } diff --git a/cilly/src/v2/il_exporter/mod.rs b/cilly/src/v2/il_exporter/mod.rs index 565cbd0..fd1196c 100644 --- a/cilly/src/v2/il_exporter/mod.rs +++ b/cilly/src/v2/il_exporter/mod.rs @@ -3,7 +3,13 @@ use crate::v2::MethodImpl; use std::{io::Write, path::Path}; use super::{ - asm::{IlasmFlavour, ILASM_FLAVOUR, ILASM_PATH}, cilnode::{ExtendKind, UnOp}, cilroot::BranchCond, method::LocalDef, tpe::simd::SIMDElem, Assembly, BinOp, CILIter, CILIterElem, CILNode, ClassRefIdx, Exporter, Int, MethodDefIdx, NodeIdx, RootIdx, SigIdx, Type + asm::{IlasmFlavour, ILASM_FLAVOUR, ILASM_PATH}, + cilnode::{ExtendKind, UnOp}, + cilroot::BranchCond, + method::LocalDef, + tpe::simd::SIMDElem, + Assembly, BinOp, CILIter, CILIterElem, CILNode, ClassRefIdx, Exporter, Int, MethodDefIdx, + NodeIdx, RootIdx, SigIdx, Type, }; pub struct ILExporter { @@ -82,7 +88,8 @@ impl ILExporter { }; } // Debug check - let mut ensure_unqiue:std::collections::HashSet = std::collections::HashSet::new(); + let mut ensure_unqiue: std::collections::HashSet = + std::collections::HashSet::new(); // Export all methods for method_id in class_def.methods() { diff --git a/src/aggregate.rs b/src/aggregate.rs index db67fd5..84a7450 100644 --- a/src/aggregate.rs +++ b/src/aggregate.rs @@ -37,7 +37,7 @@ pub fn handle_aggregate<'tcx>( .collect(); match aggregate_kind { AggregateKind::Adt(adt_def, variant_idx, subst, _utai, active_field) => { - let penv = ParamEnv::reveal_all(); + let penv = rustc_middle::ty::TypingEnv::fully_monomorphized(); let subst = ctx.monomorphize(*subst); //eprintln!("Preparing to resolve {adt_def:?} {subst:?}"); let adt_type = Instance::try_resolve(ctx.tcx(), penv, *adt_def, subst); diff --git a/src/assembly.rs b/src/assembly.rs index 5509001..ee0b738 100644 --- a/src/assembly.rs +++ b/src/assembly.rs @@ -339,7 +339,13 @@ pub fn add_fn<'tcx, 'asm, 'a: 'asm>( name: &str, ctx: &'a mut MethodCompileCtx<'tcx, 'asm>, ) -> Result<(), MethodCodegenError> { - let kind = ctx.instance().ty(ctx.tcx(), ParamEnv::reveal_all()).kind(); + let kind = ctx + .instance() + .ty( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ) + .kind(); if let TyKind::FnDef(_, _) = kind { //ALL OK. } else if let TyKind::Closure(_, _) = kind { diff --git a/src/binop/mod.rs b/src/binop/mod.rs index 4684369..ec6a751 100644 --- a/src/binop/mod.rs +++ b/src/binop/mod.rs @@ -141,11 +141,18 @@ pub(crate) fn binop<'tcx>( .get_lang_items(()) .get(LangItem::OrderingEnum) .unwrap(); - let ordering = - Instance::try_resolve(ctx.tcx(), ParamEnv::reveal_all(), ordering, List::empty()) - .unwrap() - .unwrap(); - let ordering_ty = ordering.ty(ctx.tcx(), ParamEnv::reveal_all()); + let ordering = Instance::try_resolve( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ordering, + List::empty(), + ) + .unwrap() + .unwrap(); + let ordering_ty = ordering.ty( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ); let ordering_type = ctx.type_from_cache(ordering_ty); let lt = -conv_i8!(lt_unchecked(ty_a, ops_a.clone(), ops_b.clone(), ctx)); let gt = conv_i8!(gt_unchecked(ty_a, ops_a, ops_b, ctx)); diff --git a/src/call_info.rs b/src/call_info.rs index bfb04ac..f3bf1e5 100644 --- a/src/call_info.rs +++ b/src/call_info.rs @@ -1,5 +1,5 @@ use cilly::v2::FnSig; -use rustc_middle::ty::{Instance, List, ParamEnv, ParamEnvAnd, TyKind}; +use rustc_middle::ty::{Instance, List, ParamEnv, PseudoCanonicalInput, TyKind}; use rustc_target::abi::call::Conv; use rustc_target::spec::abi::Abi as TargetAbi; @@ -15,8 +15,8 @@ impl CallInfo { function: Instance<'tcx>, ctx: &mut MethodCompileCtx<'tcx, '_>, ) -> Self { - let fn_abi = ctx.tcx().fn_abi_of_instance(ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + let fn_abi = ctx.tcx().fn_abi_of_instance(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: (function, List::empty()), }); let fn_abi = match fn_abi { @@ -39,7 +39,10 @@ impl CallInfo { args.push(get_type(arg.layout.ty, ctx)); } // There are 2 ABI enums for some reasons(they differ in what memebers they have) - let fn_ty = function.ty(ctx.tcx(), ParamEnv::reveal_all()); + let fn_ty = function.ty( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ); let internal_abi = match fn_ty.kind() { TyKind::FnDef(_, _) => fn_ty.fn_sig(ctx.tcx()).abi(), TyKind::Closure(_, args) => args.as_closure().sig().abi(), diff --git a/src/comptime.rs b/src/comptime.rs index 939b40e..d32dff4 100644 --- a/src/comptime.rs +++ b/src/comptime.rs @@ -77,7 +77,7 @@ pub fn interpret<'tcx>( func_ty.kind() { let subst_ref = ctx.monomorphize(*subst_ref); - let env = ParamEnv::reveal_all(); + let env = rustc_middle::ty::TypingEnv::fully_monomorphized(); let Some(call_instance) = Instance::try_resolve(ctx.tcx(), env, *def_id, subst_ref) .expect("Invalid function def") @@ -183,7 +183,7 @@ pub fn interpret<'tcx>( { let subst_ref = crate::utilis::monomorphize(&instance, *subst_ref, ctx.tcx()); - let env = ParamEnv::reveal_all(); + let env = rustc_middle::ty::TypingEnv::fully_monomorphized(); let Some(instance) = Instance::try_resolve(ctx.tcx(), env, *def_id, subst_ref) .expect("Invalid function def") diff --git a/src/constant.rs b/src/constant.rs index 44c0e49..2021e67 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -27,7 +27,11 @@ pub fn handle_constant<'tcx>( let constant = constant_op.const_; let constant = ctx.monomorphize(constant); let evaluated = constant - .eval(ctx.tcx(), ParamEnv::reveal_all(), constant_op.span) + .eval( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + constant_op.span, + ) .expect("Could not evaluate constant!"); load_const_value(evaluated, constant.ty(), ctx) } diff --git a/src/fn_ctx.rs b/src/fn_ctx.rs index bf42cf0..f2ded17 100644 --- a/src/fn_ctx.rs +++ b/src/fn_ctx.rs @@ -1,8 +1,8 @@ +use crate::r#type::get_type; use cilly::v2::Assembly; use cilly::Type; -use rustc_middle::ty::{Instance, ParamEnv, TyCtxt}; - -use crate::r#type::get_type; +use rustc_middle::ty::layout::HasTypingEnv; +use rustc_middle::ty::{Instance, PseudoCanonicalInput, TyCtxt}; pub struct MethodCompileCtx<'tcx, 'asm> { tcx: TyCtxt<'tcx>, method: Option<&'tcx rustc_middle::mir::Body<'tcx>>, @@ -78,7 +78,7 @@ impl<'tcx, 'asm> MethodCompileCtx<'tcx, 'asm> { self.instance() .instantiate_mir_and_normalize_erasing_regions( self.tcx(), - ParamEnv::reveal_all(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), rustc_middle::ty::EarlyBinder::bind(ty), ) } @@ -93,8 +93,8 @@ impl<'tcx, 'asm> MethodCompileCtx<'tcx, 'asm> { ) -> rustc_middle::ty::layout::TyAndLayout<'tcx> { let ty = self.monomorphize(ty); self.tcx - .layout_of(rustc_middle::ty::ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + .layout_of(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: ty, }) .expect("Could not get type layout!") @@ -118,8 +118,8 @@ impl rustc_abi::HasDataLayout for MethodCompileCtx<'_, '_> { self.tcx.data_layout() } } -impl<'tcx> rustc_middle::ty::layout::HasParamEnv<'tcx> for MethodCompileCtx<'tcx, '_> { - fn param_env(&self) -> ParamEnv<'tcx> { - ParamEnv::reveal_all() +impl<'tcx> HasTypingEnv<'tcx> for MethodCompileCtx<'tcx, '_> { + fn typing_env(&self) -> rustc_middle::ty::TypingEnv<'tcx> { + rustc_middle::ty::TypingEnv::fully_monomorphized() } } diff --git a/src/function_sig.rs b/src/function_sig.rs index cd76cb7..39e1573 100644 --- a/src/function_sig.rs +++ b/src/function_sig.rs @@ -2,7 +2,7 @@ use crate::codegen_error::CodegenError; use crate::fn_ctx::MethodCompileCtx; use crate::r#type::get_type; use cilly::{v2::FnSig, Type}; -use rustc_middle::ty::{Instance, List, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TyKind}; +use rustc_middle::ty::{Instance, List, ParamEnv, PseudoCanonicalInput, Ty, TyCtxt, TyKind}; use rustc_target::abi::call::Conv; use rustc_target::spec::abi::Abi as TargetAbi; @@ -25,10 +25,12 @@ pub fn sig_from_instance_<'tcx>( function: Instance<'tcx>, ctx: &mut MethodCompileCtx<'tcx, '_>, ) -> Result { - let fn_abi = ctx.tcx().fn_abi_of_instance(ParamEnvAnd { - param_env: ParamEnv::reveal_all(), - value: (function, List::empty()), - }); + let fn_abi = ctx + .tcx() + .fn_abi_of_instance(rustc_middle::ty::PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), + value: (function, List::empty()), + }); let fn_abi = match fn_abi { Ok(abi) => abi, Err(_error) => todo!(), @@ -47,7 +49,10 @@ pub fn sig_from_instance_<'tcx>( args.push(get_type(arg, ctx)); } // There are 2 ABI enums for some reasons(they differ in what memebers they have) - let fn_ty = function.ty(ctx.tcx(), ParamEnv::reveal_all()); + let fn_ty = function.ty( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ); let internal_abi = match fn_ty.kind() { TyKind::FnDef(_, _) => fn_ty.fn_sig(ctx.tcx()), TyKind::Closure(_, args) => args.as_closure().sig(), diff --git a/src/lib.rs b/src/lib.rs index 3256ba9..c6e41b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,6 +181,7 @@ use rustc_session::{ config::{OutputFilenames, OutputType}, Session, }; + use rustc_span::ErrorGuaranteed; use std::{any::Any, path::Path}; @@ -216,7 +217,7 @@ impl CodegenBackend for MyBackend { } if let Some((entrypoint, _kind)) = tcx.entry_fn(()) { - let penv = rustc_middle::ty::ParamEnv::reveal_all(); + let penv = rustc_middle::ty::TypingEnv::fully_monomorphized(); let entrypoint = rustc_middle::ty::Instance::try_resolve( tcx, penv, diff --git a/src/operand.rs b/src/operand.rs index 67e5bcc..d26a3fb 100644 --- a/src/operand.rs +++ b/src/operand.rs @@ -48,7 +48,11 @@ pub(crate) fn is_uninit<'tcx>( let constant = const_val.const_; let constant = ctx.monomorphize(constant); let evaluated = constant - .eval(ctx.tcx(), ParamEnv::reveal_all(), const_val.span) + .eval( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + const_val.span, + ) .expect("Could not evaluate constant!"); match evaluated { ConstValue::Scalar(_) => false, // Scalars are never uninitialized. diff --git a/src/rvalue.rs b/src/rvalue.rs index e910839..a21a448 100644 --- a/src/rvalue.rs +++ b/src/rvalue.rs @@ -104,7 +104,11 @@ pub fn handle_rvalue<'tcx>( let layout = ctx.layout_of(*ty); let offset = ctx .tcx() - .offset_of_subfield(ParamEnv::reveal_all(), layout, fields.iter()) + .offset_of_subfield( + rustc_middle::ty::TypingEnv::fully_monomorphized(), + layout, + fields.iter(), + ) .bytes(); (vec![], CILNode::V2(ctx.alloc_node(Const::USize(offset)))) } @@ -266,7 +270,7 @@ pub fn handle_rvalue<'tcx>( let (instance, _subst_ref) = if let TyKind::FnDef(def_id, subst_ref) = operand_ty.kind() { let subst = ctx.monomorphize(*subst_ref); - let env = ParamEnv::reveal_all(); + let env = rustc_middle::ty::TypingEnv::fully_monomorphized(); let Some(instance) = Instance::try_resolve(ctx.tcx(), env, *def_id, subst) .expect("Invalid function def") else { diff --git a/src/statement.rs b/src/statement.rs index 0c12d50..6c486f7 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -87,6 +87,7 @@ pub fn handle_statement<'tcx>( StatementKind::FakeRead(_) => { panic!("Fake reads should not be passed from the backend to the forntend!") } + rustc_middle::mir::StatementKind::BackwardIncompatibleDropHint { .. } => todo!(), StatementKind::PlaceMention(place) => vec![CILRoot::Pop { tree: place_get(place, ctx), } diff --git a/src/terminator/call.rs b/src/terminator/call.rs index 90ccc7b..5294690 100644 --- a/src/terminator/call.rs +++ b/src/terminator/call.rs @@ -335,7 +335,7 @@ pub fn call<'tcx>( let fn_type = ctx.monomorphize(fn_type); let (instance, subst_ref) = if let TyKind::FnDef(def_id, subst_ref) = fn_type.kind() { let subst = ctx.monomorphize(*subst_ref); - let env = ParamEnv::reveal_all(); + let env = rustc_middle::ty::TypingEnv::fully_monomorphized(); let Some(instance) = Instance::try_resolve(ctx.tcx(), env, *def_id, subst).expect("Invalid function def") else { diff --git a/src/terminator/intrinsics/mod.rs b/src/terminator/intrinsics/mod.rs index afb4871..ddd3293 100644 --- a/src/terminator/intrinsics/mod.rs +++ b/src/terminator/intrinsics/mod.rs @@ -79,6 +79,7 @@ pub fn handle_intrinsic<'tcx>( match fn_name { "arith_offset" => arith_offset(args, destination, call_instance, ctx), "breakpoint" => breakpoint(args), + "cold_path" | "assert_inhabited" | "assert_zero_valid" | "const_deallocate"=>CILRoot::Nop, "black_box" => black_box(args, destination, call_instance, ctx), "caller_location" => caller_location(destination, ctx, span), "compare_bytes" => place_set( @@ -115,7 +116,10 @@ pub fn handle_intrinsic<'tcx>( .as_type() .expect("needs_drop works only on types!"), ); - let needs_drop = tpe.needs_drop(ctx.tcx(), ParamEnv::reveal_all()); + let needs_drop = tpe.needs_drop( + ctx.tcx(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ); let needs_drop = i32::from(needs_drop); place_set(destination, CILNode::V2(ctx.alloc_node(needs_drop)), ctx) } @@ -535,7 +539,11 @@ pub fn handle_intrinsic<'tcx>( "type_name" => { let const_val = ctx .tcx() - .const_eval_instance(ParamEnv::reveal_all(), call_instance, span) + .const_eval_instance( + rustc_middle::ty::TypingEnv::fully_monomorphized(), + call_instance, + span, + ) .unwrap(); place_set( destination, @@ -1042,7 +1050,11 @@ pub fn handle_intrinsic<'tcx>( "variant_count" => { let const_val = ctx .tcx() - .const_eval_instance(ParamEnv::reveal_all(), call_instance, span) + .const_eval_instance( + rustc_middle::ty::TypingEnv::fully_monomorphized(), + call_instance, + span, + ) .unwrap(); place_set( destination, diff --git a/src/type/mod.rs b/src/type/mod.rs index 97ec736..febd7ed 100644 --- a/src/type/mod.rs +++ b/src/type/mod.rs @@ -98,9 +98,10 @@ pub fn get_type<'tcx>(ty: Ty<'tcx>, ctx: &mut MethodCompileCtx<'tcx, '_>) -> Typ // Extract the sig let mut sig = closure.sig(); sig = ctx.monomorphize(sig); - let sig = ctx - .tcx() - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), sig); + let sig = ctx.tcx().normalize_erasing_late_bound_regions( + rustc_middle::ty::TypingEnv::fully_monomorphized(), + sig, + ); let inputs: Box<_> = sig.inputs().iter().map(|ty| get_type(*ty, ctx)).collect(); let output = get_type(sig.output(), ctx); let sig = ctx.sig(inputs, output); @@ -146,9 +147,10 @@ pub fn get_type<'tcx>(ty: Ty<'tcx>, ctx: &mut MethodCompileCtx<'tcx, '_>) -> Typ TyKind::Foreign(_foregin) => Type::Void, TyKind::FnDef(_did, _subst) => Type::Void, TyKind::FnPtr(sig, _) => { - let sig = ctx - .tcx() - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), *sig); + let sig = ctx.tcx().normalize_erasing_late_bound_regions( + rustc_middle::ty::TypingEnv::fully_monomorphized(), + *sig, + ); //let sig = crate::function_sig::from_poly_sig(method, tcx, self, sig); let output = get_type(ctx.monomorphize(sig.output()), ctx); let inputs: Box<[Type]> = sig diff --git a/src/type/type.rs b/src/type/type.rs index 5e540dc..749dd8e 100644 --- a/src/type/type.rs +++ b/src/type/type.rs @@ -10,6 +10,7 @@ use cilly::{ Type, }; use rustc_middle::ty::{AdtDef, ConstKind, GenericArg, ParamEnv, Ty, TyCtxt, TyKind}; +use rustc_middle::ty::PseudoCanonicalInput; /// This struct represetnts either a primitive .NET type (F32,F64), or stores information on how to lookup a more complex type (struct,class,array) use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, PartialEq, Clone, Eq, Hash, Debug)] @@ -168,8 +169,8 @@ pub fn is_fat_ptr<'tcx>( use rustc_target::abi::BackendRepr; let ptr_type = monomorphize(&method, ptr_type, tcx); let layout = tcx - .layout_of(rustc_middle::ty::ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + .layout_of(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: ptr_type, }) .expect("Can't get layout of a type.") diff --git a/src/unsize.rs b/src/unsize.rs index ca1efa5..1d69468 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -125,9 +125,11 @@ fn unsized_info<'tcx>( target: Ty<'tcx>, old_info: Option, ) -> CILNode { - let (source, target) = - ctx.tcx() - .struct_lockstep_tails_for_codegen(source, target, ParamEnv::reveal_all()); + let (source, target) = ctx.tcx().struct_lockstep_tails_for_codegen( + source, + target, + rustc_middle::ty::TypingEnv::fully_monomorphized(), + ); match (&source.kind(), &target.kind()) { (&TyKind::Array(_, len), &TyKind::Slice(_)) => { let len = len diff --git a/src/utilis/mod.rs b/src/utilis/mod.rs index b0ad101..39980bd 100644 --- a/src/utilis/mod.rs +++ b/src/utilis/mod.rs @@ -6,8 +6,8 @@ use cilly::{ use rustc_middle::{ mir::interpret::AllocId, ty::{ - AdtDef, Const, ConstKind, EarlyBinder, GenericArg, Instance, List, ParamEnv, SymbolName, - Ty, TyCtxt, TyKind, TypeFoldable, + AdtDef, Const, ConstKind, EarlyBinder, GenericArg, Instance, List, ParamEnv, + PseudoCanonicalInput, SymbolName, Ty, TyCtxt, TyKind, TypeFoldable, }, }; pub mod adt; @@ -43,9 +43,14 @@ pub fn adt_name<'tcx>( rustc_middle::ty::print::with_no_trimmed_paths! {tcx.def_path_str(adt.did())} }; let krate = adt.did().krate; - let adt_instance = Instance::try_resolve(tcx, ParamEnv::reveal_all(), adt.did(), gargs) - .unwrap() - .unwrap(); + let adt_instance = Instance::try_resolve( + tcx, + rustc_middle::ty::TypingEnv::fully_monomorphized(), + adt.did(), + gargs, + ) + .unwrap() + .unwrap(); // Get the mangled path: it is absolute, and not poluted by types being rexported let auto_mangled = rustc_symbol_mangling::symbol_name_for_instance_in_crate(tcx, adt_instance, krate); @@ -112,7 +117,7 @@ pub fn monomorphize<'tcx, T: TypeFoldable> + Clone>( ) -> T { instance.instantiate_mir_and_normalize_erasing_regions( ctx, - ParamEnv::reveal_all(), + rustc_middle::ty::TypingEnv::fully_monomorphized(), EarlyBinder::bind(ty), ) } @@ -279,8 +284,8 @@ pub fn garag_to_bool<'tcx>(garg: GenericArg<'tcx>, _ctx: TyCtxt<'tcx>) -> bool { /// This function returns the size of a type at the compile time. This should be used ONLY for handling constants. It currently assumes a 64 bit env pub fn compiletime_sizeof<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u64 { let layout = tcx - .layout_of(rustc_middle::ty::ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + .layout_of(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: ty, }) .expect("Can't get layout of a type.") @@ -317,8 +322,8 @@ pub fn is_fn_intrinsic<'tcx>(fn_ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool { } pub fn align_of<'tcx>(ty: rustc_middle::ty::Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u64 { let layout = tcx - .layout_of(rustc_middle::ty::ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + .layout_of(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: ty, }) .expect("Can't get layout of a type.") @@ -329,8 +334,8 @@ pub fn align_of<'tcx>(ty: rustc_middle::ty::Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u64 } pub fn is_zst<'tcx>(ty: rustc_middle::ty::Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool { let layout = tcx - .layout_of(rustc_middle::ty::ParamEnvAnd { - param_env: ParamEnv::reveal_all(), + .layout_of(PseudoCanonicalInput { + typing_env: rustc_middle::ty::TypingEnv::fully_monomorphized(), value: ty, }) .expect("Can't get layout of a type.")