1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! This pass just dumps MIR at a specified point.
15 use rustc
::ty
::TyCtxt
;
17 use rustc
::mir
::transform
::{Pass, MirPass, MirPassHook, MirSource}
;
20 pub struct Marker
<'a
>(pub &'a
str);
22 impl<'b
, 'tcx
> MirPass
<'tcx
> for Marker
<'b
> {
23 fn run_pass
<'a
>(&mut self, _tcx
: TyCtxt
<'a
, 'tcx
, 'tcx
>,
24 _src
: MirSource
, _mir
: &mut Mir
<'tcx
>)
28 impl<'b
> Pass
for Marker
<'b
> {
29 fn name(&self) -> ::std
::borrow
::Cow
<'
static, str> { String::from(self.0).into() }
32 pub struct Disambiguator
<'a
> {
37 impl<'a
> fmt
::Display
for Disambiguator
<'a
> {
38 fn fmt(&self, formatter
: &mut fmt
::Formatter
) -> fmt
::Result
{
39 let title
= if self.is_after { "after" }
else { "before" }
;
40 if let Some(fmt
) = self.pass
.disambiguator() {
41 write
!(formatter
, "{}-{}", fmt
, title
)
43 write
!(formatter
, "{}", title
)
50 impl<'tcx
> MirPassHook
<'tcx
> for DumpMir
{
53 tcx
: TyCtxt
<'a
, 'tcx
, 'tcx
>,
73 impl<'b
> Pass
for DumpMir {}