Skip to content

Commit 593bfc6

Browse files
committed
Auto merge of #134550 - jhpratt:rollup-wsfmo59, r=jhpratt
Rollup of 6 pull requests Successful merges: - #126118 (docs: Mention `spare_capacity_mut()` in `Vec::set_len`) - #132830 (Rename `elem_offset` to `element_offset`) - #133103 (Pass FnAbi to find_mir_or_eval_fn) - #134321 (Hide `= _` as associated constant value inside impl blocks) - #134518 (fix typos in the example code in the doc comments of `Ipv4Addr::from_bits()`, `Ipv6Addr::from_bits()` & `Ipv6Addr::to_bits()`) - #134521 (Arbitrary self types v2: roll loop.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bcf83ec + 435eeca commit 593bfc6

27 files changed

+471
-446
lines changed

src/helpers.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
1919
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
2020
use rustc_session::config::CrateType;
2121
use rustc_span::{Span, Symbol};
22+
use rustc_target::callconv::{Conv, FnAbi};
2223

2324
use crate::*;
2425

@@ -914,13 +915,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
914915
}
915916

916917
/// Check that the ABI is what we expect.
917-
fn check_abi<'a>(&self, abi: ExternAbi, exp_abi: ExternAbi) -> InterpResult<'a, ()> {
918-
if abi != exp_abi {
918+
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
919+
if fn_abi.conv != exp_abi {
919920
throw_ub_format!(
920-
"calling a function with ABI {} using caller ABI {}",
921-
exp_abi.name(),
922-
abi.name()
923-
)
921+
"calling a function with ABI {:?} using caller ABI {:?}",
922+
exp_abi, fn_abi.conv);
924923
}
925924
interp_ok(())
926925
}
@@ -950,8 +949,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
950949

951950
fn check_abi_and_shim_symbol_clash(
952951
&mut self,
953-
abi: ExternAbi,
954-
exp_abi: ExternAbi,
952+
abi: &FnAbi<'tcx, Ty<'tcx>>,
953+
exp_abi: Conv,
955954
link_name: Symbol,
956955
) -> InterpResult<'tcx, ()> {
957956
self.check_abi(abi, exp_abi)?;
@@ -975,8 +974,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
975974

976975
fn check_shim<'a, const N: usize>(
977976
&mut self,
978-
abi: ExternAbi,
979-
exp_abi: ExternAbi,
977+
abi: &FnAbi<'tcx, Ty<'tcx>>,
978+
exp_abi: Conv,
980979
link_name: Symbol,
981980
args: &'a [OpTy<'tcx>],
982981
) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>

src/machine.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rand::{Rng, SeedableRng};
1313
use rustc_abi::{Align, ExternAbi, Size};
1414
use rustc_attr_parsing::InlineAttr;
1515
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
16+
use rustc_target::callconv::FnAbi;
1617
#[allow(unused)]
1718
use rustc_data_structures::static_assert_size;
1819
use rustc_middle::mir;
@@ -1010,7 +1011,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10101011
fn find_mir_or_eval_fn(
10111012
ecx: &mut MiriInterpCx<'tcx>,
10121013
instance: ty::Instance<'tcx>,
1013-
abi: ExternAbi,
1014+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10141015
args: &[FnArg<'tcx, Provenance>],
10151016
dest: &MPlaceTy<'tcx>,
10161017
ret: Option<mir::BasicBlock>,
@@ -1037,7 +1038,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10371038
fn call_extra_fn(
10381039
ecx: &mut MiriInterpCx<'tcx>,
10391040
fn_val: DynSym,
1040-
abi: ExternAbi,
1041+
abi: &FnAbi<'tcx, Ty<'tcx>>,
10411042
args: &[FnArg<'tcx, Provenance>],
10421043
dest: &MPlaceTy<'tcx>,
10431044
ret: Option<mir::BasicBlock>,

src/shims/backtrace.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use rustc_abi::{ExternAbi, Size};
1+
use rustc_abi::Size;
22
use rustc_middle::ty::layout::LayoutOf as _;
33
use rustc_middle::ty::{self, Instance, Ty};
44
use rustc_span::{BytePos, Loc, Symbol, hygiene};
5+
use rustc_target::callconv::{Conv, FnAbi};
56

67
use crate::helpers::check_min_arg_count;
78
use crate::*;
@@ -10,13 +11,13 @@ impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
1011
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1112
fn handle_miri_backtrace_size(
1213
&mut self,
13-
abi: ExternAbi,
14+
abi: &FnAbi<'tcx, Ty<'tcx>>,
1415
link_name: Symbol,
1516
args: &[OpTy<'tcx>],
1617
dest: &MPlaceTy<'tcx>,
1718
) -> InterpResult<'tcx> {
1819
let this = self.eval_context_mut();
19-
let [flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
20+
let [flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
2021

2122
let flags = this.read_scalar(flags)?.to_u64()?;
2223
if flags != 0 {
@@ -30,7 +31,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3031

3132
fn handle_miri_get_backtrace(
3233
&mut self,
33-
abi: ExternAbi,
34+
abi: &FnAbi<'tcx, Ty<'tcx>>,
3435
link_name: Symbol,
3536
args: &[OpTy<'tcx>],
3637
dest: &MPlaceTy<'tcx>,
@@ -71,7 +72,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
7172
// storage for pointers is allocated by miri
7273
// deallocating the slice is undefined behavior with a custom global allocator
7374
0 => {
74-
let [_flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
75+
let [_flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
7576

7677
let alloc = this.allocate(array_layout, MiriMemoryKind::Rust.into())?;
7778

@@ -86,7 +87,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8687
}
8788
// storage for pointers is allocated by the caller
8889
1 => {
89-
let [_flags, buf] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
90+
let [_flags, buf] = this.check_shim(abi, Conv::Rust, link_name, args)?;
9091

9192
let buf_place = this.deref_pointer(buf)?;
9293

@@ -136,13 +137,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
136137

137138
fn handle_miri_resolve_frame(
138139
&mut self,
139-
abi: ExternAbi,
140+
abi: &FnAbi<'tcx, Ty<'tcx>>,
140141
link_name: Symbol,
141142
args: &[OpTy<'tcx>],
142143
dest: &MPlaceTy<'tcx>,
143144
) -> InterpResult<'tcx> {
144145
let this = self.eval_context_mut();
145-
let [ptr, flags] = this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
146+
let [ptr, flags] = this.check_shim(abi, Conv::Rust, link_name, args)?;
146147

147148
let flags = this.read_scalar(flags)?.to_u64()?;
148149

@@ -207,14 +208,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
207208

208209
fn handle_miri_resolve_frame_names(
209210
&mut self,
210-
abi: ExternAbi,
211+
abi: &FnAbi<'tcx, Ty<'tcx>>,
211212
link_name: Symbol,
212213
args: &[OpTy<'tcx>],
213214
) -> InterpResult<'tcx> {
214215
let this = self.eval_context_mut();
215216

216217
let [ptr, flags, name_ptr, filename_ptr] =
217-
this.check_shim(abi, ExternAbi::Rust, link_name, args)?;
218+
this.check_shim(abi, Conv::Rust, link_name, args)?;
218219

219220
let flags = this.read_scalar(flags)?.to_u64()?;
220221
if flags != 0 {

0 commit comments

Comments
 (0)