Skip to content

Commit 9a1a753

Browse files
author
Lukas Markeffsky
committed
constify exact_div intrinsic
1 parent 542febd commit 9a1a753

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
234234
let discr_val = self.read_discriminant(&place.into())?.0;
235235
self.write_scalar(discr_val, dest)?;
236236
}
237+
sym::exact_div => {
238+
let l = self.read_immediate(&args[0])?;
239+
let r = self.read_immediate(&args[1])?;
240+
self.exact_div(&l, &r, dest)?;
241+
}
237242
sym::unchecked_shl
238243
| sym::unchecked_shr
239244
| sym::unchecked_add

library/core/src/intrinsics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,7 @@ extern "rust-intrinsic" {
18461846
/// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`
18471847
///
18481848
/// This intrinsic does not have a stable counterpart.
1849+
#[rustc_const_unstable(feature = "const_exact_div", issue = "none")]
18491850
pub fn exact_div<T: Copy>(x: T, y: T) -> T;
18501851

18511852
/// Performs an unchecked division, resulting in undefined behavior

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
#![feature(const_cmp)]
110110
#![feature(const_discriminant)]
111111
#![feature(const_eval_select)]
112+
#![feature(const_exact_div)]
112113
#![feature(const_float_bits_conv)]
113114
#![feature(const_float_classify)]
114115
#![feature(const_fmt_arguments_new)]

src/tools/miri/src/shims/intrinsics/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
357357
}
358358

359359
// Other
360-
"exact_div" => {
361-
let [num, denom] = check_arg_count(args)?;
362-
this.exact_div(&this.read_immediate(num)?, &this.read_immediate(denom)?, dest)?;
363-
}
364-
365360
"breakpoint" => {
366361
let [] = check_arg_count(args)?;
367362
// normally this would raise a SIGTRAP, which aborts if no debugger is connected

0 commit comments

Comments
 (0)