about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-08-16 18:16:12 +0530
committerGitHub <noreply@github.com>2022-08-16 18:16:12 +0530
commitcf5c7645ac7734ab9e0b4aba3f1e76abd3777167 (patch)
treea7e1b18f37f3f02ecd4b8e145455df65a269d612 /src
parent070de4bc4866fe8f36bf1538e01e10eab25f3c79 (diff)
parent89a51a1a483fcf411ab0d9e6416b6d91600d69d9 (diff)
Rollup merge of #100609 - chenyukang:fix-100527, r=davidtwco
Extend invalid floating point literal suffix suggestion

Fixes #100527
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/attempted-access-non-fatal.rs4
-rw-r--r--src/test/ui/attempted-access-non-fatal.stderr46
-rw-r--r--src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr14
3 files changed, 56 insertions, 8 deletions
diff --git a/src/test/ui/attempted-access-non-fatal.rs b/src/test/ui/attempted-access-non-fatal.rs
index e50c1f23c51..15deb9e2f60 100644
--- a/src/test/ui/attempted-access-non-fatal.rs
+++ b/src/test/ui/attempted-access-non-fatal.rs
@@ -3,4 +3,8 @@ fn main() {
     let x = 0;
     let _ = x.foo; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
     let _ = x.bar; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
+    let _ = 0.f; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
+    let _ = 2.l; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
+    let _ = 12.F; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
+    let _ = 34.L; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610]
 }
diff --git a/src/test/ui/attempted-access-non-fatal.stderr b/src/test/ui/attempted-access-non-fatal.stderr
index 5b7db0e9d6f..bff669727a1 100644
--- a/src/test/ui/attempted-access-non-fatal.stderr
+++ b/src/test/ui/attempted-access-non-fatal.stderr
@@ -10,6 +10,50 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     let _ = x.bar;
    |               ^^^
 
-error: aborting due to 2 previous errors
+error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
+  --> $DIR/attempted-access-non-fatal.rs:6:15
+   |
+LL |     let _ = 0.f;
+   |               ^
+   |
+help: if intended to be a floating point literal, consider adding a `0` after the period and a `f32` suffix
+   |
+LL |     let _ = 0.0f32;
+   |               ~~~~
+
+error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
+  --> $DIR/attempted-access-non-fatal.rs:7:15
+   |
+LL |     let _ = 2.l;
+   |               ^
+   |
+help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
+   |
+LL |     let _ = 2.0f64;
+   |               ~~~~
+
+error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
+  --> $DIR/attempted-access-non-fatal.rs:8:16
+   |
+LL |     let _ = 12.F;
+   |                ^
+   |
+help: if intended to be a floating point literal, consider adding a `0` after the period and a `f32` suffix
+   |
+LL |     let _ = 12.0f32;
+   |                ~~~~
+
+error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
+  --> $DIR/attempted-access-non-fatal.rs:9:16
+   |
+LL |     let _ = 34.L;
+   |                ^
+   |
+help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
+   |
+LL |     let _ = 34.0f64;
+   |                ~~~~
+
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0610`.
diff --git a/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr b/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
index e8e069708a8..503015f3bec 100644
--- a/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
+++ b/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
@@ -4,7 +4,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.e1;
    |       ^^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0e1;
    |       +
@@ -15,7 +15,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.E1;
    |       ^^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0E1;
    |       +
@@ -26,7 +26,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.f32;
    |       ^^^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0f32;
    |       +
@@ -37,7 +37,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.f64;
    |       ^^^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0f64;
    |       +
@@ -48,7 +48,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.e+12;
    |       ^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0e+12;
    |       +
@@ -59,7 +59,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.e-12;
    |       ^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0e-12;
    |       +
@@ -70,7 +70,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
 LL |     2.e1f32;
    |       ^^^^^
    |
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
    |
 LL |     2.0e1f32;
    |       +