Skip to content

Commit

Permalink
Switch pretty-printer roundtrip test to better parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 21, 2024
1 parent b100d8e commit ba5b6f3
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/ui-fulldeps/pprust-expr-roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
extern crate rustc_ast;
extern crate rustc_ast_pretty;
extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_parse;
extern crate rustc_session;
extern crate rustc_span;
Expand All @@ -32,27 +33,20 @@ extern crate thin_vec;
#[allow(unused_extern_crates)]
extern crate rustc_driver;

#[path = "auxiliary/parser.rs"]
mod parser;

use rustc_ast::mut_visit::{visit_clobber, MutVisitor};
use rustc_ast::ptr::P;
use rustc_ast::*;
use rustc_ast_pretty::pprust;
use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident;
use rustc_span::{FileName, DUMMY_SP};
use rustc_span::DUMMY_SP;
use thin_vec::{thin_vec, ThinVec};

fn parse_expr(psess: &ParseSess, src: &str) -> Option<P<Expr>> {
let src_as_string = src.to_string();

let mut p = unwrap_or_emit_fatal(new_parser_from_source_str(
psess,
FileName::Custom(src_as_string.clone()),
src_as_string,
));
p.parse_expr().map_err(|e| e.cancel()).ok()
}
use crate::parser::parse_expr;

// Helper functions for building exprs
fn expr(kind: ExprKind) -> P<Expr> {
Expand Down

0 comments on commit ba5b6f3

Please sign in to comment.