From 880b1ec9f558281facc0757cbe8ab321564cb17b Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 19 Oct 2011 18:04:44 -0700 Subject: [PATCH] Fail nicer when the parser doesn't find an expected string literal Closes #1028 --- src/comp/syntax/parse/parser.rs | 6 ++++-- src/test/compile-fail/mod-name-non-str.rc | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/mod-name-non-str.rc diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index f38d0f9cc77e..3b53dbc89fc1 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -2489,8 +2489,10 @@ fn parse_crate_mod(p: parser, _cfg: ast::crate_cfg) -> @ast::crate { fn parse_str(p: parser) -> str { alt p.peek() { - token::LIT_STR(s) { p.bump(); ret p.get_str(s); } - _ { fail; } + token::LIT_STR(s) { p.bump(); p.get_str(s) } + _ { + p.fatal("expected string literal") + } } } diff --git a/src/test/compile-fail/mod-name-non-str.rc b/src/test/compile-fail/mod-name-non-str.rc new file mode 100644 index 000000000000..cf2efcea47c2 --- /dev/null +++ b/src/test/compile-fail/mod-name-non-str.rc @@ -0,0 +1,3 @@ +// error-pattern: expected string literal +// Issue #1028 +mod ncurses = x; \ No newline at end of file