about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-07-01 14:12:49 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-07-02 21:05:18 +0300
commit52bdaaa0edb2824af1610b67664f06580335fd78 (patch)
treea3bdcd9be179c4529fd20054032074771334582d
parent64a88db762bc13b37508d44e09731a3b8349110a (diff)
downloadrust-52bdaaa0edb2824af1610b67664f06580335fd78.tar.gz
rust-52bdaaa0edb2824af1610b67664f06580335fd78.zip
Add some requested tests
-rw-r--r--src/test/ui/parser/float-field-interpolated.rs17
-rw-r--r--src/test/ui/parser/float-field-interpolated.stderr46
-rw-r--r--src/test/ui/tuple/index-float.rs1
3 files changed, 64 insertions, 0 deletions
diff --git a/src/test/ui/parser/float-field-interpolated.rs b/src/test/ui/parser/float-field-interpolated.rs
new file mode 100644
index 00000000000..a3053203536
--- /dev/null
+++ b/src/test/ui/parser/float-field-interpolated.rs
@@ -0,0 +1,17 @@
+struct S(u8, (u8, u8));
+
+macro_rules! generate_field_accesses {
+    ($a:tt, $b:literal, $c:expr) => {
+        let s = S(0, (0, 0));
+
+        s.$a; // OK
+        { s.$b; } //~ ERROR unexpected token: `1.1`
+                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+        { s.$c; } //~ ERROR unexpected token: `1.1`
+                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+    };
+}
+
+fn main() {
+    generate_field_accesses!(1.1, 1.1, 1.1);
+}
diff --git a/src/test/ui/parser/float-field-interpolated.stderr b/src/test/ui/parser/float-field-interpolated.stderr
new file mode 100644
index 00000000000..fb974f085cb
--- /dev/null
+++ b/src/test/ui/parser/float-field-interpolated.stderr
@@ -0,0 +1,46 @@
+error: unexpected token: `1.1`
+  --> $DIR/float-field-interpolated.rs:8:13
+   |
+LL |         { s.$b; }
+   |             ^^
+...
+LL |     generate_field_accesses!(1.1, 1.1, 1.1);
+   |     ---------------------------------------- in this macro invocation
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+  --> $DIR/float-field-interpolated.rs:8:13
+   |
+LL |         { s.$b; }
+   |             ^^ expected one of `.`, `;`, `?`, `}`, or an operator
+...
+LL |     generate_field_accesses!(1.1, 1.1, 1.1);
+   |     ---------------------------------------- in this macro invocation
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected token: `1.1`
+  --> $DIR/float-field-interpolated.rs:10:13
+   |
+LL |         { s.$c; }
+   |             ^^
+...
+LL |     generate_field_accesses!(1.1, 1.1, 1.1);
+   |     ---------------------------------------- in this macro invocation
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+  --> $DIR/float-field-interpolated.rs:10:13
+   |
+LL |         { s.$c; }
+   |             ^^ expected one of `.`, `;`, `?`, `}`, or an operator
+...
+LL |     generate_field_accesses!(1.1, 1.1, 1.1);
+   |     ---------------------------------------- in this macro invocation
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui/tuple/index-float.rs b/src/test/ui/tuple/index-float.rs
index 85b088d664d..eda2bf48581 100644
--- a/src/test/ui/tuple/index-float.rs
+++ b/src/test/ui/tuple/index-float.rs
@@ -4,6 +4,7 @@ fn main() {
     let tuple = (((),),);
 
     let _ = tuple. 0.0; // OK, whitespace
+    let _ = tuple.0. 0; // OK, whitespace
 
     let _ = tuple./*special cases*/0.0; // OK, comment
 }