1
1
//@ run-pass
2
2
//@ ignore-cross-compile
3
+ //@ aux-crate: parser=parser.rs
4
+ //@ edition: 2021
3
5
4
6
// The general idea of this test is to enumerate all "interesting" expressions and check that
5
7
// `parse(print(e)) == e` for all `e`. Here's what's interesting, for the purposes of this test:
21
23
22
24
extern crate rustc_ast;
23
25
extern crate rustc_ast_pretty;
24
- extern crate rustc_data_structures;
25
26
extern crate rustc_parse;
26
27
extern crate rustc_session;
27
28
extern crate rustc_span;
@@ -32,28 +33,17 @@ extern crate thin_vec;
32
33
#[ allow( unused_extern_crates) ]
33
34
extern crate rustc_driver;
34
35
36
+ use parser:: parse_expr;
35
37
use rustc_ast:: mut_visit:: { visit_clobber, MutVisitor } ;
36
38
use rustc_ast:: ptr:: P ;
37
39
use rustc_ast:: * ;
38
40
use rustc_ast_pretty:: pprust;
39
- use rustc_parse:: { new_parser_from_source_str, unwrap_or_emit_fatal} ;
40
41
use rustc_session:: parse:: ParseSess ;
41
42
use rustc_span:: source_map:: Spanned ;
42
43
use rustc_span:: symbol:: Ident ;
43
- use rustc_span:: { FileName , DUMMY_SP } ;
44
+ use rustc_span:: DUMMY_SP ;
44
45
use thin_vec:: { thin_vec, ThinVec } ;
45
46
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
-
57
47
// Helper functions for building exprs
58
48
fn expr ( kind : ExprKind ) -> P < Expr > {
59
49
P ( Expr { id : DUMMY_NODE_ID , kind, span : DUMMY_SP , attrs : AttrVec :: new ( ) , tokens : None } )
0 commit comments