diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-26 14:27:02 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-26 14:31:15 +0000 |
| commit | 380ca0c9e6efe2ccc6f35abef7931f7a9581bf70 (patch) | |
| tree | b71f54a52cbcf853e12acba194632ca4d148a12e | |
| parent | 70fd012439d75fd6ce561a6518b9b8fd399f455f (diff) | |
| download | rust-380ca0c9e6efe2ccc6f35abef7931f7a9581bf70.tar.gz rust-380ca0c9e6efe2ccc6f35abef7931f7a9581bf70.zip | |
Move THIR printing to rustc_mir_build.
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/mod.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/print.rs (renamed from compiler/rustc_middle/src/thir/print.rs) | 27 |
5 files changed, 22 insertions, 31 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 6f2dac46753..5f320708c84 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -29,7 +29,6 @@ use rustc_target::asm::InlineAsmRegOrRegClass; use std::fmt; use std::ops::Index; -pub mod print; pub mod visit; macro_rules! thir_with_elements { diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index fbc130501f9..e10a264d385 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -38,6 +38,6 @@ pub fn provide(providers: &mut Providers) { providers.thir_check_unsafety = check_unsafety::thir_check_unsafety; providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg; providers.thir_body = thir::cx::thir_body; - providers.thir_tree = thir::cx::thir_tree; - providers.thir_flat = thir::cx::thir_flat; + providers.thir_tree = thir::print::thir_tree; + providers.thir_flat = thir::print::thir_flat; } diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 20af60a511e..b5e819db5f8 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -52,23 +52,6 @@ pub(crate) fn thir_body( Ok((tcx.alloc_steal_thir(cx.thir), expr)) } -pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam<LocalDefId>) -> String { - match thir_body(tcx, owner_def) { - Ok((thir, _)) => { - let thir = thir.steal(); - tcx.thir_tree_representation(&thir) - } - Err(_) => "error".into(), - } -} - -pub(crate) fn thir_flat(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam<LocalDefId>) -> String { - match thir_body(tcx, owner_def) { - Ok((thir, _)) => format!("{:#?}", thir.steal()), - Err(_) => "error".into(), - } -} - struct Cx<'tcx> { tcx: TyCtxt<'tcx>, thir: Thir<'tcx>, diff --git a/compiler/rustc_mir_build/src/thir/mod.rs b/compiler/rustc_mir_build/src/thir/mod.rs index e0e6ac26654..ca26cc13b5e 100644 --- a/compiler/rustc_mir_build/src/thir/mod.rs +++ b/compiler/rustc_mir_build/src/thir/mod.rs @@ -5,9 +5,7 @@ //! structures. pub(crate) mod constant; - pub(crate) mod cx; - pub(crate) mod pattern; - +pub(crate) mod print; mod util; diff --git a/compiler/rustc_middle/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs index 60b903e9906..8028227aafd 100644 --- a/compiler/rustc_middle/src/thir/print.rs +++ b/compiler/rustc_mir_build/src/thir/print.rs @@ -1,13 +1,24 @@ -use crate::thir::*; -use crate::ty::{self, TyCtxt}; - +use rustc_middle::thir::*; +use rustc_middle::ty::{self, TyCtxt}; +use rustc_span::def_id::LocalDefId; use std::fmt::{self, Write}; -impl<'tcx> TyCtxt<'tcx> { - pub fn thir_tree_representation<'a>(self, thir: &'a Thir<'tcx>) -> String { - let mut printer = ThirPrinter::new(thir); - printer.print(); - printer.into_buffer() +pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam<LocalDefId>) -> String { + match super::cx::thir_body(tcx, owner_def) { + Ok((thir, _)) => { + let thir = thir.steal(); + let mut printer = ThirPrinter::new(&thir); + printer.print(); + printer.into_buffer() + } + Err(_) => "error".into(), + } +} + +pub(crate) fn thir_flat(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam<LocalDefId>) -> String { + match super::cx::thir_body(tcx, owner_def) { + Ok((thir, _)) => format!("{:#?}", thir.steal()), + Err(_) => "error".into(), } } |
