Skip to content

Commit af8e471

Browse files
bogglegraydon
authored andcommitted
Fixed type resolution error in math tests
1 parent 50db7ce commit af8e471

File tree

4 files changed

+70
-8
lines changed

4 files changed

+70
-8
lines changed

src/libstd/mtypes.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
3+
Module: mtypes
4+
5+
Machine type equivalents of rust int, uint, float, and complex.
6+
7+
Types useful for interop with C when writing bindings that exist
8+
for different types (float, f32, f64, ...; cf float.rs for an example)
9+
*/
10+
11+
export m_int, m_uint, m_float;
12+
13+
// PORT Change this when porting to a new architecture
14+
15+
/*
16+
Type: m_int
17+
18+
Machine type equivalent of an int
19+
*/
20+
#[cfg(target_arch="x86")]
21+
type m_int = i32;
22+
#[cfg(target_arch="x86_64")]
23+
type m_int = i64;
24+
25+
// PORT Change this when porting to a new architecture
26+
27+
/*
28+
Type: m_uint
29+
30+
Machine type equivalent of a uint
31+
*/
32+
#[cfg(target_arch="x86")]
33+
type m_uint = u32;
34+
#[cfg(target_arch="x86_64")]
35+
type m_uint = u64;
36+
37+
// PORT *must* match with "import m_float = fXX" in std::math per arch
38+
39+
/*
40+
Type: m_float
41+
42+
Machine type equivalent of a float
43+
*/
44+
type m_float = f64;
45+
46+
// PORT *must* match "import m_complex = ..." in std::complex per arch
47+
48+
/*
49+
FIXME Type m_complex
50+
51+
Machine type representing a complex value that uses floats for
52+
both the real and the imaginary part.
53+
*/
54+
// type m_complex = complex_c64::t;
55+
56+
//
57+
// Local Variables:
58+
// mode: rust
59+
// fill-column: 78;
60+
// indent-tabs-mode: nil
61+
// c-basic-offset: 4
62+
// buffer-file-coding-system: utf-8-unix
63+
// End:
64+
//

src/test/compile-fail/non-triv-cast-be.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// error-pattern: non-trivial cast of tail-call return value
2-
use std;
3-
4-
import ctypes::*;
2+
import core::mtypes::*;
53

64
fn foo_float() -> m_float { ret 0.0 as m_float; }
75
fn bar_float() -> bool { be foo_float() as bool; }

src/test/run-pass/triv-cast-be.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use std;
1+
import core::ctypes::*;
22

3-
import ctypes::*;
3+
import core::mtypes::m_float;
4+
import core::mtypes::m_int;
5+
import core::mtypes::m_uint;
46

57
fn foo_float() -> m_float { ret 0.0 as m_float; }
68
fn bar_float() -> float { be foo_float() as float; }

src/test/run-pass/triv-cast-const.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std;
2-
3-
import ctypes::*;
1+
import core::mtypes::m_int;
42

53
// This will be more interesting once there is support
64
// for consts that refer to other consts, i.e. math_f64::consts::pi as m_float

0 commit comments

Comments
 (0)