Skip to content

Commit 44c1336

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

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

tests/ui/parser/f16-f128.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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; //~ ERROR cannot find type `f16` in this scope
5+
6+
pub fn main() {
7+
let a: f16 = 100.0; //~ ERROR cannot find type `f16` in this scope
8+
let b = 0.0f16; //~ ERROR invalid width `16` for float literal
9+
10+
foo(1.23);
11+
}
12+
13+
fn foo(a: f16) {} //~ ERROR cannot find type `f16` in this scope
14+
15+
struct Bar {
16+
a: f16, //~ ERROR cannot find type `f16` in this scope
17+
}
18+
}
19+
20+
mod f128_checks {
21+
const A: f128 = 10.0; //~ ERROR cannot find type `f128` in this scope
22+
23+
pub fn main() {
24+
let a: f128 = 100.0; //~ ERROR cannot find type `f128` in this scope
25+
let b = 0.0f128; //~ ERROR invalid width `128` for float literal
26+
27+
foo(1.23);
28+
}
29+
30+
fn foo(a: f128) {} //~ ERROR cannot find type `f128` in this scope
31+
32+
struct Bar {
33+
a: f128, //~ ERROR cannot find type `f128` in this scope
34+
}
35+
}
36+
37+
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:13: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:16: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:21: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:24: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:30: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:33: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:25: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)