use rustc::front::map as hir_map;
use rustc::front::map::{blocks, NodePrinter};
use rustc_front::hir;
-use rustc_front::lowering::lower_crate;
+use rustc_front::lowering::{lower_crate, LoweringContext};
use rustc_front::print::pprust as pprust_hir;
#[derive(Copy, Clone, PartialEq, Debug)]
("expanded,identified", _) => PpmSource(PpmExpandedIdentified),
("expanded,hygiene", _) => PpmSource(PpmExpandedHygiene),
("hir", true) => PpmHir(PpmNormal),
- ("hir,identified", true) => PpmHir(PpmExpandedIdentified),
+ ("hir,identified", true) => PpmHir(PpmIdentified),
("hir,typed", true) => PpmHir(PpmTyped),
("flowgraph", true) => PpmFlowGraph(PpFlowGraphMode::Default),
("flowgraph,unlabelled", true) => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
impl PpSourceMode {
/// Constructs a `PrinterSupport` object and passes it to `f`.
fn call_with_pp_support<'tcx, A, B, F>(&self,
- sess: Session,
+ sess: &'tcx Session,
ast_map: Option<hir_map::Map<'tcx>>,
payload: B,
f: F) -> A where
}
}
fn call_with_pp_support_hir<'tcx, A, B, F>(&self,
- sess: Session,
+ sess: &'tcx Session,
ast_map: &hir_map::Map<'tcx>,
arenas: &'tcx ty::CtxtArenas<'tcx>,
- id: String,
+ id: &str,
payload: B,
f: F) -> A where
F: FnOnce(&HirPrinterSupport, B, &hir::Crate) -> A,
|tcx, _| {
let annotation = TypedAnnotation { tcx: tcx };
f(&annotation, payload, &ast_map.forest.krate)
- }).1
+ })
}
_ => panic!("Should use call_with_pp_support"),
}
}
struct NoAnn<'ast> {
- sess: Session,
+ sess: &'ast Session,
ast_map: Option<hir_map::Map<'ast>>
}
impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> {
- fn sess<'a>(&'a self) -> &'a Session { &self.sess }
+ fn sess<'a>(&'a self) -> &'a Session { self.sess }
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
self.ast_map.as_ref()
}
impl<'ast> HirPrinterSupport<'ast> for NoAnn<'ast> {
- fn sess<'a>(&'a self) -> &'a Session { &self.sess }
+ fn sess<'a>(&'a self) -> &'a Session { self.sess }
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
self.ast_map.as_ref()
impl<'ast> pprust_hir::PpAnn for NoAnn<'ast> {}
struct IdentifiedAnnotation<'ast> {
- sess: Session,
+ sess: &'ast Session,
ast_map: Option<hir_map::Map<'ast>>,
}
impl<'ast> PrinterSupport<'ast> for IdentifiedAnnotation<'ast> {
- fn sess<'a>(&'a self) -> &'a Session { &self.sess }
+ fn sess<'a>(&'a self) -> &'a Session { self.sess }
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
self.ast_map.as_ref()
}
impl<'ast> HirPrinterSupport<'ast> for IdentifiedAnnotation<'ast> {
- fn sess<'a>(&'a self) -> &'a Session { &self.sess }
+ fn sess<'a>(&'a self) -> &'a Session { self.sess }
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
self.ast_map.as_ref()
}
struct HygieneAnnotation<'ast> {
- sess: Session,
+ sess: &'ast Session,
ast_map: Option<hir_map::Map<'ast>>,
}
impl<'ast> PrinterSupport<'ast> for HygieneAnnotation<'ast> {
- fn sess<'a>(&'a self) -> &'a Session { &self.sess }
+ fn sess<'a>(&'a self) -> &'a Session { self.sess }
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
self.ast_map.as_ref()
// There is some twisted, god-forsaken tangle of lifetimes here which makes
// the ordering of stuff super-finicky.
let mut hir_forest;
+ let lcx = LoweringContext::new(&sess, Some(&krate));
let arenas = ty::CtxtArenas::new();
let ast_map = if compute_ast_map {
- hir_forest = hir_map::Forest::new(lower_crate(&krate));
+ hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate));
let map = driver::make_map(&sess, &mut hir_forest);
Some(map)
} else {
// Silently ignores an identified node.
let out: &mut Write = &mut out;
s.call_with_pp_support(
- sess, ast_map, box out, |annotation, out| {
+ &sess, ast_map, box out, |annotation, out| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
pprust::print_crate(sess.codemap(),
(PpmHir(s), None) => {
let out: &mut Write = &mut out;
s.call_with_pp_support_hir(
- sess, &ast_map.unwrap(), &arenas, id, box out, |annotation, out, krate| {
+ &sess, &ast_map.unwrap(), &arenas, &id, box out, |annotation, out, krate| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
pprust_hir::print_crate(sess.codemap(),
(PpmHir(s), Some(uii)) => {
let out: &mut Write = &mut out;
- s.call_with_pp_support_hir(sess,
+ s.call_with_pp_support_hir(&sess,
&ast_map.unwrap(),
&arenas,
- id,
+ &id,
(out,uii),
|annotation, (out,uii), _| {
debug!("pretty printing source code {:?}", s);
match code {
Some(code) => {
let variants = gather_flowgraph_variants(&sess);
- driver::phase_3_run_analysis_passes(sess,
+ driver::phase_3_run_analysis_passes(&sess,
ast_map,
&arenas,
- id,
+ &id,
resolve::MakeGlobMap::No,
|tcx, _| {
print_flowgraph(variants, tcx, code, mode, out)
- }).1
+ })
}
None => {
let message = format!("--pretty=flowgraph needs \