about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-10-24 11:55:03 -0400
committerNiko Matsakis <niko@alum.mit.edu>2017-10-31 12:41:37 -0400
commitbd2511652fec706c306a3c11742e69756a4d0fb1 (patch)
tree4202f141383c76daf12c9997d7c1be307aaab25d
parent16b5f244fb21ebbec2bf3a27820de44a56fbd8b0 (diff)
downloadrust-bd2511652fec706c306a3c11742e69756a4d0fb1.tar.gz
rust-bd2511652fec706c306a3c11742e69756a4d0fb1.zip
extend `dump_mir` to work for any tcx, not just global tcx
-rw-r--r--src/librustc/mir/transform.rs4
-rw-r--r--src/librustc_mir/util/pretty.rs68
2 files changed, 36 insertions, 36 deletions
diff --git a/src/librustc/mir/transform.rs b/src/librustc/mir/transform.rs
index f29405e6650..92e62b14693 100644
--- a/src/librustc/mir/transform.rs
+++ b/src/librustc/mir/transform.rs
@@ -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.
diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs
index 9f61feabe41..1d924175b21 100644
--- a/src/librustc_mir/util/pretty.rs
+++ b/src/librustc_mir/util/pretty.rs
@@ -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 @@ where
                           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 @@ where
 }
 
 /// 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, " {{")?;