Skip to content

Commit

Permalink
Add warning cycle #42326.
Browse files Browse the repository at this point in the history
  • Loading branch information
qnighy committed May 31, 2017
1 parent ed6c6c9 commit 0b8c3de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,20 @@ impl<'a> StringReader<'a> {
}

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))
}
})
}

Expand Down
9 changes: 8 additions & 1 deletion src/test/parse-fail/underscore-suffix-for-string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0b8c3de

Please sign in to comment.