]> git.lizzy.rs Git - rust.git/commitdiff
Disallow underscore suffix for string-like literals.
authorMasaki Hara <ackie.h.gmai@gmail.com>
Sun, 14 May 2017 12:37:50 +0000 (21:37 +0900)
committerMasaki Hara <ackie.h.gmai@gmail.com>
Sun, 14 May 2017 12:37:50 +0000 (21:37 +0900)
src/libsyntax/parse/lexer/mod.rs
src/test/parse-fail/underscore-suffix-for-string.rs [new file with mode: 0644]

index a83b19c7334e7b70b33dac1ad6db07d5b3c3ae7d..480049f845c3553834db4f12901b9c4eb50dc643 100644 (file)
@@ -479,11 +479,7 @@ fn scan_optional_raw_name(&mut self) -> Option<ast::Name> {
         }
 
         self.with_str_from(start, |string| {
-            if string == "_" {
-                None
-            } else {
-                Some(Symbol::intern(string))
-            }
+            Some(Symbol::intern(string))
         })
     }
 
diff --git a/src/test/parse-fail/underscore-suffix-for-string.rs b/src/test/parse-fail/underscore-suffix-for-string.rs
new file mode 100644 (file)
index 0000000..a19bbe0
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2017 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() {
+    let a = "Foo"_; //~ ERROR string literal with a suffix is invalid
+}