From 54875908607aeba57477e117a08e5f8f3611bf76 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 10 Feb 2012 13:22:15 -0700 Subject: 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.) --- src/comp/syntax/parse/parser.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/comp/syntax/parse') 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(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; -- cgit 1.4.1-3-g733a5