about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2024-02-28 04:04:16 -0500
committerTrevor Gross <tmgross@umich.edu>2024-02-28 12:58:32 -0500
commit406790e9d1f2a02f3b4d004cca7d33e69ef7dca5 (patch)
tree599868c1f483ccadc87fdb4a60639df45be9cbb2
parentc17a516a3ac33233cde46d45a24e493b6534fa86 (diff)
downloadrust-406790e9d1f2a02f3b4d004cca7d33e69ef7dca5.tar.gz
rust-406790e9d1f2a02f3b4d004cca7d33e69ef7dca5.zip
Add a basic test for `f16` and `f128`
-rw-r--r--tests/ui/parser/f16-f128.rs37
-rw-r--r--tests/ui/parser/f16-f128.stderr67
2 files changed, 104 insertions, 0 deletions
diff --git a/tests/ui/parser/f16-f128.rs b/tests/ui/parser/f16-f128.rs
new file mode 100644
index 00000000000..4f31dccce3c
--- /dev/null
+++ b/tests/ui/parser/f16-f128.rs
@@ -0,0 +1,37 @@
+// Make sure we don't ICE while incrementally adding f16 and f128 support
+
+mod f16_checks {
+    const A: f16 = 10.0; //~ ERROR cannot find type `f16` in this scope
+
+    pub fn main() {
+        let a: f16 = 100.0; //~ ERROR cannot find type `f16` in this scope
+        let b = 0.0f16; //~ ERROR invalid width `16` for float literal
+
+        foo(1.23);
+    }
+
+    fn foo(a: f16) {} //~ ERROR cannot find type `f16` in this scope
+
+    struct Bar {
+        a: f16, //~ ERROR cannot find type `f16` in this scope
+    }
+}
+
+mod f128_checks {
+    const A: f128 = 10.0; //~ ERROR cannot find type `f128` in this scope
+
+    pub fn main() {
+        let a: f128 = 100.0; //~ ERROR cannot find type `f128` in this scope
+        let b = 0.0f128; //~ ERROR invalid width `128` for float literal
+
+        foo(1.23);
+    }
+
+    fn foo(a: f128) {} //~ ERROR cannot find type `f128` in this scope
+
+    struct Bar {
+        a: f128, //~ ERROR cannot find type `f128` in this scope
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/parser/f16-f128.stderr b/tests/ui/parser/f16-f128.stderr
new file mode 100644
index 00000000000..d3f2227acd7
--- /dev/null
+++ b/tests/ui/parser/f16-f128.stderr
@@ -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:13: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:16: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:21: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:24: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:30: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:33: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:25: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`.