about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-10-26 11:29:57 +0530
committerGitHub <noreply@github.com>2022-10-26 11:29:57 +0530
commit703fb66fa03f1ca4832d02aa274eecefa10ca029 (patch)
treefdbc306079735a585f24106d593a4c05992166f5
parentd159124dbd8066a29fbc826dd7793805cf29fba5 (diff)
parent5064648624c94008d54a2f1d754168d1a0d1df26 (diff)
downloadrust-703fb66fa03f1ca4832d02aa274eecefa10ca029.tar.gz
rust-703fb66fa03f1ca4832d02aa274eecefa10ca029.zip
Rollup merge of #103542 - scottmcm:invalid-macro-patterns, r=compiler-errors
Pinning tests for some `macro_rules!` errors discussed in the lang meeting

r? ``@nikomatsakis``

Mind just stamping these, since they were useful for the meeting discussion today?
-rw-r--r--src/test/ui/macros/macro_rules-unmatchable-literals.rs14
-rw-r--r--src/test/ui/macros/macro_rules-unmatchable-literals.stderr14
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/macros/macro_rules-unmatchable-literals.rs b/src/test/ui/macros/macro_rules-unmatchable-literals.rs
new file mode 100644
index 00000000000..bde0fe1a015
--- /dev/null
+++ b/src/test/ui/macros/macro_rules-unmatchable-literals.rs
@@ -0,0 +1,14 @@
+// Pinning tests for things that don't work to make sure we notice if that changes
+
+#![crate_type = "lib"]
+
+macro_rules! octal_with_bad_digit {
+    ( 0o1238 ) => {}; //~ ERROR invalid digit
+}
+
+macro_rules! binary_with_bad_digit {
+    ( 0b012 ) => {}; //~ ERROR invalid digit
+}
+
+// This can't happen for Hex and Decimal as things like `123A` and `0xFFG`
+// get treated as unknown *suffixes*, rather than digits.
diff --git a/src/test/ui/macros/macro_rules-unmatchable-literals.stderr b/src/test/ui/macros/macro_rules-unmatchable-literals.stderr
new file mode 100644
index 00000000000..956a669791d
--- /dev/null
+++ b/src/test/ui/macros/macro_rules-unmatchable-literals.stderr
@@ -0,0 +1,14 @@
+error: invalid digit for a base 8 literal
+  --> $DIR/macro_rules-unmatchable-literals.rs:6:12
+   |
+LL |     ( 0o1238 ) => {};
+   |            ^
+
+error: invalid digit for a base 2 literal
+  --> $DIR/macro_rules-unmatchable-literals.rs:10:11
+   |
+LL |     ( 0b012 ) => {};
+   |           ^
+
+error: aborting due to 2 previous errors
+