diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-05-08 01:17:58 -0400 |
|---|---|---|
| committer | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-05-10 22:47:18 -0400 |
| commit | 319575ae8c3f6ea5db1c850c8f4c786c8cc203fe (patch) | |
| tree | 3ae4430bed06270beb9e8eae4dfde2a8be7e90f3 /compiler/rustc_const_eval | |
| parent | ecd44958e0a21110d09862ee080d95a4ca6c52f8 (diff) | |
| download | rust-319575ae8c3f6ea5db1c850c8f4c786c8cc203fe.tar.gz rust-319575ae8c3f6ea5db1c850c8f4c786c8cc203fe.zip | |
Introduce EarlyBinder
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 38fecf7232e..5c56e6ee5f5 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -13,7 +13,7 @@ use rustc_middle::mir::pretty::display_allocation; use rustc_middle::traits::Reveal; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{self, subst::Subst, TyCtxt}; +use rustc_middle::ty::{self, subst::Subst, EarlyBinder, TyCtxt}; use rustc_span::source_map::Span; use rustc_target::abi::{self, Abi}; use std::borrow::Cow; @@ -47,7 +47,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( "Unexpected DefKind: {:?}", ecx.tcx.def_kind(cid.instance.def_id()) ); - let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?; + let layout = ecx.layout_of(EarlyBinder(body.return_ty()).subst(tcx, cid.instance.substs))?; assert!(!layout.is_unsized()); let ret = ecx.allocate(layout, MemoryKind::Stack)?; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs index 058903dcdee..43133b03ad1 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs @@ -5,6 +5,7 @@ use rustc_hir::lang_items::LangItem; use rustc_middle::mir::TerminatorKind; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::subst::Subst; +use rustc_middle::ty::EarlyBinder; use rustc_span::{Span, Symbol}; use crate::interpret::{ @@ -93,10 +94,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) }; // Allocate memory for `CallerLocation` struct. - let loc_ty = self - .tcx - .type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None)) - .subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter())); + let loc_ty = EarlyBinder( + self.tcx.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None)), + ) + .subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter())); let loc_layout = self.layout_of(loc_ty).unwrap(); // This can fail if rustc runs out of memory right here. Trying to emit an error would be // pointless, since that would require allocating more memory than a Location. |
