about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-10-19 18:04:44 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-19 18:04:44 -0700
commit880b1ec9f558281facc0757cbe8ab321564cb17b (patch)
treeb1e5c169e5a689029ba27173128cd4703f5fcf27 /src
parent15d33f7957ff62f8be4e53409c7d131c2c32dfef (diff)
Fail nicer when the parser doesn't find an expected string literal
Closes #1028
Diffstat (limited to 'src')
-rw-r--r--src/comp/syntax/parse/parser.rs6
-rw-r--r--src/test/compile-fail/mod-name-non-str.rc3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index f38d0f9cc77..3b53dbc89fc 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 00000000000..cf2efcea47c
--- /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