Skip to content

Commit 23f39a2

Browse files
Rollup merge of #125953 - nnethercote:streamline-nested-calls, r=lqd
Streamline `nested` calls. `TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We can call that impl, which then calls the one on `intravisit::Map`, instead of calling the one on `intravisit::Map` directly, avoiding a cast and extra references. r? `@lqd`
2 parents 7699da4 + 4798c20 commit 23f39a2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

compiler/rustc_driver_impl/src/pretty.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use rustc_ast as ast;
44
use rustc_ast_pretty::pprust as pprust_ast;
55
use rustc_errors::FatalError;
6-
use rustc_hir as hir;
76
use rustc_hir_pretty as pprust_hir;
87
use rustc_middle::bug;
98
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
@@ -70,11 +69,7 @@ struct HirIdentifiedAnn<'tcx> {
7069

7170
impl<'tcx> pprust_hir::PpAnn for HirIdentifiedAnn<'tcx> {
7271
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
73-
pprust_hir::PpAnn::nested(
74-
&(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>),
75-
state,
76-
nested,
77-
)
72+
self.tcx.nested(state, nested)
7873
}
7974

8075
fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
@@ -152,8 +147,7 @@ impl<'tcx> pprust_hir::PpAnn for HirTypedAnn<'tcx> {
152147
if let pprust_hir::Nested::Body(id) = nested {
153148
self.maybe_typeck_results.set(Some(self.tcx.typeck_body(id)));
154149
}
155-
let pp_ann = &(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>);
156-
pprust_hir::PpAnn::nested(pp_ann, state, nested);
150+
self.tcx.nested(state, nested);
157151
self.maybe_typeck_results.set(old_maybe_typeck_results);
158152
}
159153

0 commit comments

Comments
 (0)