Skip to content

rustc: Remove f{32,64} % from the language #13410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4125,14 +4125,15 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
static opcat_eq: int = 5;
static opcat_bit: int = 6;
static opcat_logic: int = 7;
static opcat_mod: int = 8;

fn opcat(op: ast::BinOp) -> int {
match op {
ast::BiAdd => opcat_add,
ast::BiSub => opcat_sub,
ast::BiMul => opcat_mult,
ast::BiDiv => opcat_mult,
ast::BiRem => opcat_mult,
ast::BiRem => opcat_mod,
ast::BiAnd => opcat_logic,
ast::BiOr => opcat_logic,
ast::BiBitXor => opcat_bit,
Expand Down Expand Up @@ -4168,14 +4169,14 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
static f: bool = false;

let tbl = [
// +, -, *, shift, rel, ==, bit, logic
/*other*/ [f, f, f, f, f, f, f, f],
/*bool*/ [f, f, f, f, t, t, t, t],
/*char*/ [f, f, f, f, t, t, f, f],
/*int*/ [t, t, t, t, t, t, t, f],
/*float*/ [t, t, t, f, t, t, f, f],
/*bot*/ [t, t, t, t, t, t, t, t],
/*raw ptr*/ [f, f, f, f, t, t, f, f]];
// +, -, *, shift, rel, ==, bit, logic, mod
/*other*/ [f, f, f, f, f, f, f, f, f],
/*bool*/ [f, f, f, f, t, t, t, t, f],
/*char*/ [f, f, f, f, t, t, f, f, f],
/*int*/ [t, t, t, t, t, t, t, f, t],
/*float*/ [t, t, t, f, t, t, f, f, f],
/*bot*/ [t, t, t, t, t, t, t, t, t],
/*raw ptr*/ [f, f, f, f, t, t, f, f, f]];

return tbl[tycat(cx, ty) as uint ][opcat(op) as uint];
}
Expand Down
5 changes: 4 additions & 1 deletion src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod cmath {
pub fn frexpf(n: c_float, value: &mut c_int) -> c_float;
pub fn fmaxf(a: c_float, b: c_float) -> c_float;
pub fn fminf(a: c_float, b: c_float) -> c_float;
pub fn fmodf(a: c_float, b: c_float) -> c_float;
pub fn nextafterf(x: c_float, y: c_float) -> c_float;
pub fn hypotf(x: c_float, y: c_float) -> c_float;
pub fn ldexpf(x: c_float, n: c_int) -> c_float;
Expand Down Expand Up @@ -201,7 +202,9 @@ impl Div<f32,f32> for f32 {
#[cfg(not(test))]
impl Rem<f32,f32> for f32 {
#[inline]
fn rem(&self, other: &f32) -> f32 { *self % *other }
fn rem(&self, other: &f32) -> f32 {
unsafe { cmath::fmodf(*self, *other) }
}
}

#[cfg(not(test))]
Expand Down
5 changes: 4 additions & 1 deletion src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod cmath {
pub fn fdim(a: c_double, b: c_double) -> c_double;
pub fn fmax(a: c_double, b: c_double) -> c_double;
pub fn fmin(a: c_double, b: c_double) -> c_double;
pub fn fmod(a: c_double, b: c_double) -> c_double;
pub fn nextafter(x: c_double, y: c_double) -> c_double;
pub fn frexp(n: c_double, value: &mut c_int) -> c_double;
pub fn hypot(x: c_double, y: c_double) -> c_double;
Expand Down Expand Up @@ -210,7 +211,9 @@ impl Div<f64,f64> for f64 {
#[cfg(not(test))]
impl Rem<f64,f64> for f64 {
#[inline]
fn rem(&self, other: &f64) -> f64 { *self % *other }
fn rem(&self, other: &f64) -> f64 {
unsafe { cmath::fmod(*self, *other) }
}
}
#[cfg(not(test))]
impl Neg<f64> for f64 {
Expand Down