Skip to content

Commit bd25116

Browse files
committed
extend dump_mir to work for any tcx, not just global tcx
1 parent 16b5f24 commit bd25116

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

src/librustc/mir/transform.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub enum MirSource {
3939
GeneratorDrop(NodeId),
4040
}
4141

42-
impl<'a, 'tcx> MirSource {
42+
impl<'a, 'gcx, 'tcx> MirSource {
4343
pub fn from_local_def_id(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> MirSource {
4444
let id = tcx.hir.as_local_node_id(def_id).expect("mir source requires local def-id");
4545
Self::from_node(tcx, id)
4646
}
4747

48-
pub fn from_node(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> MirSource {
48+
pub fn from_node(tcx: TyCtxt<'a, 'gcx, 'tcx>, id: NodeId) -> MirSource {
4949
use hir::*;
5050

5151
// Handle constants in enum discriminants, types, and repeat expressions.

src/librustc_mir/util/pretty.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ pub enum PassWhere {
5656
/// - `substring1&substring2,...` -- `&`-separated list of substrings
5757
/// that can appear in the pass-name or the `item_path_str` for the given
5858
/// node-id. If any one of the substrings match, the data is dumped out.
59-
pub fn dump_mir<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
60-
pass_num: Option<(MirSuite, MirPassIndex)>,
61-
pass_name: &str,
62-
disambiguator: &Display,
63-
source: MirSource,
64-
mir: &Mir<'tcx>,
65-
extra_data: F)
59+
pub fn dump_mir<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
60+
pass_num: Option<(MirSuite, MirPassIndex)>,
61+
pass_name: &str,
62+
disambiguator: &Display,
63+
source: MirSource,
64+
mir: &Mir<'tcx>,
65+
extra_data: F)
6666
where
6767
F: FnMut(PassWhere, &mut Write) -> io::Result<()>
6868
{
@@ -77,10 +77,10 @@ where
7777
disambiguator, source, mir, extra_data);
7878
}
7979

80-
pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
81-
pass_name: &str,
82-
source: MirSource)
83-
-> bool {
80+
pub fn dump_enabled<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
81+
pass_name: &str,
82+
source: MirSource)
83+
-> bool {
8484
let filters = match tcx.sess.opts.debugging_opts.dump_mir {
8585
None => return false,
8686
Some(ref filters) => filters,
@@ -101,14 +101,14 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
101101
// `item_path_str()` would otherwise trigger `type_of`, and this can
102102
// run while we are already attempting to evaluate `type_of`.
103103

104-
fn dump_matched_mir_node<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
105-
pass_num: Option<(MirSuite, MirPassIndex)>,
106-
pass_name: &str,
107-
node_path: &str,
108-
disambiguator: &Display,
109-
source: MirSource,
110-
mir: &Mir<'tcx>,
111-
mut extra_data: F)
104+
fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
105+
pass_num: Option<(MirSuite, MirPassIndex)>,
106+
pass_name: &str,
107+
node_path: &str,
108+
disambiguator: &Display,
109+
source: MirSource,
110+
mir: &Mir<'tcx>,
111+
mut extra_data: F)
112112
where
113113
F: FnMut(PassWhere, &mut Write) -> io::Result<()>
114114
{
@@ -161,10 +161,10 @@ where
161161
}
162162

163163
/// Write out a human-readable textual representation for the given MIR.
164-
pub fn write_mir_pretty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
165-
single: Option<DefId>,
166-
w: &mut Write)
167-
-> io::Result<()>
164+
pub fn write_mir_pretty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
165+
single: Option<DefId>,
166+
w: &mut Write)
167+
-> io::Result<()>
168168
{
169169
writeln!(w, "// WARNING: This output format is intended for human consumers only")?;
170170
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>,
192192
Ok(())
193193
}
194194

195-
pub fn write_mir_fn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
196-
src: MirSource,
197-
mir: &Mir<'tcx>,
198-
extra_data: &mut F,
199-
w: &mut Write)
200-
-> io::Result<()>
195+
pub fn write_mir_fn<'a, 'gcx, 'tcx, F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
196+
src: MirSource,
197+
mir: &Mir<'tcx>,
198+
extra_data: &mut F,
199+
w: &mut Write)
200+
-> io::Result<()>
201201
where
202202
F: FnMut(PassWhere, &mut Write) -> io::Result<()>
203203
{
@@ -321,11 +321,11 @@ fn write_scope_tree(tcx: TyCtxt,
321321

322322
/// Write out a human-readable textual representation of the MIR's `fn` type and the types of its
323323
/// local variables (both user-defined bindings and compiler temporaries).
324-
pub fn write_mir_intro<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
325-
src: MirSource,
326-
mir: &Mir,
327-
w: &mut Write)
328-
-> io::Result<()> {
324+
pub fn write_mir_intro<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
325+
src: MirSource,
326+
mir: &Mir,
327+
w: &mut Write)
328+
-> io::Result<()> {
329329
write_mir_sig(tcx, src, mir, w)?;
330330
writeln!(w, " {{")?;
331331

0 commit comments

Comments
 (0)