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.)
This commit is contained in:
parent
a803a14b56
commit
d6d7134c37
3 changed files with 51 additions and 0 deletions
|
@ -2633,6 +2633,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue