Skip to content

Commit

Permalink
Add a basic test for f16 and f128
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Feb 28, 2024
1 parent 36c078f commit c126076
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/ui/parser/f16-f128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Make sure we don't ICE while incrementally adding f16 and f128 support

mod f16_checks {
const A: f16 = 10.0;

pub fn main() {
let a: f16 = 100.0;
let b = 0.0f16;
foo(1.23);
}

fn foo(a: f16) {}

struct Bar {
a: f16,
}
}

mod f128_checks {
const A: f128 = 10.0;

pub fn main() {
let a: f128 = 100.0;
let b = 0.0f128;
foo(1.23);
}

fn foo(a: f128) {}

struct Bar {
a: f128,
}
}

fn main() {}
67 changes: 67 additions & 0 deletions tests/ui/parser/f16-f128.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
error[E0412]: cannot find type `f16` in this scope
--> $DIR/f16-f128.rs:4:14
|
LL | const A: f16 = 10.0;
| ^^^ help: a builtin type with a similar name exists: `i16`

error[E0412]: cannot find type `f16` in this scope
--> $DIR/f16-f128.rs:7:16
|
LL | let a: f16 = 100.0;
| ^^^ help: a builtin type with a similar name exists: `i16`

error[E0412]: cannot find type `f16` in this scope
--> $DIR/f16-f128.rs:12:15
|
LL | fn foo(a: f16) {}
| ^^^ help: a builtin type with a similar name exists: `i16`

error[E0412]: cannot find type `f16` in this scope
--> $DIR/f16-f128.rs:15:12
|
LL | a: f16,
| ^^^ help: a builtin type with a similar name exists: `i16`

error[E0412]: cannot find type `f128` in this scope
--> $DIR/f16-f128.rs:20:14
|
LL | const A: f128 = 10.0;
| ^^^^ help: a builtin type with a similar name exists: `i128`

error[E0412]: cannot find type `f128` in this scope
--> $DIR/f16-f128.rs:23:16
|
LL | let a: f128 = 100.0;
| ^^^^ help: a builtin type with a similar name exists: `i128`

error[E0412]: cannot find type `f128` in this scope
--> $DIR/f16-f128.rs:28:15
|
LL | fn foo(a: f128) {}
| ^^^^ help: a builtin type with a similar name exists: `i128`

error[E0412]: cannot find type `f128` in this scope
--> $DIR/f16-f128.rs:31:12
|
LL | a: f128,
| ^^^^ help: a builtin type with a similar name exists: `i128`

error: invalid width `16` for float literal
--> $DIR/f16-f128.rs:8:17
|
LL | let b = 0.0f16;
| ^^^^^^
|
= help: valid widths are 32 and 64

error: invalid width `128` for float literal
--> $DIR/f16-f128.rs:24:17
|
LL | let b = 0.0f128;
| ^^^^^^^
|
= help: valid widths are 32 and 64

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0412`.

0 comments on commit c126076

Please sign in to comment.