Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.)
- Loading branch information
1 parent
a803a14
commit d6d7134
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// xfail-pretty | ||
|
||
use std; | ||
use rustc; | ||
|
||
import rustc::*; | ||
import std::io::*; | ||
|
||
import rustc::driver::diagnostic; | ||
import rustc::syntax::ast; | ||
import rustc::syntax::codemap; | ||
import rustc::syntax::parse::parser; | ||
import rustc::syntax::print::*; | ||
|
||
fn new_parse_sess() -> parser::parse_sess { | ||
fail; | ||
} | ||
|
||
iface fake_ext_ctxt { | ||
fn session() -> fake_session; | ||
} | ||
|
||
type fake_options = {cfg: ast::crate_cfg}; | ||
|
||
type fake_session = {opts: @fake_options, | ||
parse_sess: parser::parse_sess}; | ||
|
||
impl of fake_ext_ctxt for fake_session { | ||
fn session() -> fake_session {self} | ||
} | ||
|
||
fn mk_ctxt() -> fake_ext_ctxt { | ||
let opts : fake_options = {cfg: []}; | ||
{opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt | ||
} | ||
|
||
|
||
fn main() { | ||
let ext_cx = mk_ctxt(); | ||
|
||
let stmt = #ast(stmt){let x int = 20;}; //! ERROR expected end-of-string | ||
check_pp(*stmt, pprust::print_stmt, ""); | ||
} | ||
|
||
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) { | ||
fail; | ||
} | ||
|