Skip to content

Commit 00e2182

Browse files
committed
Rename some things.
- Rename `pprust` as `pprust_ast`, to align with `pprust_hir`. - Rename `PrinterSupport` as `AstPrinterSupport`, to align with `HirPrinterSupport`.
1 parent 475c71d commit 00e2182

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! The various pretty-printing routines.
22
33
use rustc_ast as ast;
4-
use rustc_ast_pretty::pprust;
4+
use rustc_ast_pretty::pprust as pprust_ast;
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_hir as hir;
77
use rustc_hir_pretty as pprust_hir;
@@ -26,26 +26,25 @@ use crate::abort_on_err;
2626
// analysis results) on to the chosen pretty-printer, along with the
2727
// `&PpAnn` object.
2828
//
29-
// Note that since the `&PrinterSupport` is freshly constructed on each
29+
// Note that since the `&AstPrinterSupport` is freshly constructed on each
3030
// call, it would not make sense to try to attach the lifetime of `self`
3131
// to the lifetime of the `&PrinterObject`.
3232

33-
/// Constructs a `PrinterSupport` object and passes it to `f`.
34-
fn call_with_pp_support<'tcx, A, F>(
33+
/// Constructs an `AstPrinterSupport` object and passes it to `f`.
34+
fn call_with_pp_support_ast<'tcx, A, F>(
3535
ppmode: &PpSourceMode,
3636
sess: &'tcx Session,
3737
tcx: Option<TyCtxt<'tcx>>,
3838
f: F,
3939
) -> A
4040
where
41-
F: FnOnce(&dyn PrinterSupport) -> A,
41+
F: FnOnce(&dyn AstPrinterSupport) -> A,
4242
{
4343
match *ppmode {
4444
Normal | Expanded => {
4545
let annotation = NoAnn { sess, tcx };
4646
f(&annotation)
4747
}
48-
4948
Identified | ExpandedIdentified => {
5049
let annotation = IdentifiedAnnotation { sess, tcx };
5150
f(&annotation)
@@ -65,7 +64,6 @@ where
6564
let annotation = NoAnn { sess: tcx.sess, tcx: Some(tcx) };
6665
f(&annotation, tcx.hir())
6766
}
68-
6967
PpHirMode::Identified => {
7068
let annotation = IdentifiedAnnotation { sess: tcx.sess, tcx: Some(tcx) };
7169
f(&annotation, tcx.hir())
@@ -79,7 +77,7 @@ where
7977
}
8078
}
8179

82-
trait PrinterSupport: pprust::PpAnn {
80+
trait AstPrinterSupport: pprust_ast::PpAnn {
8381
/// Provides a uniform interface for re-extracting a reference to a
8482
/// `Session` from a value that now owns it.
8583
fn sess(&self) -> &Session;
@@ -88,7 +86,7 @@ trait PrinterSupport: pprust::PpAnn {
8886
///
8987
/// (Rust does not yet support upcasting from a trait object to
9088
/// an object for one of its supertraits.)
91-
fn pp_ann(&self) -> &dyn pprust::PpAnn;
89+
fn pp_ann(&self) -> &dyn pprust_ast::PpAnn;
9290
}
9391

9492
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
@@ -112,12 +110,12 @@ struct NoAnn<'hir> {
112110
tcx: Option<TyCtxt<'hir>>,
113111
}
114112

115-
impl<'hir> PrinterSupport for NoAnn<'hir> {
113+
impl<'hir> AstPrinterSupport for NoAnn<'hir> {
116114
fn sess(&self) -> &Session {
117115
self.sess
118116
}
119117

120-
fn pp_ann(&self) -> &dyn pprust::PpAnn {
118+
fn pp_ann(&self) -> &dyn pprust_ast::PpAnn {
121119
self
122120
}
123121
}
@@ -136,7 +134,7 @@ impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
136134
}
137135
}
138136

139-
impl<'hir> pprust::PpAnn for NoAnn<'hir> {}
137+
impl<'hir> pprust_ast::PpAnn for NoAnn<'hir> {}
140138
impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> {
141139
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
142140
if let Some(tcx) = self.tcx {
@@ -150,44 +148,46 @@ struct IdentifiedAnnotation<'hir> {
150148
tcx: Option<TyCtxt<'hir>>,
151149
}
152150

153-
impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
151+
impl<'hir> AstPrinterSupport for IdentifiedAnnotation<'hir> {
154152
fn sess(&self) -> &Session {
155153
self.sess
156154
}
157155

158-
fn pp_ann(&self) -> &dyn pprust::PpAnn {
156+
fn pp_ann(&self) -> &dyn pprust_ast::PpAnn {
159157
self
160158
}
161159
}
162160

163-
impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> {
164-
fn pre(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) {
165-
if let pprust::AnnNode::Expr(_) = node {
161+
impl<'hir> pprust_ast::PpAnn for IdentifiedAnnotation<'hir> {
162+
fn pre(&self, s: &mut pprust_ast::State<'_>, node: pprust_ast::AnnNode<'_>) {
163+
if let pprust_ast::AnnNode::Expr(_) = node {
166164
s.popen();
167165
}
168166
}
169-
fn post(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) {
167+
fn post(&self, s: &mut pprust_ast::State<'_>, node: pprust_ast::AnnNode<'_>) {
170168
match node {
171-
pprust::AnnNode::Crate(_) | pprust::AnnNode::Ident(_) | pprust::AnnNode::Name(_) => {}
169+
pprust_ast::AnnNode::Crate(_)
170+
| pprust_ast::AnnNode::Ident(_)
171+
| pprust_ast::AnnNode::Name(_) => {}
172172

173-
pprust::AnnNode::Item(item) => {
173+
pprust_ast::AnnNode::Item(item) => {
174174
s.s.space();
175175
s.synth_comment(item.id.to_string())
176176
}
177-
pprust::AnnNode::SubItem(id) => {
177+
pprust_ast::AnnNode::SubItem(id) => {
178178
s.s.space();
179179
s.synth_comment(id.to_string())
180180
}
181-
pprust::AnnNode::Block(blk) => {
181+
pprust_ast::AnnNode::Block(blk) => {
182182
s.s.space();
183183
s.synth_comment(format!("block {}", blk.id))
184184
}
185-
pprust::AnnNode::Expr(expr) => {
185+
pprust_ast::AnnNode::Expr(expr) => {
186186
s.s.space();
187187
s.synth_comment(expr.id.to_string());
188188
s.pclose()
189189
}
190-
pprust::AnnNode::Pat(pat) => {
190+
pprust_ast::AnnNode::Pat(pat) => {
191191
s.s.space();
192192
s.synth_comment(format!("pat {}", pat.id));
193193
}
@@ -256,28 +256,28 @@ struct HygieneAnnotation<'a> {
256256
sess: &'a Session,
257257
}
258258

259-
impl<'a> PrinterSupport for HygieneAnnotation<'a> {
259+
impl<'a> AstPrinterSupport for HygieneAnnotation<'a> {
260260
fn sess(&self) -> &Session {
261261
self.sess
262262
}
263263

264-
fn pp_ann(&self) -> &dyn pprust::PpAnn {
264+
fn pp_ann(&self) -> &dyn pprust_ast::PpAnn {
265265
self
266266
}
267267
}
268268

269-
impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
270-
fn post(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) {
269+
impl<'a> pprust_ast::PpAnn for HygieneAnnotation<'a> {
270+
fn post(&self, s: &mut pprust_ast::State<'_>, node: pprust_ast::AnnNode<'_>) {
271271
match node {
272-
pprust::AnnNode::Ident(&Ident { name, span }) => {
272+
pprust_ast::AnnNode::Ident(&Ident { name, span }) => {
273273
s.s.space();
274274
s.synth_comment(format!("{}{:?}", name.as_u32(), span.ctxt()))
275275
}
276-
pprust::AnnNode::Name(&name) => {
276+
pprust_ast::AnnNode::Name(&name) => {
277277
s.s.space();
278278
s.synth_comment(name.as_u32().to_string())
279279
}
280-
pprust::AnnNode::Crate(_) => {
280+
pprust_ast::AnnNode::Crate(_) => {
281281
s.s.hardbreak();
282282
let verbose = self.sess.verbose();
283283
s.synth_comment(rustc_span::hygiene::debug_hygiene_data(verbose));
@@ -366,11 +366,11 @@ pub fn print_after_parsing(sess: &Session, krate: &ast::Crate, ppm: PpMode) {
366366
let out = match ppm {
367367
Source(s) => {
368368
// Silently ignores an identified node.
369-
call_with_pp_support(&s, sess, None, move |annotation| {
369+
call_with_pp_support_ast(&s, sess, None, move |annotation| {
370370
debug!("pretty printing source code {:?}", s);
371371
let sess = annotation.sess();
372372
let parse = &sess.parse_sess;
373-
pprust::print_crate(
373+
pprust_ast::print_crate(
374374
sess.source_map(),
375375
krate,
376376
src_name,
@@ -403,11 +403,11 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, ppm: PpMode) {
403403
let out = match ppm {
404404
Source(s) => {
405405
// Silently ignores an identified node.
406-
call_with_pp_support(&s, tcx.sess, Some(tcx), move |annotation| {
406+
call_with_pp_support_ast(&s, tcx.sess, Some(tcx), move |annotation| {
407407
debug!("pretty printing source code {:?}", s);
408408
let sess = annotation.sess();
409409
let parse = &sess.parse_sess;
410-
pprust::print_crate(
410+
pprust_ast::print_crate(
411411
sess.source_map(),
412412
&tcx.resolver_for_lowering(()).borrow().1,
413413
src_name,

0 commit comments

Comments
 (0)