Skip to content

Commit 602e1a0

Browse files
committed
Auto merge of #1168 - RalfJung:rustup, r=RalfJung
Rustup
2 parents ad7b1bd + 5d2caef commit 602e1a0

12 files changed

+22
-61
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0cbcb17d3306d6e22eafc2c05ce885db97d0189c
1+
333c32a5a4a51cae562c47e0669bc5aeaf741c45

src/shims/intrinsics.rs

-40
Original file line numberDiff line numberDiff line change
@@ -518,46 +518,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
518518
this.write_scalar(Scalar::from_uint(align.bytes(), ptr_size), dest)?;
519519
}
520520

521-
"unchecked_div" => {
522-
let l = this.read_immediate(args[0])?;
523-
let r = this.read_immediate(args[1])?;
524-
let rval = r.to_scalar()?.to_bits(args[1].layout.size)?;
525-
if rval == 0 {
526-
throw_ub_format!("Division by 0 in unchecked_div");
527-
}
528-
this.binop_ignore_overflow(mir::BinOp::Div, l, r, dest)?;
529-
}
530-
531-
"unchecked_rem" => {
532-
let l = this.read_immediate(args[0])?;
533-
let r = this.read_immediate(args[1])?;
534-
let rval = r.to_scalar()?.to_bits(args[1].layout.size)?;
535-
if rval == 0 {
536-
throw_ub_format!("Division by 0 in unchecked_rem");
537-
}
538-
this.binop_ignore_overflow(mir::BinOp::Rem, l, r, dest)?;
539-
}
540-
541-
#[rustfmt::skip]
542-
| "unchecked_add"
543-
| "unchecked_sub"
544-
| "unchecked_mul"
545-
=> {
546-
let l = this.read_immediate(args[0])?;
547-
let r = this.read_immediate(args[1])?;
548-
let op = match intrinsic_name {
549-
"unchecked_add" => mir::BinOp::Add,
550-
"unchecked_sub" => mir::BinOp::Sub,
551-
"unchecked_mul" => mir::BinOp::Mul,
552-
_ => bug!(),
553-
};
554-
let (res, overflowed, _ty) = this.overflowing_binary_op(op, l, r)?;
555-
if overflowed {
556-
throw_ub_format!("Overflowing arithmetic in {}", intrinsic_name);
557-
}
558-
this.write_scalar(res, dest)?;
559-
}
560-
561521
"uninit" => {
562522
// Check fast path: we don't want to force an allocation in case the destination is a simple value,
563523
// but we also do not want to create a new allocation with 0s and then copy that over.

tests/compile-fail/div-by-zero-1.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
use std::intrinsics::*;
44

5-
//error-pattern: Division by 0 in unchecked_div
6-
75
fn main() {
86
unsafe {
9-
let _n = unchecked_div(1i64, 0);
7+
let _n = unchecked_div(1i64, 0); //~ERROR dividing by zero
108
}
119
}

tests/compile-fail/div-by-zero-2.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(core_intrinsics)]
2+
3+
use std::intrinsics::*;
4+
5+
fn main() {
6+
unsafe {
7+
let _n = unchecked_rem(3u32, 0); //~ ERROR calculating the remainder with a divisor of zero
8+
}
9+
}

tests/compile-fail/div-by-zero-3.rs

-11
This file was deleted.

tests/compile-fail/unchecked_add1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MAX overflow
4-
unsafe { std::intrinsics::unchecked_add(40000u16, 30000); } //~ ERROR Overflowing arithmetic in unchecked_add
4+
unsafe { std::intrinsics::unchecked_add(40000u16, 30000); } //~ ERROR Overflow executing `unchecked_add`
55
}

tests/compile-fail/unchecked_add2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MIN overflow
4-
unsafe { std::intrinsics::unchecked_add(-30000i16, -8000); } //~ ERROR Overflowing arithmetic in unchecked_add
4+
unsafe { std::intrinsics::unchecked_add(-30000i16, -8000); } //~ ERROR Overflow executing `unchecked_add`
55
}

tests/compile-fail/unchecked_div1.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![feature(core_intrinsics)]
2+
fn main() {
3+
// MIN/-1 cannot be represented
4+
unsafe { std::intrinsics::unchecked_div(i16::min_value(), -1); } //~ ERROR Overflow executing `unchecked_div`
5+
}

tests/compile-fail/unchecked_mul1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MAX overflow
4-
unsafe { std::intrinsics::unchecked_mul(300u16, 250u16); } //~ ERROR Overflowing arithmetic in unchecked_mul
4+
unsafe { std::intrinsics::unchecked_mul(300u16, 250u16); } //~ ERROR Overflow executing `unchecked_mul`
55
}

tests/compile-fail/unchecked_mul2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MIN overflow
4-
unsafe { std::intrinsics::unchecked_mul(1_000_000_000i32, -4); } //~ ERROR Overflowing arithmetic in unchecked_mul
4+
unsafe { std::intrinsics::unchecked_mul(1_000_000_000i32, -4); } //~ ERROR Overflow executing `unchecked_mul`
55
}

tests/compile-fail/unchecked_sub1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MIN overflow
4-
unsafe { std::intrinsics::unchecked_sub(14u32, 22); } //~ ERROR Overflowing arithmetic in unchecked_sub
4+
unsafe { std::intrinsics::unchecked_sub(14u32, 22); } //~ ERROR Overflow executing `unchecked_sub`
55
}

tests/compile-fail/unchecked_sub2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// MAX overflow
4-
unsafe { std::intrinsics::unchecked_sub(30000i16, -7000); } //~ ERROR Overflowing arithmetic in unchecked_sub
4+
unsafe { std::intrinsics::unchecked_sub(30000i16, -7000); } //~ ERROR Overflow executing `unchecked_sub`
55
}

0 commit comments

Comments
 (0)