Skip to content

Commit 822e806

Browse files
committed
Switch pretty-printer roundtrip test to better parser
1 parent 65ba6ac commit 822e806

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

tests/ui-fulldeps/pprust-expr-roundtrip.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ run-pass
22
//@ ignore-cross-compile
3+
//@ aux-crate: parser=parser.rs
4+
//@ edition: 2021
35

46
// The general idea of this test is to enumerate all "interesting" expressions and check that
57
// `parse(print(e)) == e` for all `e`. Here's what's interesting, for the purposes of this test:
@@ -21,7 +23,6 @@
2123

2224
extern crate rustc_ast;
2325
extern crate rustc_ast_pretty;
24-
extern crate rustc_data_structures;
2526
extern crate rustc_parse;
2627
extern crate rustc_session;
2728
extern crate rustc_span;
@@ -32,28 +33,17 @@ extern crate thin_vec;
3233
#[allow(unused_extern_crates)]
3334
extern crate rustc_driver;
3435

36+
use parser::parse_expr;
3537
use rustc_ast::mut_visit::{visit_clobber, MutVisitor};
3638
use rustc_ast::ptr::P;
3739
use rustc_ast::*;
3840
use rustc_ast_pretty::pprust;
39-
use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
4041
use rustc_session::parse::ParseSess;
4142
use rustc_span::source_map::Spanned;
4243
use rustc_span::symbol::Ident;
43-
use rustc_span::{FileName, DUMMY_SP};
44+
use rustc_span::DUMMY_SP;
4445
use thin_vec::{thin_vec, ThinVec};
4546

46-
fn parse_expr(psess: &ParseSess, src: &str) -> Option<P<Expr>> {
47-
let src_as_string = src.to_string();
48-
49-
let mut p = unwrap_or_emit_fatal(new_parser_from_source_str(
50-
psess,
51-
FileName::Custom(src_as_string.clone()),
52-
src_as_string,
53-
));
54-
p.parse_expr().map_err(|e| e.cancel()).ok()
55-
}
56-
5747
// Helper functions for building exprs
5848
fn expr(kind: ExprKind) -> P<Expr> {
5949
P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: AttrVec::new(), tokens: None })

0 commit comments

Comments
 (0)