Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f13c4f4

Browse files
author
Lukas Markeffsky
committed
constify exact_div intrinsic
1 parent 5e6de23 commit f13c4f4

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
@@ -243,6 +243,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
243243
let discr_val = self.read_discriminant(&place.into())?.0;
244244
self.write_scalar(discr_val, dest)?;
245245
}
246+
sym::exact_div => {
247+
let l = self.read_immediate(&args[0])?;
248+
let r = self.read_immediate(&args[1])?;
249+
self.exact_div(&l, &r, dest)?;
250+
}
246251
sym::unchecked_shl
247252
| sym::unchecked_shr
248253
| sym::unchecked_add

library/core/src/intrinsics.rs

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

18561857
/// 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
@@ -368,11 +368,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
368368
}
369369

370370
// Other
371-
"exact_div" => {
372-
let [num, denom] = check_arg_count(args)?;
373-
this.exact_div(&this.read_immediate(num)?, &this.read_immediate(denom)?, dest)?;
374-
}
375-
376371
"breakpoint" => {
377372
let [] = check_arg_count(args)?;
378373
// normally this would raise a SIGTRAP, which aborts if no debugger is connected

0 commit comments

Comments
 (0)