Skip to content

Commit 880b1ec

Browse files
committed
Fail nicer when the parser doesn't find an expected string literal
Closes #1028
1 parent 15d33f7 commit 880b1ec

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,8 +2489,10 @@ fn parse_crate_mod(p: parser, _cfg: ast::crate_cfg) -> @ast::crate {
24892489

24902490
fn parse_str(p: parser) -> str {
24912491
alt p.peek() {
2492-
token::LIT_STR(s) { p.bump(); ret p.get_str(s); }
2493-
_ { fail; }
2492+
token::LIT_STR(s) { p.bump(); p.get_str(s) }
2493+
_ {
2494+
p.fatal("expected string literal")
2495+
}
24942496
}
24952497
}
24962498

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// error-pattern: expected string literal
2+
// Issue #1028
3+
mod ncurses = x;

0 commit comments

Comments
 (0)