Skip to content

Commit bfa0206

Browse files
committed
---
yaml --- r: 69375 b: refs/heads/auto c: 382b037 h: refs/heads/master i: 69373: b0bc027 69371: d3f66cb 69367: cad11ad 69359: 1def817 69343: a1b827d 69311: d2a8fed 69247: 3ffbdab 69119: 51f94d8 v: v3
1 parent 7c3e351 commit bfa0206

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 4c4cf003ea32d7617602fdbd1b2ebc8099633f06
17+
refs/heads/auto: 382b037252c213150f2a298524db2c7674804126
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libsyntax/parse/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,10 @@ mod test {
384384
span:sp(0,6)})
385385
}
386386

387-
// FIXME (#6416): For some reason, this fails and causes a test failure, even though it's
388-
// marked as `#[should_fail]`.
389-
/*#[should_fail]
387+
#[should_fail]
390388
#[test] fn bad_path_expr_1() {
391389
string_to_expr(@"::abc::def::return");
392-
}*/
390+
}
393391

394392
#[test] fn string_to_tts_1 () {
395393
let (tts,_ps) = string_to_tts_and_sess(@"fn a (b : int) { b; }");

branches/auto/src/libsyntax/util/parser_testing.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,46 @@ pub fn string_to_parser(source_str: @str) -> Parser {
3333
p
3434
}
3535

36+
fn with_error_checking_parse<T>(s: @str, f: &fn(&mut Parser) -> T) -> T {
37+
let mut p = string_to_parser(s);
38+
let x = f(&mut p);
39+
p.abort_if_errors();
40+
x
41+
}
42+
3643
pub fn string_to_crate (source_str : @str) -> @ast::Crate {
37-
string_to_parser(source_str).parse_crate_mod()
44+
do with_error_checking_parse(source_str) |p| {
45+
p.parse_crate_mod()
46+
}
3847
}
3948

4049
// parse a string, return an expr
4150
pub fn string_to_expr (source_str : @str) -> @ast::expr {
42-
string_to_parser(source_str).parse_expr()
51+
do with_error_checking_parse(source_str) |p| {
52+
p.parse_expr()
53+
}
4354
}
4455

4556
// parse a string, return an item
4657
pub fn string_to_item (source_str : @str) -> Option<@ast::item> {
47-
string_to_parser(source_str).parse_item(~[])
58+
do with_error_checking_parse(source_str) |p| {
59+
p.parse_item(~[])
60+
}
4861
}
4962

5063
// parse a string, return an item and the ParseSess
5164
pub fn string_to_item_and_sess (source_str : @str) -> (Option<@ast::item>,@mut ParseSess) {
5265
let (p,ps) = string_to_parser_and_sess(source_str);
53-
(p.parse_item(~[]),ps)
66+
let io = p.parse_item(~[]);
67+
p.abort_if_errors();
68+
(io,ps)
5469
}
5570

5671
// parse a string, return a stmt
5772
pub fn string_to_stmt(source_str : @str) -> @ast::stmt {
58-
string_to_parser(source_str).parse_stmt(~[])
73+
do with_error_checking_parse(source_str) |p| {
74+
p.parse_stmt(~[])
75+
}
5976
}
6077

6178
// parse a string, return a pat. Uses "irrefutable"... which doesn't

0 commit comments

Comments
 (0)