]> git.lizzy.rs Git - rust.git/commitdiff
extend `dump_mir` to work for any tcx, not just global tcx
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 24 Oct 2017 15:55:03 +0000 (11:55 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 Oct 2017 16:41:37 +0000 (12:41 -0400)
src/librustc/mir/transform.rs
src/librustc_mir/util/pretty.rs

index f29405e6650518bced752cc45950d6699cdf61d7..92e62b14693f4f746c29914291a8db745db0cf9e 100644 (file)
@@ -39,13 +39,13 @@ pub enum MirSource {
     GeneratorDrop(NodeId),
 }
 
-impl<'a, 'tcx> MirSource {
+impl<'a, 'gcx, 'tcx> MirSource {
     pub fn from_local_def_id(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> MirSource {
         let id = tcx.hir.as_local_node_id(def_id).expect("mir source requires local def-id");
         Self::from_node(tcx, id)
     }
 
-    pub fn from_node(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> MirSource {
+    pub fn from_node(tcx: TyCtxt<'a, 'gcx, 'tcx>, id: NodeId) -> MirSource {
         use hir::*;
 
         // Handle constants in enum discriminants, types, and repeat expressions.
index 9f61feabe4114492063df25ad57a94f12ee14b0e..1d924175b2167dca4fd27ca849a2322b00f42059 100644 (file)
@@ -56,13 +56,13 @@ pub enum PassWhere {
 /// - `substring1&substring2,...` -- `&`-separated list of substrings
 ///   that can appear in the pass-name or the `item_path_str` for the given
 ///   node-id. If any one of the substrings match, the data is dumped out.
-pub fn dump_mir<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                             pass_num: Option<(MirSuite, MirPassIndex)>,
-                             pass_name: &str,
-                             disambiguator: &Display,
-                             source: MirSource,
-                             mir: &Mir<'tcx>,
-                             extra_data: F)
+pub fn dump_mir<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                   pass_num: Option<(MirSuite, MirPassIndex)>,
+                                   pass_name: &str,
+                                   disambiguator: &Display,
+                                   source: MirSource,
+                                   mir: &Mir<'tcx>,
+                                   extra_data: F)
 where
     F: FnMut(PassWhere, &mut Write) -> io::Result<()>
 {
@@ -77,10 +77,10 @@ pub fn dump_mir<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                           disambiguator, source, mir, extra_data);
 }
 
-pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                              pass_name: &str,
-                              source: MirSource)
-                              -> bool {
+pub fn dump_enabled<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                    pass_name: &str,
+                                    source: MirSource)
+                                    -> bool {
     let filters = match tcx.sess.opts.debugging_opts.dump_mir {
         None => return false,
         Some(ref filters) => filters,
@@ -101,14 +101,14 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 // `item_path_str()` would otherwise trigger `type_of`, and this can
 // run while we are already attempting to evaluate `type_of`.
 
-fn dump_matched_mir_node<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                      pass_num: Option<(MirSuite, MirPassIndex)>,
-                                      pass_name: &str,
-                                      node_path: &str,
-                                      disambiguator: &Display,
-                                      source: MirSource,
-                                      mir: &Mir<'tcx>,
-                                      mut extra_data: F)
+fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                            pass_num: Option<(MirSuite, MirPassIndex)>,
+                                            pass_name: &str,
+                                            node_path: &str,
+                                            disambiguator: &Display,
+                                            source: MirSource,
+                                            mir: &Mir<'tcx>,
+                                            mut extra_data: F)
 where
     F: FnMut(PassWhere, &mut Write) -> io::Result<()>
 {
@@ -161,10 +161,10 @@ fn dump_matched_mir_node<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 /// Write out a human-readable textual representation for the given MIR.
-pub fn write_mir_pretty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                  single: Option<DefId>,
-                                  w: &mut Write)
-                                  -> io::Result<()>
+pub fn write_mir_pretty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                        single: Option<DefId>,
+                                        w: &mut Write)
+                                        -> io::Result<()>
 {
     writeln!(w, "// WARNING: This output format is intended for human consumers only")?;
     writeln!(w, "// and is subject to change without notice. Knock yourself out.")?;
@@ -192,12 +192,12 @@ pub fn write_mir_pretty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     Ok(())
 }
 
-pub fn write_mir_fn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                 src: MirSource,
-                                 mir: &Mir<'tcx>,
-                                 extra_data: &mut F,
-                                 w: &mut Write)
-                                 -> io::Result<()>
+pub fn write_mir_fn<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                       src: MirSource,
+                                       mir: &Mir<'tcx>,
+                                       extra_data: &mut F,
+                                       w: &mut Write)
+                                       -> io::Result<()>
 where
     F: FnMut(PassWhere, &mut Write) -> io::Result<()>
 {
@@ -321,11 +321,11 @@ fn write_scope_tree(tcx: TyCtxt,
 
 /// Write out a human-readable textual representation of the MIR's `fn` type and the types of its
 /// local variables (both user-defined bindings and compiler temporaries).
-pub fn write_mir_intro<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                             src: MirSource,
-                             mir: &Mir,
-                             w: &mut Write)
-                             -> io::Result<()> {
+pub fn write_mir_intro<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
+                                       src: MirSource,
+                                       mir: &Mir,
+                                       w: &mut Write)
+                                       -> io::Result<()> {
     write_mir_sig(tcx, src, mir, w)?;
     writeln!(w, " {{")?;