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:
2123
2224extern crate rustc_ast;
2325extern crate rustc_ast_pretty;
24- extern crate rustc_data_structures;
2526extern crate rustc_parse;
2627extern crate rustc_session;
2728extern crate rustc_span;
@@ -32,28 +33,17 @@ extern crate thin_vec;
3233#[ allow( unused_extern_crates) ]
3334extern crate rustc_driver;
3435
36+ use parser:: parse_expr;
3537use rustc_ast:: mut_visit:: { visit_clobber, MutVisitor } ;
3638use rustc_ast:: ptr:: P ;
3739use rustc_ast:: * ;
3840use rustc_ast_pretty:: pprust;
39- use rustc_parse:: { new_parser_from_source_str, unwrap_or_emit_fatal} ;
4041use rustc_session:: parse:: ParseSess ;
4142use rustc_span:: source_map:: Spanned ;
4243use rustc_span:: symbol:: Ident ;
43- use rustc_span:: { FileName , DUMMY_SP } ;
44+ use rustc_span:: DUMMY_SP ;
4445use 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
5848fn expr ( kind : ExprKind ) -> P < Expr > {
5949 P ( Expr { id : DUMMY_NODE_ID , kind, span : DUMMY_SP , attrs : AttrVec :: new ( ) , tokens : None } )
0 commit comments