about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorKevin Atkinson <kevina@cs.utah.edu>2012-02-10 13:22:15 -0700
committerKevin Atkinson <kevina@cs.utah.edu>2012-02-10 17:51:22 -0700
commit54875908607aeba57477e117a08e5f8f3611bf76 (patch)
treeb320d06a1d4dd91070b988df2eb2c08aecb242f5 /src/comp/syntax/parse
parent48eda22835e58ec1f14f6333e444ccc8a32244b7 (diff)
downloadrust-54875908607aeba57477e117a08e5f8f3611bf76.tar.gz
rust-54875908607aeba57477e117a08e5f8f3611bf76.zip
When parsing a source string, fail when the entire string is not parsed.
(For now only fail when parse_from_source_str is used to avoid
possible compatibility problems; parse_expr_from_source_str still
does not check.)
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 2352ac2f9db..1cfd96c97cb 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -2622,6 +2622,9 @@ fn parse_from_source_str<T>(f: fn (p: parser) -> T,
 {
     let p = new_parser_from_source_str(sess, cfg, name, ss, source);
     let r = f(p);
+    if !p.reader.is_eof() {
+        p.reader.fatal("expected end-of-string");
+    }
     sess.chpos = p.reader.chpos;
     sess.byte_pos = sess.byte_pos + p.reader.pos;
     ret r;