Skip to content

Commit ed6c6c9

Browse files
committed
Disallow underscore suffix for string-like literals.
1 parent 94497b7 commit ed6c6c9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,7 @@ impl<'a> StringReader<'a> {
479479
}
480480

481481
self.with_str_from(start, |string| {
482-
if string == "_" {
483-
None
484-
} else {
485-
Some(Symbol::intern(string))
486-
}
482+
Some(Symbol::intern(string))
487483
})
488484
}
489485

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let a = "Foo"_; //~ ERROR string literal with a suffix is invalid
13+
}

0 commit comments

Comments
 (0)