Skip to content

Commit 0608e01

Browse files
pnkfelixalexcrichton
authored andcommitted
---
yaml --- r: 150707 b: refs/heads/try2 c: da25539 h: refs/heads/master i: 150705: d770699 150703: 5b13392 v: v3
1 parent 9ebefbc commit 0608e01

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: a70f8d9cf3619aed475874c1b27595e0c86e627e
8+
refs/heads/try2: da25539c1ab295ec40261109557dd4526923928c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/driver/driver.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ impl pprust::PpAnn for TypedAnnotation {
664664
pub fn pretty_print_input(sess: Session,
665665
cfg: ast::CrateConfig,
666666
input: &Input,
667-
ppm: PpMode) {
667+
ppm: PpMode,
668+
ofile: Option<Path>) {
668669
let krate = phase_1_parse_input(&sess, cfg, input);
669670
let id = link::find_crate_id(krate.attrs.as_slice(), input.filestem());
670671

@@ -682,14 +683,25 @@ pub fn pretty_print_input(sess: Session,
682683
let src = Vec::from_slice(sess.codemap().get_filemap(src_name).src.as_bytes());
683684
let mut rdr = MemReader::new(src);
684685

686+
let out = match ofile {
687+
None => ~io::stdout() as ~Writer,
688+
Some(p) => {
689+
let r = io::File::create(&p);
690+
match r {
691+
Ok(w) => ~w as ~Writer,
692+
Err(e) => fail!("print-print failed to open {} due to {}",
693+
p.display(), e),
694+
}
695+
}
696+
};
685697
match ppm {
686698
PpmIdentified | PpmExpandedIdentified => {
687699
pprust::print_crate(sess.codemap(),
688700
sess.diagnostic(),
689701
&krate,
690702
src_name,
691703
&mut rdr,
692-
~io::stdout(),
704+
out,
693705
&IdentifiedAnnotation,
694706
is_expanded)
695707
}
@@ -704,7 +716,7 @@ pub fn pretty_print_input(sess: Session,
704716
&krate,
705717
src_name,
706718
&mut rdr,
707-
~io::stdout(),
719+
out,
708720
&annotation,
709721
is_expanded)
710722
}
@@ -714,7 +726,7 @@ pub fn pretty_print_input(sess: Session,
714726
&krate,
715727
src_name,
716728
&mut rdr,
717-
~io::stdout(),
729+
out,
718730
&pprust::NoAnn,
719731
is_expanded)
720732
}

branches/try2/src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub fn run_compiler(args: &[~str]) {
293293
});
294294
match pretty {
295295
Some::<d::PpMode>(ppm) => {
296-
d::pretty_print_input(sess, cfg, &input, ppm);
296+
d::pretty_print_input(sess, cfg, &input, ppm, ofile);
297297
return;
298298
}
299299
None::<d::PpMode> => {/* continue */ }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) -o $(TMPDIR)/input.out --pretty=normal input.rs
5+
diff -u $(TMPDIR)/input.out input.pp
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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.
4+
//
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.
10+
11+
12+
#[crate_type = "lib"]
13+
pub fn foo() -> i32 { 45 }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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.
4+
//
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.
10+
11+
#[crate_type="lib"]
12+
13+
pub fn
14+
foo() -> i32
15+
{ 45 }

0 commit comments

Comments
 (0)