@@ -141,17 +141,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
141
141
// First: functions that diverge.
142
142
match link_name {
143
143
"__rust_start_panic" | "panic_impl" => {
144
- throw_unsup ! ( MachineError ( "the evaluated program panicked" . to_string ( ) ) ) ;
144
+ throw_unsup_format ! ( "the evaluated program panicked" ) ;
145
145
}
146
146
"exit" | "ExitProcess" => {
147
147
// it's really u32 for ExitProcess, but we have to put it into the `Exit` error variant anyway
148
148
let code = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
149
149
return Err ( InterpError :: Exit ( code) . into ( ) ) ;
150
150
}
151
151
_ => if dest. is_none ( ) {
152
- throw_unsup ! ( Unimplemented (
153
- format!( "can't call diverging foreign function: {}" , link_name) ,
154
- ) ) ;
152
+ throw_unsup_format ! ( "can't call (diverging) foreign function: {}" , link_name) ;
155
153
}
156
154
}
157
155
@@ -179,16 +177,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
179
177
if !align. is_power_of_two ( ) {
180
178
throw_unsup ! ( HeapAllocNonPowerOfTwoAlignment ( align) ) ;
181
179
}
182
- /*
183
- FIXME: This check is disabled because rustc violates it.
184
- See <https://github.com/rust-lang/rust/issues/62251>.
185
180
if align < this. pointer_size ( ) . bytes ( ) {
186
- throw_unsup!(MachineError(format !(
181
+ throw_ub_format ! (
187
182
"posix_memalign: alignment must be at least the size of a pointer, but is {}" ,
188
183
align,
189
- ))) ;
184
+ ) ;
190
185
}
191
- */
186
+
192
187
if size == 0 {
193
188
this. write_null ( ret. into ( ) ) ?;
194
189
} else {
@@ -309,9 +304,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
309
304
this. write_scalar ( Scalar :: from_uint ( len, dest. layout . size ) , dest) ?;
310
305
}
311
306
id => {
312
- throw_unsup ! ( Unimplemented (
313
- format!( "miri does not support syscall ID {}" , id) ,
314
- ) )
307
+ throw_unsup_format ! ( "miri does not support syscall ID {}" , id)
315
308
}
316
309
}
317
310
}
@@ -359,12 +352,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
359
352
) ?;
360
353
let mut args = this. frame ( ) . body . args_iter ( ) ;
361
354
362
- let arg_local = args. next ( ) . ok_or_else ( ||
363
- err_unsup ! ( AbiViolation (
364
- "Argument to __rust_maybe_catch_panic does not take enough arguments."
365
- . to_owned( ) ,
366
- ) ) ,
367
- ) ?;
355
+ let arg_local = args. next ( )
356
+ . expect ( "Argument to __rust_maybe_catch_panic does not take enough arguments." ) ;
368
357
let arg_dest = this. local_place ( arg_local) ?;
369
358
this. write_scalar ( data, arg_dest) ?;
370
359
@@ -641,9 +630,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
641
630
if let Some ( result) = result {
642
631
this. write_scalar ( result, dest) ?;
643
632
} else {
644
- throw_unsup ! ( Unimplemented (
645
- format!( "Unimplemented sysconf name: {}" , name) ,
646
- ) ) ;
633
+ throw_unsup_format ! ( "Unimplemented sysconf name: {}" , name)
647
634
}
648
635
}
649
636
@@ -670,9 +657,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
670
657
// This is `libc::pthread_key_t`.
671
658
let key_type = args[ 0 ] . layout . ty
672
659
. builtin_deref ( true )
673
- . ok_or_else ( || err_unsup ! (
674
- AbiViolation ( "wrong signature used for `pthread_key_create`: first argument must be a raw pointer." . to_owned ( ) )
675
- ) ) ?
660
+ . ok_or_else ( || err_ub ! ( Ub ( format !(
661
+ "wrong signature used for `pthread_key_create`: first argument must be a raw pointer."
662
+ ) ) ) ) ?
676
663
. ty ;
677
664
let key_layout = this. layout_of ( key_type) ?;
678
665
@@ -738,7 +725,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
738
725
739
726
// We don't support threading. (Also for Windows.)
740
727
"pthread_create" | "CreateThread" => {
741
- throw_unsup ! ( Unimplemented ( format! ( "Miri does not support threading" ) ) ) ;
728
+ throw_unsup_format ! ( "Miri does not support threading" ) ;
742
729
}
743
730
744
731
// Stub out calls for condvar, mutex and rwlock, to just return `0`.
@@ -957,9 +944,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
957
944
958
945
// We can't execute anything else.
959
946
_ => {
960
- throw_unsup ! ( Unimplemented (
961
- format!( "can't call foreign function: {}" , link_name) ,
962
- ) ) ;
947
+ throw_unsup_format ! ( "can't call foreign function: {}" , link_name)
963
948
}
964
949
}
965
950
0 commit comments