summary refs log tree commit diff
path: root/src/test/parse-fail
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-03-31 00:27:13 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-03-31 12:16:42 +1100
commit606f50c46dd9a3852d36456d2015e1ccf832642e (patch)
tree1c992543bb91d02c72328b9021202a9fdcdba01a /src/test/parse-fail
parentf00264074fb8f7e3b603eb3469822813632a6d30 (diff)
downloadrust-606f50c46dd9a3852d36456d2015e1ccf832642e.tar.gz
rust-606f50c46dd9a3852d36456d2015e1ccf832642e.zip
Lex binary and octal literals more eagerly.
Previously 0b12 was considered two tokens, 0b1 and 2, as 2 isn't a valid
base 2 digit. This patch changes that to collapse them into one (and
makes `0b12` etc. an error: 2 isn't a valid base 2 digit).

This may break some macro invocations of macros with `tt` (or syntax
extensions) that rely on adjacent digits being separate tokens and hence
is a

[breaking-change]

The fix is to separate the tokens, e.g. `0b12` -> `0b1 2`.

cc https://github.com/rust-lang/rfcs/pull/879
Diffstat (limited to 'src/test/parse-fail')
-rw-r--r--src/test/parse-fail/issue-1802-1.rs2
-rw-r--r--src/test/parse-fail/lex-bad-binary-literal.rs21
-rw-r--r--src/test/parse-fail/lex-bad-octal-literal.rs14
3 files changed, 36 insertions, 1 deletions
diff --git a/src/test/parse-fail/issue-1802-1.rs b/src/test/parse-fail/issue-1802-1.rs
index 8ce99f517c4..00fb2808faa 100644
--- a/src/test/parse-fail/issue-1802-1.rs
+++ b/src/test/parse-fail/issue-1802-1.rs
@@ -10,5 +10,5 @@
 
 // error-pattern:no valid digits found for number
 fn main() {
-    log(error, 0b42);
+    log(error, 0b);
 }
diff --git a/src/test/parse-fail/lex-bad-binary-literal.rs b/src/test/parse-fail/lex-bad-binary-literal.rs
new file mode 100644
index 00000000000..e92000c54ba
--- /dev/null
+++ b/src/test/parse-fail/lex-bad-binary-literal.rs
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    0b121; //~ ERROR invalid digit for a base 2 literal
+    0b10_10301; //~ ERROR invalid digit for a base 2 literal
+    0b30; //~ ERROR invalid digit for a base 2 literal
+    0b41; //~ ERROR invalid digit for a base 2 literal
+    0b5; //~ ERROR invalid digit for a base 2 literal
+    0b6; //~ ERROR invalid digit for a base 2 literal
+    0b7; //~ ERROR invalid digit for a base 2 literal
+    0b8; //~ ERROR invalid digit for a base 2 literal
+    0b9; //~ ERROR invalid digit for a base 2 literal
+}
diff --git a/src/test/parse-fail/lex-bad-octal-literal.rs b/src/test/parse-fail/lex-bad-octal-literal.rs
new file mode 100644
index 00000000000..bf9880cb6cf
--- /dev/null
+++ b/src/test/parse-fail/lex-bad-octal-literal.rs
@@ -0,0 +1,14 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    0o18; //~ ERROR invalid digit for a base 8 literal
+    0o1234_9_5670;  //~ ERROR invalid digit for a base 8 literal
+}