]> git.lizzy.rs Git - rust.git/commitdiff
Prefer queries over Compiler methods
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Wed, 7 Dec 2022 11:55:29 +0000 (11:55 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 23 Jan 2023 10:35:21 +0000 (10:35 +0000)
compiler/rustc_driver/src/lib.rs
compiler/rustc_driver/src/pretty.rs

index d00a68471bb773d3ea03798ba094389535b2c4f6..862931da00998295113ae80ba1ecc0c7a845eed7 100644 (file)
@@ -296,9 +296,8 @@ fn run_compiler(
 
             if let Some(ppm) = &sess.opts.pretty {
                 if ppm.needs_ast_map() {
-                    let expanded_crate = queries.expansion()?.borrow().0.clone();
                     queries.global_ctxt()?.enter(|tcx| {
-                        pretty::print_after_hir_lowering(tcx, &*expanded_crate, *ppm);
+                        pretty::print_after_hir_lowering(tcx, *ppm);
                         Ok(())
                     })?;
                 } else {
index ae3ac8625b1862ca109c1a216329268abc6a6557..022051e008e32cfa192c60e88655f2c6f42670ae 100644 (file)
@@ -403,7 +403,7 @@ pub fn print_after_parsing(sess: &Session, krate: &ast::Crate, ppm: PpMode) {
     write_or_print(&out, sess);
 }
 
-pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm: PpMode) {
+pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, ppm: PpMode) {
     if ppm.needs_analysis() {
         abort_on_err(print_with_analysis(tcx, ppm), tcx.sess);
         return;
@@ -420,7 +420,7 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm
                 let parse = &sess.parse_sess;
                 pprust::print_crate(
                     sess.source_map(),
-                    krate,
+                    &tcx.resolver_for_lowering(()).borrow().1,
                     src_name,
                     src,
                     annotation.pp_ann(),
@@ -433,7 +433,7 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm
 
         AstTree(PpAstTreeMode::Expanded) => {
             debug!("pretty-printing expanded AST");
-            format!("{krate:#?}")
+            format!("{:#?}", tcx.resolver_for_lowering(()).borrow().1)
         }
 
         Hir(s) => call_with_pp_support_hir(&s, tcx, move |annotation, hir_map| {