Skip to content

Commit c126076

Browse files
committed
Add a basic test for f16 and f128
1 parent 36c078f commit c126076

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

tests/ui/parser/f16-f128.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Make sure we don't ICE while incrementally adding f16 and f128 support
2+
3+
mod f16_checks {
4+
const A: f16 = 10.0;
5+
6+
pub fn main() {
7+
let a: f16 = 100.0;
8+
let b = 0.0f16;
9+
foo(1.23);
10+
}
11+
12+
fn foo(a: f16) {}
13+
14+
struct Bar {
15+
a: f16,
16+
}
17+
}
18+
19+
mod f128_checks {
20+
const A: f128 = 10.0;
21+
22+
pub fn main() {
23+
let a: f128 = 100.0;
24+
let b = 0.0f128;
25+
foo(1.23);
26+
}
27+
28+
fn foo(a: f128) {}
29+
30+
struct Bar {
31+
a: f128,
32+
}
33+
}
34+
35+
fn main() {}

tests/ui/parser/f16-f128.stderr

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error[E0412]: cannot find type `f16` in this scope
2+
--> $DIR/f16-f128.rs:4:14
3+
|
4+
LL | const A: f16 = 10.0;
5+
| ^^^ help: a builtin type with a similar name exists: `i16`
6+
7+
error[E0412]: cannot find type `f16` in this scope
8+
--> $DIR/f16-f128.rs:7:16
9+
|
10+
LL | let a: f16 = 100.0;
11+
| ^^^ help: a builtin type with a similar name exists: `i16`
12+
13+
error[E0412]: cannot find type `f16` in this scope
14+
--> $DIR/f16-f128.rs:12:15
15+
|
16+
LL | fn foo(a: f16) {}
17+
| ^^^ help: a builtin type with a similar name exists: `i16`
18+
19+
error[E0412]: cannot find type `f16` in this scope
20+
--> $DIR/f16-f128.rs:15:12
21+
|
22+
LL | a: f16,
23+
| ^^^ help: a builtin type with a similar name exists: `i16`
24+
25+
error[E0412]: cannot find type `f128` in this scope
26+
--> $DIR/f16-f128.rs:20:14
27+
|
28+
LL | const A: f128 = 10.0;
29+
| ^^^^ help: a builtin type with a similar name exists: `i128`
30+
31+
error[E0412]: cannot find type `f128` in this scope
32+
--> $DIR/f16-f128.rs:23:16
33+
|
34+
LL | let a: f128 = 100.0;
35+
| ^^^^ help: a builtin type with a similar name exists: `i128`
36+
37+
error[E0412]: cannot find type `f128` in this scope
38+
--> $DIR/f16-f128.rs:28:15
39+
|
40+
LL | fn foo(a: f128) {}
41+
| ^^^^ help: a builtin type with a similar name exists: `i128`
42+
43+
error[E0412]: cannot find type `f128` in this scope
44+
--> $DIR/f16-f128.rs:31:12
45+
|
46+
LL | a: f128,
47+
| ^^^^ help: a builtin type with a similar name exists: `i128`
48+
49+
error: invalid width `16` for float literal
50+
--> $DIR/f16-f128.rs:8:17
51+
|
52+
LL | let b = 0.0f16;
53+
| ^^^^^^
54+
|
55+
= help: valid widths are 32 and 64
56+
57+
error: invalid width `128` for float literal
58+
--> $DIR/f16-f128.rs:24:17
59+
|
60+
LL | let b = 0.0f128;
61+
| ^^^^^^^
62+
|
63+
= help: valid widths are 32 and 64
64+
65+
error: aborting due to 10 previous errors
66+
67+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)