]> git.lizzy.rs Git - rust.git/commitdiff
Add warning cycle #42326.
authorMasaki Hara <ackie.h.gmai@gmail.com>
Wed, 31 May 2017 07:43:47 +0000 (16:43 +0900)
committerMasaki Hara <ackie.h.gmai@gmail.com>
Wed, 31 May 2017 07:43:47 +0000 (16:43 +0900)
src/libsyntax/parse/lexer/mod.rs
src/test/parse-fail/underscore-suffix-for-string.rs

index 480049f845c3553834db4f12901b9c4eb50dc643..e8fbc00d36f06a430ea00e4cb4aff8cc127eafc0 100644 (file)
@@ -479,7 +479,20 @@ fn scan_optional_raw_name(&mut self) -> Option<ast::Name> {
         }
 
         self.with_str_from(start, |string| {
-            Some(Symbol::intern(string))
+            if string == "_" {
+                self.sess.span_diagnostic
+                    .struct_span_warn(mk_sp(start, self.pos),
+                                      "underscore literal suffix is not allowed")
+                    .warn("this was previously accepted by the compiler but is \
+                          being phased out; it will become a hard error in \
+                          a future release!")
+                    .note("for more information, see issue #42326 \
+                          <https://github.com/rust-lang/rust/issues/42326>")
+                    .emit();
+                None
+            } else {
+                Some(Symbol::intern(string))
+            }
         })
     }
 
index a19bbe083770435f0510eaefbbab2f8d5b1b9afa..05de5f8e1941b7dc7ce80d4ab6f0b7b68c4f3266 100644 (file)
@@ -9,5 +9,12 @@
 // except according to those terms.
 
 fn main() {
-    let a = "Foo"_; //~ ERROR string literal with a suffix is invalid
+    let _ = "Foo"_;
+    //~^ WARNING underscore literal suffix is not allowed
+    //~| WARNING this was previously accepted
+    //~| NOTE issue #42326
 }
+
+FAIL
+//~^ ERROR
+//~| NOTE