1
Fork 0

Remove re-exports of std::io::stdio::{print, println} in the prelude.

The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
This commit is contained in:
Brendan Zabarauskas 2014-01-09 21:06:55 +11:00
parent ff7ecca20e
commit 4fc0452ace
130 changed files with 350 additions and 336 deletions

View file

@ -275,7 +275,7 @@ fn main() {
}; };
if result.is_err() { if result.is_err() {
println("parsing failed"); println!("parsing failed");
} }
} }

View file

@ -218,12 +218,12 @@ let xs = [2u, 3, 5, 7, 11, 13, 17];
// print out all the elements in the vector // print out all the elements in the vector
for x in xs.iter() { for x in xs.iter() {
println(x.to_str()) println!("{}", *x)
} }
// print out all but the first 3 elements in the vector // print out all but the first 3 elements in the vector
for x in xs.iter().skip(3) { for x in xs.iter().skip(3) {
println(x.to_str()) println!("{}", *x)
} }
~~~ ~~~

View file

@ -222,7 +222,7 @@ struct Point {
fn main() { fn main() {
let a = Point { x: 10, y: 20 }; let a = Point { x: 10, y: 20 };
do spawn { do spawn {
println(a.x.to_str()); println!("{}", a.x);
} }
} }
~~~ ~~~
@ -239,7 +239,7 @@ struct Point {
fn main() { fn main() {
let a = ~Point { x: 10, y: 20 }; let a = ~Point { x: 10, y: 20 };
do spawn { do spawn {
println(a.x.to_str()); println!("{}", a.x);
} }
} }
~~~ ~~~
@ -270,18 +270,22 @@ struct Point {
fn main() { fn main() {
let a = ~Point { x: 10, y: 20 }; let a = ~Point { x: 10, y: 20 };
let b = a; let b = a;
println(b.x.to_str()); println!("{}", b.x);
println(a.x.to_str()); println!("{}", a.x);
} }
~~~ ~~~
You'll get this error: You'll get this error:
~~~ {.notrust} ~~~ {.notrust}
test.rs:10:12: 10:13 error: use of moved value: `a` test.rs:10:20: 10:21 error: use of moved value: `a`
test.rs:10 println(a.x.to_str()); test.rs:10 println!("{}", a.x);
^ ^
test.rs:8:8: 8:9 note: `a` moved here because it has type `~Point`, which is moved by default (use `ref` to override) note: in expansion of format_args!
<std-macros>:158:27: 158:81 note: expansion site
<std-macros>:157:5: 159:6 note: in expansion of println!
test.rs:10:5: 10:25 note: expansion site
test.rs:8:9: 8:10 note: `a` moved here because it has type `~Point`, which is moved by default (use `ref` to override)
test.rs:8 let b = a; test.rs:8 let b = a;
^ ^
~~~ ~~~
@ -297,8 +301,8 @@ struct Point {
fn main() { fn main() {
let a = @Point { x: 10, y: 20 }; let a = @Point { x: 10, y: 20 };
let b = a; let b = a;
println(b.x.to_str()); println!("{}", b.x);
println(a.x.to_str()); println!("{}", a.x);
} }
~~~ ~~~
@ -367,7 +371,7 @@ compile?
~~~rust{.xfail-test} ~~~rust{.xfail-test}
fn main() { fn main() {
println(x.to_str()); println!("{}", x);
let x = 5; let x = 5;
} }
~~~ ~~~

View file

@ -143,7 +143,7 @@ Next, let's add a source file:
#[license = "MIT"]; #[license = "MIT"];
pub fn world() { pub fn world() {
println("Hello, world."); println!("Hello, world.");
} }
~~~ ~~~

View file

@ -72,15 +72,15 @@ closure in the new task.
# use std::task::spawn; # use std::task::spawn;
// Print something profound in a different task using a named function // Print something profound in a different task using a named function
fn print_message() { println("I am running in a different task!"); } fn print_message() { println!("I am running in a different task!"); }
spawn(print_message); spawn(print_message);
// Print something more profound in a different task using a lambda expression // Print something more profound in a different task using a lambda expression
spawn(proc() println("I am also running in a different task!") ); spawn(proc() println!("I am also running in a different task!") );
// The canonical way to spawn is using `do` notation // The canonical way to spawn is using `do` notation
do spawn { do spawn {
println("I too am running in a different task!"); println!("I too am running in a different task!");
} }
~~~~ ~~~~

View file

@ -2668,7 +2668,7 @@ An example:
let mut i = 0; let mut i = 0;
while i < 10 { while i < 10 {
println("hello\n"); println!("hello");
i = i + 1; i = i + 1;
} }
~~~~ ~~~~
@ -3267,7 +3267,7 @@ impl Printable for int {
} }
fn print(a: @Printable) { fn print(a: @Printable) {
println(a.to_string()); println!("{}", a.to_string());
} }
fn main() { fn main() {

View file

@ -130,7 +130,7 @@ we have a file `hello.rs` containing this program:
~~~~ ~~~~
fn main() { fn main() {
println("hello?"); println!("hello?");
} }
~~~~ ~~~~
@ -140,12 +140,12 @@ Windows) which, upon running, will likely do exactly what you expect.
The Rust compiler tries to provide useful information when it encounters an The Rust compiler tries to provide useful information when it encounters an
error. If you introduce an error into the program (for example, by changing error. If you introduce an error into the program (for example, by changing
`println` to some nonexistent function), and then compile it, you'll see `println!` to some nonexistent macro), and then compile it, you'll see
an error message like this: an error message like this:
~~~~ {.notrust} ~~~~ {.notrust}
hello.rs:2:4: 2:16 error: unresolved name: print_with_unicorns hello.rs:2:5: 2:24 error: macro undefined: 'print_with_unicorns'
hello.rs:2 print_with_unicorns("hello?"); hello.rs:2 print_with_unicorns!("hello?");
^~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
~~~~ ~~~~
@ -424,11 +424,11 @@ compulsory, an `if` can have an optional `else` clause, and multiple
~~~~ ~~~~
if false { if false {
println("that's odd"); println!("that's odd");
} else if true { } else if true {
println("right"); println!("right");
} else { } else {
println("neither true nor false"); println!("neither true nor false");
} }
~~~~ ~~~~
@ -456,10 +456,10 @@ executes its corresponding arm.
~~~~ ~~~~
# let my_number = 1; # let my_number = 1;
match my_number { match my_number {
0 => println("zero"), 0 => println!("zero"),
1 | 2 => println("one or two"), 1 | 2 => println!("one or two"),
3..10 => println("three to ten"), 3..10 => println!("three to ten"),
_ => println("something else") _ => println!("something else")
} }
~~~~ ~~~~
@ -484,8 +484,8 @@ commas are optional.
~~~ ~~~
# let my_number = 1; # let my_number = 1;
match my_number { match my_number {
0 => { println("zero") } 0 => { println!("zero") }
_ => { println("something else") } _ => { println!("something else") }
} }
~~~ ~~~
@ -563,7 +563,7 @@ let mut x = 5u;
loop { loop {
x += x - 3; x += x - 3;
if x % 5 == 0 { break; } if x % 5 == 0 { break; }
println(x.to_str()); println!("{}", x);
} }
~~~~ ~~~~
@ -613,8 +613,8 @@ origin.y += 1.0; // ERROR: assigning to immutable field
# struct Point { x: f64, y: f64 } # struct Point { x: f64, y: f64 }
# let mypoint = Point { x: 0.0, y: 0.0 }; # let mypoint = Point { x: 0.0, y: 0.0 };
match mypoint { match mypoint {
Point { x: 0.0, y: yy } => { println(yy.to_str()); } Point { x: 0.0, y: yy } => println!("{}", yy),
Point { x: xx, y: yy } => { println(xx.to_str() + " " + yy.to_str()); } Point { x: xx, y: yy } => println!("{} {}", xx, yy),
} }
~~~~ ~~~~
@ -629,7 +629,7 @@ reuses the field name as the binding name.
# struct Point { x: f64, y: f64 } # struct Point { x: f64, y: f64 }
# let mypoint = Point { x: 0.0, y: 0.0 }; # let mypoint = Point { x: 0.0, y: 0.0 };
match mypoint { match mypoint {
Point { x, .. } => { println(x.to_str()) } Point { x, .. } => println!("{}", x),
} }
~~~ ~~~
@ -1777,7 +1777,7 @@ structure.
~~~~ ~~~~
# fn call_it(op: proc(v: int)) { } # fn call_it(op: proc(v: int)) { }
call_it(proc(n) { call_it(proc(n) {
println(n.to_str()); println!("{}", n);
}); });
~~~~ ~~~~
@ -1787,7 +1787,7 @@ call for these functions.
~~~~ ~~~~
# fn call_it(op: proc(v: int)) { } # fn call_it(op: proc(v: int)) { }
do call_it() |n| { do call_it() |n| {
println(n.to_str()); println!("{}", n);
} }
~~~~ ~~~~
@ -2124,7 +2124,7 @@ struct TimeBomb {
impl Drop for TimeBomb { impl Drop for TimeBomb {
fn drop(&mut self) { fn drop(&mut self) {
for _ in range(0, self.explosivity) { for _ in range(0, self.explosivity) {
println("blam!"); println!("blam!");
} }
} }
} }
@ -2168,7 +2168,7 @@ impl Printable for int {
} }
impl Printable for ~str { impl Printable for ~str {
fn print(&self) { println(*self) } fn print(&self) { println!("{}", *self) }
} }
# 1.print(); # 1.print();
@ -2214,7 +2214,7 @@ trait Printable {
impl Printable for int {} impl Printable for int {}
impl Printable for ~str { impl Printable for ~str {
fn print(&self) { println(*self) } fn print(&self) { println!("{}", *self) }
} }
impl Printable for bool {} impl Printable for bool {}
@ -2561,7 +2561,7 @@ For example, for a simple hello world program your crate only consists of this c
~~~~ ~~~~
// main.rs // main.rs
fn main() { fn main() {
println("Hello world!"); println!("Hello world!");
} }
~~~~ ~~~~
@ -2583,18 +2583,18 @@ All modules in a crate below the crate root are declared with the `mod` keyword:
mod farm { mod farm {
// This is the body of module 'farm' declared in the crate root. // This is the body of module 'farm' declared in the crate root.
fn chicken() { println("cluck cluck"); } fn chicken() { println!("cluck cluck"); }
fn cow() { println("mooo"); } fn cow() { println!("mooo"); }
mod barn { mod barn {
// Body of module 'barn' // Body of module 'barn'
fn hay() { println("..."); } fn hay() { println!("..."); }
} }
} }
fn main() { fn main() {
println("Hello farm!"); println!("Hello farm!");
} }
~~~~ ~~~~
@ -2611,12 +2611,12 @@ One way to do it is to simply fully qualifying it:
~~~~ {.xfail-test} ~~~~ {.xfail-test}
mod farm { mod farm {
fn chicken() { println("cluck cluck"); } fn chicken() { println!("cluck cluck"); }
// ... // ...
} }
fn main() { fn main() {
println("Hello chicken!"); println!("Hello chicken!");
::farm::chicken(); // Won't compile yet, see further down ::farm::chicken(); // Won't compile yet, see further down
} }
@ -2639,13 +2639,13 @@ _public_ with `pub`:
~~~~ ~~~~
mod farm { mod farm {
pub fn chicken() { println("cluck cluck"); } pub fn chicken() { println!("cluck cluck"); }
pub fn cow() { println("mooo"); } pub fn cow() { println!("mooo"); }
// ... // ...
} }
fn main() { fn main() {
println("Hello chicken!"); println!("Hello chicken!");
::farm::chicken(); // This compiles now ::farm::chicken(); // This compiles now
} }
~~~~ ~~~~
@ -2725,18 +2725,18 @@ So, if we want to move the content of `mod farm` into it's own file, it would lo
mod farm; // Compiler will look for 'farm.rs' and 'farm/mod.rs' mod farm; // Compiler will look for 'farm.rs' and 'farm/mod.rs'
fn main() { fn main() {
println("Hello farm!"); println!("Hello farm!");
::farm::cow(); ::farm::cow();
} }
~~~~ ~~~~
~~~~ ~~~~
// farm.rs - contains body of module 'farm' in the crate root // farm.rs - contains body of module 'farm' in the crate root
pub fn chicken() { println("cluck cluck"); } pub fn chicken() { println!("cluck cluck"); }
pub fn cow() { println("mooo"); } pub fn cow() { println!("mooo"); }
pub mod barn { pub mod barn {
pub fn hay() { println("..."); } pub fn hay() { println!("..."); }
} }
# fn main() { } # fn main() { }
~~~~ ~~~~
@ -2843,7 +2843,7 @@ without the `::` prefix. For example, this imports `cow` into the local scope:
~~~ ~~~
use farm::cow; use farm::cow;
# mod farm { pub fn cow() { println("I'm a hidden ninja cow!") } } # mod farm { pub fn cow() { println!("I'm a hidden ninja cow!") } }
# fn main() { cow() } # fn main() { cow() }
~~~ ~~~
@ -2861,7 +2861,7 @@ while adding a `self::` prefix will start in the current module:
~~~ ~~~
# mod workaround { # mod workaround {
# pub fn some_parent_item(){ println("...") } # pub fn some_parent_item(){ println!("...") }
# mod foo { # mod foo {
use super::some_parent_item; use super::some_parent_item;
use self::some_child_module::some_item; use self::some_child_module::some_item;
@ -2883,8 +2883,8 @@ scope with corresponding `use` statements.
# // XXX: Allow unused import in doc test # // XXX: Allow unused import in doc test
use farm::cow; use farm::cow;
// ... // ...
# mod farm { pub fn cow() { println("Hidden ninja cow is hidden.") } } # mod farm { pub fn cow() { println!("Hidden ninja cow is hidden.") } }
fn cow() { println("Mooo!") } fn cow() { println!("Mooo!") }
fn main() { fn main() {
cow() // resolves to the locally defined cow() function cow() // resolves to the locally defined cow() function
@ -2902,7 +2902,7 @@ even if they refer to things inside them:
~~~ ~~~
use farm::cow; use farm::cow;
mod farm { mod farm {
pub fn cow() { println("Moooooo?") } pub fn cow() { println!("Moooooo?") }
} }
fn main() { cow() } fn main() { cow() }
@ -2916,16 +2916,16 @@ use farm::cow;
use farm::barn; use farm::barn;
mod farm { mod farm {
pub fn chicken() { println("cluck cluck"); } pub fn chicken() { println!("cluck cluck"); }
pub fn cow() { println("mooo"); } pub fn cow() { println!("mooo"); }
pub mod barn { pub mod barn {
pub fn hay() { println("..."); } pub fn hay() { println!("..."); }
} }
} }
fn main() { fn main() {
println("Hello farm!"); println!("Hello farm!");
// Can now refer to those names directly: // Can now refer to those names directly:
chicken(); chicken();
@ -2952,7 +2952,7 @@ pub fn foo() { bar(); }
~~~ ~~~
// c.rs // c.rs
pub fn bar() { println("Baz!"); } pub fn bar() { println!("Baz!"); }
# fn main() {} # fn main() {}
~~~ ~~~
@ -2963,8 +2963,8 @@ There also exist two short forms for importing multiple names at once:
~~~ ~~~
use farm::{chicken, cow}; use farm::{chicken, cow};
# mod farm { # mod farm {
# pub fn cow() { println("Did I already mention how hidden and ninja I am?") } # pub fn cow() { println!("Did I already mention how hidden and ninja I am?") }
# pub fn chicken() { println("I'm Bat-chicken, guardian of the hidden tutorial code.") } # pub fn chicken() { println!("I'm Bat-chicken, guardian of the hidden tutorial code.") }
# } # }
# fn main() { cow(); chicken() } # fn main() { cow(); chicken() }
~~~ ~~~
@ -2974,8 +2974,8 @@ use farm::{chicken, cow};
~~~ ~~~
use farm::*; use farm::*;
# mod farm { # mod farm {
# pub fn cow() { println("Bat-chicken? What a stupid name!") } # pub fn cow() { println!("Bat-chicken? What a stupid name!") }
# pub fn chicken() { println("Says the 'hidden ninja' cow.") } # pub fn chicken() { println!("Says the 'hidden ninja' cow.") }
# } # }
# fn main() { cow(); chicken() } # fn main() { cow(); chicken() }
~~~ ~~~
@ -2988,7 +2988,7 @@ However, that's not all. You can also rename an item while you're bringing it in
~~~ ~~~
use egg_layer = farm::chicken; use egg_layer = farm::chicken;
# mod farm { pub fn chicken() { println("Laying eggs is fun!") } } # mod farm { pub fn chicken() { println!("Laying eggs is fun!") } }
// ... // ...
fn main() { fn main() {
@ -3010,11 +3010,11 @@ For that, you write `pub use`:
mod farm { mod farm {
pub use self::barn::hay; pub use self::barn::hay;
pub fn chicken() { println("cluck cluck"); } pub fn chicken() { println!("cluck cluck"); }
pub fn cow() { println("mooo"); } pub fn cow() { println!("mooo"); }
mod barn { mod barn {
pub fn hay() { println("..."); } pub fn hay() { println!("..."); }
} }
} }
@ -3082,7 +3082,7 @@ use farm::dog;
use extra::rational::Ratio; use extra::rational::Ratio;
mod farm { mod farm {
pub fn dog() { println("woof"); } pub fn dog() { println!("woof"); }
} }
fn main() { fn main() {
@ -3180,7 +3180,7 @@ pub fn explore() -> &'static str { "world" }
~~~~ {.xfail-test} ~~~~ {.xfail-test}
// main.rs // main.rs
extern mod world; extern mod world;
fn main() { println("hello " + world::explore()); } fn main() { println!("hello {}", world::explore()); }
~~~~ ~~~~
Now compile and run like this (adjust to your platform if necessary): Now compile and run like this (adjust to your platform if necessary):
@ -3200,7 +3200,7 @@ a hash representing the crates package ID.
## The standard library and the prelude ## The standard library and the prelude
While reading the examples in this tutorial, you might have asked yourself where all While reading the examples in this tutorial, you might have asked yourself where all
those magical predefined items like `println()` are coming from. those magical predefined items like `range` are coming from.
The truth is, there's nothing magical about them: They are all defined normally The truth is, there's nothing magical about them: They are all defined normally
in the `std` library, which is a crate that ships with Rust. in the `std` library, which is a crate that ships with Rust.
@ -3219,19 +3219,24 @@ use std::prelude::*;
The role of the `prelude` module is to re-export common definitions from `std`. The role of the `prelude` module is to re-export common definitions from `std`.
This allows you to use common types and functions like `Option<T>` or `println` This allows you to use common types and functions like `Option<T>` or `range`
without needing to import them. And if you need something from `std` that's not in the prelude, without needing to import them. And if you need something from `std` that's not in the prelude,
you just have to import it with an `use` statement. you just have to import it with an `use` statement.
For example, it re-exports `println` which is defined in `std::io::stdio::println`: For example, it re-exports `range` which is defined in `std::iter::range`:
~~~ ~~~
use puts = std::io::stdio::println; use iter_range = std::iter::range;
fn main() { fn main() {
println("println is imported per default."); // range is imported by default
puts("Doesn't hinder you from importing it under a different name yourself."); for _ in range(0, 10) {}
::std::io::stdio::println("Or from not using the automatic import.");
// Doesn't hinder you from importing it under a different name yourself
for _ in iter_range(0, 10) {}
// Or from not using the automatic import.
for _ in ::std::iter::range(0, 10) {}
} }
~~~ ~~~

View file

@ -84,8 +84,8 @@ pub fn parse_config(args: ~[~str]) -> config {
let args_ = args.tail(); let args_ = args.tail();
if args[1] == ~"-h" || args[1] == ~"--help" { if args[1] == ~"-h" || args[1] == ~"--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println(getopts::groups::usage(message, groups)); println!("{}", getopts::groups::usage(message, groups));
println(""); println!("");
fail!() fail!()
} }
@ -97,8 +97,8 @@ pub fn parse_config(args: ~[~str]) -> config {
if matches.opt_present("h") || matches.opt_present("help") { if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println(getopts::groups::usage(message, groups)); println!("{}", getopts::groups::usage(message, groups));
println(""); println!("");
fail!() fail!()
} }
@ -219,7 +219,7 @@ pub fn run_tests(config: &config) {
if config.target == ~"arm-linux-androideabi" { if config.target == ~"arm-linux-androideabi" {
match config.mode{ match config.mode{
mode_debug_info => { mode_debug_info => {
println("arm-linux-androideabi debug-info \ println!("arm-linux-androideabi debug-info \
test uses tcp 5039 port. please reserve it"); test uses tcp 5039 port. please reserve it");
//arm-linux-androideabi debug-info test uses remote debugger //arm-linux-androideabi debug-info test uses remote debugger
//so, we test 1 task at once //so, we test 1 task at once

View file

@ -53,5 +53,5 @@ pub fn path_div() -> ~str { ~";" }
pub fn logv(config: &config, s: ~str) { pub fn logv(config: &config, s: ~str) {
debug!("{}", s); debug!("{}", s);
if config.verbose { println(s); } if config.verbose { println!("{}", s); }
} }

View file

@ -35,17 +35,17 @@
//! use std::os; //! use std::os;
//! //!
//! fn do_work(inp: &str, out: Option<~str>) { //! fn do_work(inp: &str, out: Option<~str>) {
//! println(inp); //! println!("{}", inp);
//! println(match out { //! match out {
//! Some(x) => x, //! Some(x) => println!("{}", x),
//! None => ~"No Output" //! None => println!("No Output"),
//! }); //! }
//! } //! }
//! //!
//! fn print_usage(program: &str, _opts: &[Opt]) { //! fn print_usage(program: &str, _opts: &[Opt]) {
//! println!("Usage: {} [options]", program); //! println!("Usage: {} [options]", program);
//! println("-o\t\tOutput"); //! println!("-o\t\tOutput");
//! println("-h --help\tUsage"); //! println!("-h --help\tUsage");
//! } //! }
//! //!
//! fn main() { //! fn main() {

View file

@ -226,10 +226,10 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
fn usage(binary: &str, helpstr: &str) { fn usage(binary: &str, helpstr: &str) {
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary); let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
println(groups::usage(message, optgroups())); println!("{}", groups::usage(message, optgroups()));
println(""); println!("");
if helpstr == "help" { if helpstr == "help" {
println("\ println!("{}", "\
The FILTER is matched against the name of all tests to run, and if any tests The FILTER is matched against the name of all tests to run, and if any tests
have a substring match, only those tests are run. have a substring match, only those tests are run.

View file

@ -393,7 +393,7 @@ fn query_from_str(rawquery: &str) -> Query {
* use extra::url; * use extra::url;
* *
* let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")]; * let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")];
* println(url::query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10 * println!("{}", url::query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10
* ``` * ```
*/ */
pub fn query_to_str(query: &Query) -> ~str { pub fn query_to_str(query: &Query) -> ~str {

View file

@ -34,7 +34,7 @@ use extra::uuid::Uuid;
fn main() { fn main() {
let uuid1 = Uuid::new_v4(); let uuid1 = Uuid::new_v4();
println(uuid1.to_str()); println!("{}", uuid1.to_str());
} }
``` ```

View file

@ -536,5 +536,5 @@ fn test() {
} }
}); });
println(s); println!("{}", s);
} }

View file

@ -160,7 +160,7 @@ Additional help:
} }
pub fn describe_warnings() { pub fn describe_warnings() {
println(" println!("
Available lint options: Available lint options:
-W <foo> Warn about <foo> -W <foo> Warn about <foo>
-A <foo> Allow <foo> -A <foo> Allow <foo>
@ -181,7 +181,7 @@ Available lint options:
fn padded(max: uint, s: &str) -> ~str { fn padded(max: uint, s: &str) -> ~str {
" ".repeat(max - s.len()) + s " ".repeat(max - s.len()) + s
} }
println("\nAvailable lint checks:\n"); println!("{}", "\nAvailable lint checks:\n"); // FIXME: #9970
println!(" {} {:7.7s} {}", println!(" {} {:7.7s} {}",
padded(max_key, "name"), "default", "meaning"); padded(max_key, "name"), "default", "meaning");
println!(" {} {:7.7s} {}\n", println!(" {} {:7.7s} {}\n",
@ -193,11 +193,11 @@ Available lint options:
lint::level_to_str(spec.default), lint::level_to_str(spec.default),
spec.desc); spec.desc);
} }
println(""); println!("");
} }
pub fn describe_debug_flags() { pub fn describe_debug_flags() {
println("\nAvailable debug options:\n"); println!("{}", "\nAvailable debug options:\n"); // FIXME: #9970
let r = session::debugging_opts_map(); let r = session::debugging_opts_map();
for tuple in r.iter() { for tuple in r.iter() {
match *tuple { match *tuple {
@ -312,10 +312,10 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
} }
}; };
if crate_id { if crate_id {
println(crateid.to_str()); println!("{}", crateid.to_str());
} }
if crate_name { if crate_name {
println(crateid.name); println!("{}", crateid.name);
} }
} }

View file

@ -1905,7 +1905,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate)
} }
} }
println("metadata stats:"); println!("metadata stats:");
println!(" inline bytes: {}", ecx.stats.inline_bytes.get()); println!(" inline bytes: {}", ecx.stats.inline_bytes.get());
println!(" attribute bytes: {}", ecx.stats.attr_bytes.get()); println!(" attribute bytes: {}", ecx.stats.attr_bytes.get());
println!(" dep bytes: {}", ecx.stats.dep_bytes.get()); println!(" dep bytes: {}", ecx.stats.dep_bytes.get());

View file

@ -93,7 +93,7 @@ pub fn check_crate(tcx: ty::ctxt,
visit::walk_crate(bccx, crate, ()); visit::walk_crate(bccx, crate, ());
if tcx.sess.borrowck_stats() { if tcx.sess.borrowck_stats() {
println("--- borrowck stats ---"); println!("--- borrowck stats ---");
println!("paths requiring guarantees: {}", println!("paths requiring guarantees: {}",
bccx.stats.guaranteed_paths.get()); bccx.stats.guaranteed_paths.get());
println!("paths requiring loans : {}", println!("paths requiring loans : {}",

View file

@ -3367,7 +3367,7 @@ pub fn trans_crate(sess: session::Session,
// Translate the metadata. // Translate the metadata.
let metadata = write_metadata(ccx, &crate); let metadata = write_metadata(ccx, &crate);
if ccx.sess.trans_stats() { if ccx.sess.trans_stats() {
println("--- trans stats ---"); println!("--- trans stats ---");
println!("n_static_tydescs: {}", ccx.stats.n_static_tydescs.get()); println!("n_static_tydescs: {}", ccx.stats.n_static_tydescs.get());
println!("n_glues_created: {}", ccx.stats.n_glues_created.get()); println!("n_glues_created: {}", ccx.stats.n_glues_created.get());
println!("n_null_glues: {}", ccx.stats.n_null_glues.get()); println!("n_null_glues: {}", ccx.stats.n_null_glues.get());
@ -3377,7 +3377,7 @@ pub fn trans_crate(sess: session::Session,
println!("n_monos: {}", ccx.stats.n_monos.get()); println!("n_monos: {}", ccx.stats.n_monos.get());
println!("n_inlines: {}", ccx.stats.n_inlines.get()); println!("n_inlines: {}", ccx.stats.n_inlines.get());
println!("n_closures: {}", ccx.stats.n_closures.get()); println!("n_closures: {}", ccx.stats.n_closures.get());
println("fn stats:"); println!("fn stats:");
{ {
let mut fn_stats = ccx.stats.fn_stats.borrow_mut(); let mut fn_stats = ccx.stats.fn_stats.borrow_mut();
fn_stats.get().sort_by(|&(_, _, insns_a), &(_, _, insns_b)| { fn_stats.get().sort_by(|&(_, _, insns_a), &(_, _, insns_b)| {

View file

@ -105,14 +105,14 @@ pub fn opts() -> ~[groups::OptGroup] {
} }
pub fn usage(argv0: &str) { pub fn usage(argv0: &str) {
println(groups::usage(format!("{} [options] <input>", argv0), opts())); println!("{}", groups::usage(format!("{} [options] <input>", argv0), opts()));
} }
pub fn main_args(args: &[~str]) -> int { pub fn main_args(args: &[~str]) -> int {
let matches = match groups::getopts(args.tail(), opts()) { let matches = match groups::getopts(args.tail(), opts()) {
Ok(m) => m, Ok(m) => m,
Err(err) => { Err(err) => {
println(err.to_err_msg()); println!("{}", err.to_err_msg());
return 1; return 1;
} }
}; };
@ -122,10 +122,10 @@ pub fn main_args(args: &[~str]) -> int {
} }
if matches.free.len() == 0 { if matches.free.len() == 0 {
println("expected an input file to act on"); println!("expected an input file to act on");
return 1; return 1;
} if matches.free.len() > 1 { } if matches.free.len() > 1 {
println("only one input file may be specified"); println!("only one input file may be specified");
return 1; return 1;
} }
let input = matches.free[0].as_slice(); let input = matches.free[0].as_slice();
@ -135,11 +135,11 @@ pub fn main_args(args: &[~str]) -> int {
} }
if matches.opt_strs("passes") == ~[~"list"] { if matches.opt_strs("passes") == ~[~"list"] {
println("Available passes for running rustdoc:"); println!("Available passes for running rustdoc:");
for &(name, _, description) in PASSES.iter() { for &(name, _, description) in PASSES.iter() {
println!("{:>20s} - {}", name, description); println!("{:>20s} - {}", name, description);
} }
println("\nDefault passes for rustdoc:"); println!("{}", "\nDefault passes for rustdoc:"); // FIXME: #9970
for &name in DEFAULT_PASSES.iter() { for &name in DEFAULT_PASSES.iter() {
println!("{:>20s}", name); println!("{:>20s}", name);
} }

View file

@ -269,43 +269,43 @@ pub fn flags_forbidden_for_cmd(flags: &RustcFlags,
}; };
if flags.linker.is_some() && cmd != BuildCmd && cmd != InstallCmd { if flags.linker.is_some() && cmd != BuildCmd && cmd != InstallCmd {
println("The --linker option can only be used with the build or install commands."); println!("The --linker option can only be used with the build or install commands.");
return true; return true;
} }
if flags.link_args.is_some() && cmd != BuildCmd && cmd != InstallCmd { if flags.link_args.is_some() && cmd != BuildCmd && cmd != InstallCmd {
println("The --link-args option can only be used with the build or install commands."); println!("The --link-args option can only be used with the build or install commands.");
return true; return true;
} }
if !cfgs.is_empty() && cmd != BuildCmd && cmd != InstallCmd && cmd != TestCmd { if !cfgs.is_empty() && cmd != BuildCmd && cmd != InstallCmd && cmd != TestCmd {
println("The --cfg option can only be used with the build, test, or install commands."); println!("The --cfg option can only be used with the build, test, or install commands.");
return true; return true;
} }
if user_supplied_opt_level && cmd != BuildCmd && cmd != InstallCmd { if user_supplied_opt_level && cmd != BuildCmd && cmd != InstallCmd {
println("The -O and --opt-level options can only be used with the build \ println!("The -O and --opt-level options can only be used with the build \
or install commands."); or install commands.");
return true; return true;
} }
if flags.save_temps && cmd != BuildCmd && cmd != InstallCmd { if flags.save_temps && cmd != BuildCmd && cmd != InstallCmd {
println("The --save-temps option can only be used with the build \ println!("The --save-temps option can only be used with the build \
or install commands."); or install commands.");
return true; return true;
} }
if flags.target.is_some() && cmd != BuildCmd && cmd != InstallCmd { if flags.target.is_some() && cmd != BuildCmd && cmd != InstallCmd {
println("The --target option can only be used with the build \ println!("The --target option can only be used with the build \
or install commands."); or install commands.");
return true; return true;
} }
if flags.target_cpu.is_some() && cmd != BuildCmd && cmd != InstallCmd { if flags.target_cpu.is_some() && cmd != BuildCmd && cmd != InstallCmd {
println("The --target-cpu option can only be used with the build \ println!("The --target-cpu option can only be used with the build \
or install commands."); or install commands.");
return true; return true;
} }
if flags.experimental_features.is_some() && cmd != BuildCmd && cmd != InstallCmd { if flags.experimental_features.is_some() && cmd != BuildCmd && cmd != InstallCmd {
println("The -Z option can only be used with the build or install commands."); println!("The -Z option can only be used with the build or install commands.");
return true; return true;
} }

View file

@ -364,9 +364,9 @@ impl CtxMethods for BuildContext {
} }
} }
ListCmd => { ListCmd => {
println("Installed packages:"); println!("Installed packages:");
installed_packages::list_installed_packages(|pkg_id| { installed_packages::list_installed_packages(|pkg_id| {
pkg_id.path.display().with_str(|s| println(s)); pkg_id.path.display().with_str(|s| println!("{}", s));
true true
}); });
} }
@ -747,7 +747,7 @@ impl CtxMethods for BuildContext {
} }
pub fn main() { pub fn main() {
println("WARNING: The Rust package manager is experimental and may be unstable"); println!("WARNING: The Rust package manager is experimental and may be unstable");
os::set_exit_status(main_args(os::args())); os::set_exit_status(main_args(os::args()));
} }

View file

@ -38,8 +38,8 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult
target.as_str().unwrap().to_owned()]); target.as_str().unwrap().to_owned()]);
let outp = opt_outp.expect("Failed to exec `git`"); let outp = opt_outp.expect("Failed to exec `git`");
if !outp.status.success() { if !outp.status.success() {
println(str::from_utf8_owned(outp.output.clone())); println!("{}", str::from_utf8_owned(outp.output.clone()));
println(str::from_utf8_owned(outp.error)); println!("{}", str::from_utf8_owned(outp.error));
return DirToUse(target.clone()); return DirToUse(target.clone());
} }
else { else {
@ -54,8 +54,8 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult
format!("--git-dir={}", git_dir.as_str().unwrap().to_owned()), format!("--git-dir={}", git_dir.as_str().unwrap().to_owned()),
~"checkout", format!("{}", *s)]).expect("Failed to exec `git`"); ~"checkout", format!("{}", *s)]).expect("Failed to exec `git`");
if !outp.status.success() { if !outp.status.success() {
println(str::from_utf8_owned(outp.output.clone())); println!("{}", str::from_utf8_owned(outp.output.clone()));
println(str::from_utf8_owned(outp.error)); println!("{}", str::from_utf8_owned(outp.error));
return DirToUse(target.clone()); return DirToUse(target.clone());
} }
} }

View file

@ -16,5 +16,5 @@ The test runner should check that, after `rustpkg build hello-world`:
*/ */
fn main() { fn main() {
println(~"Hello world!"); println!("Hello world!");
} }

View file

@ -36,7 +36,7 @@ pub fn main() {
} }
if args[2] != ~"install" { if args[2] != ~"install" {
println(format!("Warning: I don't know how to {}", args[2])); println!("Warning: I don't know how to {}", args[2]);
return; return;
} }

View file

@ -19,5 +19,5 @@ The test runner should check that, after `rustpkg build hello-world`:
*/ */
fn main() { fn main() {
println("Hello world!"); println!("Hello world!");
} }

View file

@ -11,7 +11,7 @@
use context::Command; use context::Command;
pub fn general() { pub fn general() {
println("Usage: rustpkg [options] <cmd> [args..] println!("Usage: rustpkg [options] <cmd> [args..]
Where <cmd> is one of: Where <cmd> is one of:
build, clean, do, info, install, list, prefer, test, uninstall, unprefer build, clean, do, info, install, list, prefer, test, uninstall, unprefer
@ -24,7 +24,7 @@ Options:
} }
pub fn build() { pub fn build() {
println("rustpkg build [options..] [package-ID] println!("rustpkg build [options..] [package-ID]
Build the given package ID if specified. With no package ID argument, Build the given package ID if specified. With no package ID argument,
build the package in the current directory. In that case, the current build the package in the current directory. In that case, the current
@ -50,21 +50,21 @@ Options:
} }
pub fn clean() { pub fn clean() {
println("rustpkg clean println!("rustpkg clean
Remove all build files in the work cache for the package in the current Remove all build files in the work cache for the package in the current
directory."); directory.");
} }
pub fn do_cmd() { pub fn do_cmd() {
println("rustpkg do <cmd> println!(r"rustpkg do <cmd>
Runs a command in the package script. You can listen to a command Runs a command in the package script. You can listen to a command
by tagging a function with the attribute `#[pkg_do(cmd)]`."); by tagging a function with the attribute `\#[pkg_do(cmd)]`.");
} }
pub fn info() { pub fn info() {
println("rustpkg [options..] info println!("rustpkg [options..] info
Probe the package script in the current directory for information. Probe the package script in the current directory for information.
@ -73,13 +73,13 @@ Options:
} }
pub fn list() { pub fn list() {
println("rustpkg list println!("rustpkg list
List all installed packages."); List all installed packages.");
} }
pub fn install() { pub fn install() {
println("rustpkg install [options..] [package-ID] println!(r"rustpkg install [options..] [package-ID]
Install the given package ID if specified. With no package ID Install the given package ID if specified. With no package ID
argument, install the package in the current directory. argument, install the package in the current directory.
@ -89,7 +89,7 @@ In that case, the current directory must be a direct child of a
Examples: Examples:
rustpkg install rustpkg install
rustpkg install github.com/mozilla/servo rustpkg install github.com/mozilla/servo
rustpkg install github.com/mozilla/servo#0.1.2 rustpkg install github.com/mozilla/servo\#0.1.2
Options: Options:
-c, --cfg Pass a cfg flag to the package script -c, --cfg Pass a cfg flag to the package script
@ -105,14 +105,14 @@ Options:
} }
pub fn uninstall() { pub fn uninstall() {
println("rustpkg uninstall <id|name>[@version] println!("rustpkg uninstall <id|name>[@version]
Remove a package by id or name and optionally version. If the package(s) Remove a package by id or name and optionally version. If the package(s)
is/are depended on by another package then they cannot be removed."); is/are depended on by another package then they cannot be removed.");
} }
pub fn prefer() { pub fn prefer() {
println("rustpkg [options..] prefer <id|name>[@version] println!("rustpkg [options..] prefer <id|name>[@version]
By default all binaries are given a unique name so that multiple versions can By default all binaries are given a unique name so that multiple versions can
coexist. The prefer command will symlink the uniquely named binary to coexist. The prefer command will symlink the uniquely named binary to
@ -130,7 +130,7 @@ Example:
} }
pub fn unprefer() { pub fn unprefer() {
println("rustpkg [options..] unprefer <id|name>[@version] println!("rustpkg [options..] unprefer <id|name>[@version]
Remove all symlinks from the store to the binary directory for a package Remove all symlinks from the store to the binary directory for a package
name and optionally version. If version is not supplied, the latest version name and optionally version. If version is not supplied, the latest version
@ -139,7 +139,7 @@ information.");
} }
pub fn test() { pub fn test() {
println("rustpkg [options..] test println!("rustpkg [options..] test
Build all test crates in the current directory with the test flag. Build all test crates in the current directory with the test flag.
Then, run all the resulting test executables, redirecting the output Then, run all the resulting test executables, redirecting the output
@ -150,7 +150,7 @@ Options:
} }
pub fn init() { pub fn init() {
println("rustpkg init println!("rustpkg init
This will turn the current working directory into a workspace. The first This will turn the current working directory into a workspace. The first
command you run when starting off a new project. command you run when starting off a new project.

View file

@ -54,7 +54,7 @@ use num::FromPrimitive;
/// ///
/// ``` /// ```
/// std::bool::all_values(|x: bool| { /// std::bool::all_values(|x: bool| {
/// println(x.to_str()); /// println!("{}", x);
/// }) /// })
/// ``` /// ```
#[inline] #[inline]

View file

@ -51,8 +51,8 @@ my_error::cond.trap(|raised_int| {
// condition, then the above handler will be invoked (so long as there's no // condition, then the above handler will be invoked (so long as there's no
// other nested handler). // other nested handler).
println(my_error::cond.raise(3)); // prints "three" println!("{}", my_error::cond.raise(3)); // prints "three"
println(my_error::cond.raise(4)); // prints "oh well" println!("{}", my_error::cond.raise(4)); // prints "oh well"
}) })

View file

@ -32,7 +32,7 @@ Some examples of obvious things you might want to do
# let _g = ::std::io::ignore_io_error(); # let _g = ::std::io::ignore_io_error();
let mut stdin = BufferedReader::new(stdin()); let mut stdin = BufferedReader::new(stdin());
for line in stdin.lines() { for line in stdin.lines() {
print(line); print!("{}", line);
} }
``` ```
@ -67,7 +67,7 @@ Some examples of obvious things you might want to do
let path = Path::new("message.txt"); let path = Path::new("message.txt");
let mut file = BufferedReader::new(File::open(&path)); let mut file = BufferedReader::new(File::open(&path));
for line in file.lines() { for line in file.lines() {
print(line); print!("{}", line);
} }
``` ```
@ -204,7 +204,7 @@ io_error::cond.trap(|e: IoError| {
}); });
if error.is_some() { if error.is_some() {
println("failed to write my diary"); println!("failed to write my diary");
} }
# ::std::io::fs::unlink(&Path::new("diary.txt")); # ::std::io::fs::unlink(&Path::new("diary.txt"));
``` ```

View file

@ -68,7 +68,7 @@ pub enum Signum {
/// do spawn { /// do spawn {
/// loop { /// loop {
/// match listener.port.recv() { /// match listener.port.recv() {
/// Interrupt => println("Got Interrupt'ed"), /// Interrupt => println!("Got Interrupt'ed"),
/// _ => (), /// _ => (),
/// } /// }
/// } /// }

View file

@ -402,7 +402,7 @@ pub trait Iterator<A> {
/// .filter(|&x| x % 2 == 0) /// .filter(|&x| x % 2 == 0)
/// .inspect(|&x| debug!("{} made it through", x)) /// .inspect(|&x| debug!("{} made it through", x))
/// .sum(); /// .sum();
/// println(sum.to_str()); /// println!("{}", sum);
/// ``` /// ```
#[inline] #[inline]
fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> { fn inspect<'r>(self, f: 'r |&A|) -> Inspect<'r, A, Self> {

View file

@ -47,8 +47,8 @@
* } * }
* } * }
* fn main() { * fn main() {
* println(format!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3})); * println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
* println(format!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3})); * println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
* } * }
* ``` * ```
* *
@ -72,7 +72,7 @@
* *
* impl Drop for HasDrop { * impl Drop for HasDrop {
* fn drop(&mut self) { * fn drop(&mut self) {
* println("Dropping!"); * println!("Dropping!");
* } * }
* } * }
* *
@ -100,7 +100,7 @@ pub trait Drop {
* *
* impl Add<Foo, Foo> for Foo { * impl Add<Foo, Foo> for Foo {
* fn add(&self, _rhs: &Foo) -> Foo { * fn add(&self, _rhs: &Foo) -> Foo {
* println("Adding!"); * println!("Adding!");
* *self * *self
* } * }
* } * }
@ -129,7 +129,7 @@ pub trait Add<RHS,Result> {
* *
* impl Sub<Foo, Foo> for Foo { * impl Sub<Foo, Foo> for Foo {
* fn sub(&self, _rhs: &Foo) -> Foo { * fn sub(&self, _rhs: &Foo) -> Foo {
* println("Subtracting!"); * println!("Subtracting!");
* *self * *self
* } * }
* } * }
@ -158,7 +158,7 @@ pub trait Sub<RHS,Result> {
* *
* impl Mul<Foo, Foo> for Foo { * impl Mul<Foo, Foo> for Foo {
* fn mul(&self, _rhs: &Foo) -> Foo { * fn mul(&self, _rhs: &Foo) -> Foo {
* println("Multiplying!"); * println!("Multiplying!");
* *self * *self
* } * }
* } * }
@ -187,7 +187,7 @@ pub trait Mul<RHS,Result> {
* *
* impl Div<Foo, Foo> for Foo { * impl Div<Foo, Foo> for Foo {
* fn div(&self, _rhs: &Foo) -> Foo { * fn div(&self, _rhs: &Foo) -> Foo {
* println("Dividing!"); * println!("Dividing!");
* *self * *self
* } * }
* } * }
@ -216,7 +216,7 @@ pub trait Div<RHS,Result> {
* *
* impl Rem<Foo, Foo> for Foo { * impl Rem<Foo, Foo> for Foo {
* fn rem(&self, _rhs: &Foo) -> Foo { * fn rem(&self, _rhs: &Foo) -> Foo {
* println("Remainder-ing!"); * println!("Remainder-ing!");
* *self * *self
* } * }
* } * }
@ -245,7 +245,7 @@ pub trait Rem<RHS,Result> {
* *
* impl Neg<Foo> for Foo { * impl Neg<Foo> for Foo {
* fn neg(&self) -> Foo { * fn neg(&self) -> Foo {
* println("Negating!"); * println!("Negating!");
* *self * *self
* } * }
* } * }
@ -274,7 +274,7 @@ pub trait Neg<Result> {
* *
* impl Not<Foo> for Foo { * impl Not<Foo> for Foo {
* fn not(&self) -> Foo { * fn not(&self) -> Foo {
* println("Not-ing!"); * println!("Not-ing!");
* *self * *self
* } * }
* } * }
@ -303,7 +303,7 @@ pub trait Not<Result> {
* *
* impl BitAnd<Foo, Foo> for Foo { * impl BitAnd<Foo, Foo> for Foo {
* fn bitand(&self, _rhs: &Foo) -> Foo { * fn bitand(&self, _rhs: &Foo) -> Foo {
* println("Bitwise And-ing!"); * println!("Bitwise And-ing!");
* *self * *self
* } * }
* } * }
@ -332,7 +332,7 @@ pub trait BitAnd<RHS,Result> {
* *
* impl BitOr<Foo, Foo> for Foo { * impl BitOr<Foo, Foo> for Foo {
* fn bitor(&self, _rhs: &Foo) -> Foo { * fn bitor(&self, _rhs: &Foo) -> Foo {
* println("Bitwise Or-ing!"); * println!("Bitwise Or-ing!");
* *self * *self
* } * }
* } * }
@ -361,7 +361,7 @@ pub trait BitOr<RHS,Result> {
* *
* impl BitXor<Foo, Foo> for Foo { * impl BitXor<Foo, Foo> for Foo {
* fn bitxor(&self, _rhs: &Foo) -> Foo { * fn bitxor(&self, _rhs: &Foo) -> Foo {
* println("Bitwise Xor-ing!"); * println!("Bitwise Xor-ing!");
* *self * *self
* } * }
* } * }
@ -390,7 +390,7 @@ pub trait BitXor<RHS,Result> {
* *
* impl Shl<Foo, Foo> for Foo { * impl Shl<Foo, Foo> for Foo {
* fn shl(&self, _rhs: &Foo) -> Foo { * fn shl(&self, _rhs: &Foo) -> Foo {
* println("Shifting left!"); * println!("Shifting left!");
* *self * *self
* } * }
* } * }
@ -419,7 +419,7 @@ pub trait Shl<RHS,Result> {
* *
* impl Shr<Foo, Foo> for Foo { * impl Shr<Foo, Foo> for Foo {
* fn shr(&self, _rhs: &Foo) -> Foo { * fn shr(&self, _rhs: &Foo) -> Foo {
* println("Shifting right!"); * println!("Shifting right!");
* *self * *self
* } * }
* } * }
@ -449,7 +449,7 @@ pub trait Shr<RHS,Result> {
* *
* impl Index<Foo, Foo> for Foo { * impl Index<Foo, Foo> for Foo {
* fn index(&self, _rhs: &Foo) -> Foo { * fn index(&self, _rhs: &Foo) -> Foo {
* println("Indexing!"); * println!("Indexing!");
* *self * *self
* } * }
* } * }

View file

@ -26,7 +26,7 @@
//! //!
//! // Take a reference to the contained string //! // Take a reference to the contained string
//! match msg { //! match msg {
//! Some(ref m) => io::println(*m), //! Some(ref m) => println!("{}", *m),
//! None => () //! None => ()
//! } //! }
//! //!

View file

@ -40,7 +40,6 @@ pub use result::{Result, Ok, Err};
// Reexported functions // Reexported functions
pub use from_str::from_str; pub use from_str::from_str;
pub use iter::range; pub use iter::range;
pub use io::stdio::{print, println};
// Reexported types and traits // Reexported types and traits

View file

@ -244,7 +244,7 @@ pub trait Rng {
/// ```rust /// ```rust
/// use std::rand::{task_rng, Rng}; /// use std::rand::{task_rng, Rng};
/// ///
/// println(task_rng().gen_ascii_str(10)); /// println!("{}", task_rng().gen_ascii_str(10));
/// ``` /// ```
fn gen_ascii_str(&mut self, len: uint) -> ~str { fn gen_ascii_str(&mut self, len: uint) -> ~str {
static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\ static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\

View file

@ -118,7 +118,7 @@ impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R>>
/// let mut rng = ReseedingRng::new(rand::StdRng::new(), 10, rsdr); /// let mut rng = ReseedingRng::new(rand::StdRng::new(), 10, rsdr);
/// ///
/// // this will repeat, because it gets reseeded very regularly. /// // this will repeat, because it gets reseeded very regularly.
/// println(rng.gen_ascii_str(100)); /// println!("{}", rng.gen_ascii_str(100));
/// } /// }
/// ///
/// ``` /// ```

View file

@ -634,6 +634,7 @@ fn test_repr() {
use prelude::*; use prelude::*;
use str; use str;
use str::Str; use str::Str;
use io::stdio::println;
use util::swap; use util::swap;
use char::is_alphabetic; use char::is_alphabetic;

View file

@ -1591,8 +1591,8 @@ pub trait StrSlice<'a> {
/// assert_eq!(d.len(), 23); /// assert_eq!(d.len(), 23);
/// ///
/// // the two strings *look* the same /// // the two strings *look* the same
/// println(c); /// println!("{}", c);
/// println(d); /// println!("{}", d);
/// ``` /// ```
fn char_len(&self) -> uint; fn char_len(&self) -> uint;

View file

@ -1317,7 +1317,7 @@ pub trait OwnedVector<T> {
/// let v = ~[~"a", ~"b"]; /// let v = ~[~"a", ~"b"];
/// for s in v.move_iter() { /// for s in v.move_iter() {
/// // s has type ~str, not &~str /// // s has type ~str, not &~str
/// println(s); /// println!("{}", s);
/// } /// }
/// ``` /// ```
fn move_iter(self) -> MoveIterator<T>; fn move_iter(self) -> MoveIterator<T>;

View file

@ -1127,7 +1127,7 @@ mod test {
// - two renames of the same var.. can only happen if you use // - two renames of the same var.. can only happen if you use
// local-expand to prevent the inner binding from being renamed // local-expand to prevent the inner binding from being renamed
// during the rename-pass caused by the first: // during the rename-pass caused by the first:
println("about to run bad test"); println!("about to run bad test");
{ let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50), { let sc = unfold_test_sc(~[R(id(a,EMPTY_CTXT),50),
R(id(a,EMPTY_CTXT),51)], R(id(a,EMPTY_CTXT),51)],
EMPTY_CTXT,&mut t); EMPTY_CTXT,&mut t);

View file

@ -1283,7 +1283,7 @@ mod test {
//fn expand_and_resolve(crate_str: @str) -> ast::crate { //fn expand_and_resolve(crate_str: @str) -> ast::crate {
//let expanded_ast = expand_crate_str(crate_str); //let expanded_ast = expand_crate_str(crate_str);
// println(format!("expanded: {:?}\n",expanded_ast)); // println!("expanded: {:?}\n",expanded_ast);
//mtwt_resolve_crate(expanded_ast) //mtwt_resolve_crate(expanded_ast)
//} //}
//fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str { //fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str {
@ -1396,7 +1396,7 @@ mod test {
let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt, let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt,
invalid_name); invalid_name);
if (!(varref_name==binding_name)){ if (!(varref_name==binding_name)){
println("uh oh, should match but doesn't:"); println!("uh oh, should match but doesn't:");
println!("varref: {:?}",varref); println!("varref: {:?}",varref);
println!("binding: {:?}", bindings[binding_idx]); println!("binding: {:?}", bindings[binding_idx]);
ast_util::display_sctable(get_sctable()); ast_util::display_sctable(get_sctable());
@ -1458,7 +1458,7 @@ foo_module!()
&& (@"xx" == (ident_to_str(&p.segments[0].identifier))) && (@"xx" == (ident_to_str(&p.segments[0].identifier)))
}).enumerate() { }).enumerate() {
if (mtwt_resolve(v.segments[0].identifier) != resolved_binding) { if (mtwt_resolve(v.segments[0].identifier) != resolved_binding) {
println("uh oh, xx binding didn't match xx varref:"); println!("uh oh, xx binding didn't match xx varref:");
println!("this is xx varref \\# {:?}",idx); println!("this is xx varref \\# {:?}",idx);
println!("binding: {:?}",cxbind); println!("binding: {:?}",cxbind);
println!("resolves to: {:?}",resolved_binding); println!("resolves to: {:?}",resolved_binding);
@ -1466,7 +1466,7 @@ foo_module!()
println!("resolves to: {:?}", println!("resolves to: {:?}",
mtwt_resolve(v.segments[0].identifier)); mtwt_resolve(v.segments[0].identifier));
let table = get_sctable(); let table = get_sctable();
println("SC table:"); println!("SC table:");
{ {
let table = table.table.borrow(); let table = table.table.borrow();

View file

@ -21,7 +21,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt,
-> base::MacResult { -> base::MacResult {
cx.print_backtrace(); cx.print_backtrace();
println( println!("{}",
print::pprust::tt_to_str( print::pprust::tt_to_str(
&ast::TTDelim(@tt.to_owned()), &ast::TTDelim(@tt.to_owned()),
get_ident_interner())); get_ident_interner()));

View file

@ -983,7 +983,7 @@ mod test {
#[test] fn t1 () { #[test] fn t1 () {
let Env {string_reader} = let Env {string_reader} =
setup(@"/* my source file */ \ setup(@"/* my source file */ \
fn main() { io::println(~\"zebra\"); }\n"); fn main() { println!(\"zebra\"); }\n");
let id = str_to_ident("fn"); let id = str_to_ident("fn");
let tok1 = string_reader.next_token(); let tok1 = string_reader.next_token();
let tok2 = TokenAndSpan{ let tok2 = TokenAndSpan{

View file

@ -20,6 +20,6 @@ pub struct Bar {
impl Foo for Bar { impl Foo for Bar {
#[inline(always)] #[inline(always)]
fn f(&self) { fn f(&self) {
println((*self).x); println!("{}", (*self).x);
} }
} }

View file

@ -16,7 +16,7 @@ pub struct S {
impl Drop for S { impl Drop for S {
fn drop(&mut self) { fn drop(&mut self) {
println("goodbye"); println!("goodbye");
} }
} }

View file

@ -27,7 +27,7 @@ fn timed(label: &str, f: ||) {
} }
fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) { fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
println(" Ascending integers:"); println!(" Ascending integers:");
timed("insert", || { timed("insert", || {
for i in range(0u, n_keys) { for i in range(0u, n_keys) {
@ -49,7 +49,7 @@ fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
} }
fn descending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) { fn descending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
println(" Descending integers:"); println!(" Descending integers:");
timed("insert", || { timed("insert", || {
for i in range(0, n_keys).invert() { for i in range(0, n_keys).invert() {
@ -115,7 +115,8 @@ fn main() {
println!("{} keys", n_keys); println!("{} keys", n_keys);
println("\nTreeMap:"); // FIXME: #9970
println!("{}", "\nTreeMap:");
{ {
let mut map: TreeMap<uint,uint> = TreeMap::new(); let mut map: TreeMap<uint,uint> = TreeMap::new();
@ -128,12 +129,13 @@ fn main() {
} }
{ {
println(" Random integers:"); println!(" Random integers:");
let mut map: TreeMap<uint,uint> = TreeMap::new(); let mut map: TreeMap<uint,uint> = TreeMap::new();
vector(&mut map, n_keys, rand); vector(&mut map, n_keys, rand);
} }
println("\nHashMap:"); // FIXME: #9970
println!("{}", "\nHashMap:");
{ {
let mut map: HashMap<uint,uint> = HashMap::new(); let mut map: HashMap<uint,uint> = HashMap::new();
@ -146,12 +148,13 @@ fn main() {
} }
{ {
println(" Random integers:"); println!(" Random integers:");
let mut map: HashMap<uint,uint> = HashMap::new(); let mut map: HashMap<uint,uint> = HashMap::new();
vector(&mut map, n_keys, rand); vector(&mut map, n_keys, rand);
} }
println("\nTrieMap:"); // FIXME: #9970
println!("{}", "\nTrieMap:");
{ {
let mut map: TrieMap<uint> = TrieMap::new(); let mut map: TrieMap<uint> = TrieMap::new();
@ -164,7 +167,7 @@ fn main() {
} }
{ {
println(" Random integers:"); println!(" Random integers:");
let mut map: TrieMap<uint> = TrieMap::new(); let mut map: TrieMap<uint> = TrieMap::new();
vector(&mut map, n_keys, rand); vector(&mut map, n_keys, rand);
} }

View file

@ -123,7 +123,7 @@ impl Results {
} }
fn write_header(header: &str) { fn write_header(header: &str) {
println(header); println!("{}", header);
} }
fn write_row(label: &str, value: f64) { fn write_row(label: &str, value: f64) {

View file

@ -118,8 +118,8 @@ fn main() {
for y in range(0, 256) { for y in range(0, 256) {
for x in range(0, 256) { for x in range(0, 256) {
print(symbols[(pixels[y*256+x] / 0.2f32) as int]); print!("{}", symbols[(pixels[y*256+x] / 0.2f32) as int]);
} }
println(""); println!("");
} }
} }

View file

@ -78,7 +78,7 @@ fn main() {
}).to_owned_vec(); }).to_owned_vec();
for message in messages.mut_iter() { for message in messages.mut_iter() {
println(*message.get_ref()); println!("{}", *message.get_ref());
} }
println!("long lived tree of depth {}\t check: {}", println!("long lived tree of depth {}\t check: {}",

View file

@ -20,8 +20,8 @@ fn print_complements() {
let all = [Blue, Red, Yellow]; let all = [Blue, Red, Yellow];
for aa in all.iter() { for aa in all.iter() {
for bb in all.iter() { for bb in all.iter() {
println(show_color(*aa) + " + " + show_color(*bb) + println!("{} + {} -> {}", show_color(*aa), show_color(*bb),
" -> " + show_color(transform(*aa, *bb))); show_color(transform(*aa, *bb)));
} }
} }
} }
@ -187,15 +187,15 @@ fn rendezvous(nn: uint, set: ~[color]) {
} }
// print each color in the set // print each color in the set
println(show_color_list(set)); println!("{}", show_color_list(set));
// print each creature's stats // print each creature's stats
for rep in report.iter() { for rep in report.iter() {
println(*rep); println!("{}", *rep);
} }
// print the total number of creatures met // print the total number of creatures met
println(show_number(creatures_met)); println!("{}", show_number(creatures_met));
} }
fn main() { fn main() {
@ -211,10 +211,10 @@ fn main() {
let nn = from_str::<uint>(args[1]).unwrap(); let nn = from_str::<uint>(args[1]).unwrap();
print_complements(); print_complements();
println(""); println!("");
rendezvous(nn, ~[Blue, Red, Yellow]); rendezvous(nn, ~[Blue, Red, Yellow]);
println(""); println!("");
rendezvous(nn, rendezvous(nn,
~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]); ~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]);

View file

@ -64,7 +64,7 @@ fn fannkuch_redux(n: i32) -> i32 {
// Use incremental change to generate another permutation. // Use incremental change to generate another permutation.
loop { loop {
if r == n { if r == n {
println(checksum.to_str()); println!("{}", checksum);
return max_flips_count; return max_flips_count;
} }

View file

@ -223,6 +223,6 @@ fn main() {
// now fetch and print result messages // now fetch and print result messages
for (ii, _sz) in sizes.iter().enumerate() { for (ii, _sz) in sizes.iter().enumerate() {
println(from_child[ii].recv()); println!("{}", from_child[ii].recv());
} }
} }

View file

@ -21,7 +21,7 @@ static LIMIT: f64 = 2.0;
fn main() { fn main() {
let args = std::os::args(); let args = std::os::args();
let (w, mut out) = if args.len() < 2 { let (w, mut out) = if args.len() < 2 {
println("Test mode: do not dump the image because it's not utf8, \ println!("Test mode: do not dump the image because it's not utf8, \
which interferes with the test runner."); which interferes with the test runner.");
(1000, ~DummyWriter as ~Writer) (1000, ~DummyWriter as ~Writer)
} else { } else {

View file

@ -193,11 +193,11 @@ fn to_utf8(raw_sol: &List<u64>) -> ~str {
// Prints a solution in ~str form. // Prints a solution in ~str form.
fn print_sol(sol: &str) { fn print_sol(sol: &str) {
for (i, c) in sol.chars().enumerate() { for (i, c) in sol.chars().enumerate() {
if (i) % 5 == 0 {println("");} if (i) % 5 == 0 { println!(""); }
if (i + 5) % 10 == 0 {print(" ");} if (i + 5) % 10 == 0 { print!(" "); }
print!("{} ", c); print!("{} ", c);
} }
println(""); println!("");
} }
// The data managed during the search // The data managed during the search
@ -277,5 +277,5 @@ fn main () {
println!("{} solutions found", data.nb); println!("{} solutions found", data.nb);
print_sol(data.min); print_sol(data.min);
print_sol(data.max); print_sol(data.max);
println(""); println!("");
} }

View file

@ -80,7 +80,7 @@ fn pidigits(n: int) {
let m = n % 10; let m = n % 10;
if m != 0 { if m != 0 {
for _ in range(m, 10) {print(" ");} for _ in range(m, 10) { print!(" "); }
print!("\t:{}\n", n); print!("\t:{}\n", n);
} }
} }

View file

@ -22,7 +22,7 @@ enum Either<T, U> { Left(T), Right(U) }
fn g() { fn g() {
let mut x: Either<int,f64> = Left(3); let mut x: Either<int,f64> = Left(3);
println(f(&mut x, &x).to_str()); //~ ERROR cannot borrow println!("{}", f(&mut x, &x)); //~ ERROR cannot borrow
} }
fn h() { fn h() {

View file

@ -1,6 +1,6 @@
struct S {f:~str} struct S {f:~str}
impl Drop for S { impl Drop for S {
fn drop(&mut self) { println(self.f); } fn drop(&mut self) { println!("{}", self.f); }
} }
fn move_in_match() { fn move_in_match() {

View file

@ -16,5 +16,5 @@ fn main() {
}, },
None => { fail!() } None => { fail!() }
} }
println(*msg); println!("{}", *msg);
} }

View file

@ -17,6 +17,6 @@ fn main() {
}; };
match &s.x { match &s.x {
&Foo => {} &Foo => {}
&Bar(ref identifier) => println(*identifier) &Bar(ref identifier) => println!("{}", *identifier)
}; };
} }

View file

@ -13,5 +13,5 @@
mod circular_modules_main; mod circular_modules_main;
pub fn say_hello() { pub fn say_hello() {
println(circular_modules_main::hi_str()); println!("{}", circular_modules_main::hi_str());
} }

View file

@ -7,7 +7,7 @@ fn call_bare(f: fn(&str)) {
fn main() { fn main() {
let string = "world!"; let string = "world!";
let f: |&str| = |s| println(s + string); let f: |&str| = |s| println!("{}", s + string);
call_bare(f) //~ ERROR mismatched types call_bare(f) //~ ERROR mismatched types
} }

View file

@ -15,7 +15,7 @@ type Foo = @[u8];
impl Drop for Foo { //~ ERROR the Drop trait may only be implemented impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation //~^ ERROR cannot provide an extension implementation
fn drop(&mut self) { fn drop(&mut self) {
println("kaboom"); println!("kaboom");
} }
} }

View file

@ -14,7 +14,7 @@ struct Foo {
impl Drop for Foo { impl Drop for Foo {
fn drop(&mut self) { fn drop(&mut self) {
println("kaboom"); println!("kaboom");
} }
} }

View file

@ -18,7 +18,7 @@ trait Bar : Drop {
impl Drop for Foo { impl Drop for Foo {
fn drop(&mut self) { fn drop(&mut self) {
println("kaboom"); println!("kaboom");
} }
} }

View file

@ -17,7 +17,7 @@ use extra::arc::Arc;
struct A { y: Arc<int>, x: Arc<int> } struct A { y: Arc<int>, x: Arc<int> }
impl Drop for A { impl Drop for A {
fn drop(&mut self) { println(format!("x={:?}", self.x.get())); } fn drop(&mut self) { println!("x={:?}", self.x.get()); }
} }
fn main() { fn main() {
let a = A { y: Arc::new(1), x: Arc::new(2) }; let a = A { y: Arc::new(1), x: Arc::new(2) };

View file

@ -24,8 +24,8 @@ impl<'self> Serializable<str> for &'self str {
} }
fn main() { fn main() {
println("hello"); println!("hello");
let x = ~"foo"; let x = ~"foo";
let y = x; let y = x;
println(y); println!("{}", y);
} }

View file

@ -22,7 +22,7 @@ struct foo {
impl Drop for foo { impl Drop for foo {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
println("Goodbye, World!"); println!("Goodbye, World!");
self.x.set(self.x.get() + 1); self.x.set(self.x.get() + 1);
} }
} }

View file

@ -31,8 +31,8 @@ impl Eq for Lol {
fn main() { fn main() {
if Lol(2) == Lol(4) { if Lol(2) == Lol(4) {
println("2 == 4"); println!("2 == 4");
} else { } else {
println("2 != 4"); println!("2 != 4");
} }
} }

View file

@ -28,5 +28,5 @@ impl ToStr for Point { //~ ERROR implements a method not defined in the trait
fn main() { fn main() {
let p = Point::new(0.0f, 0.0f); let p = Point::new(0.0f, 0.0f);
io::println(p.to_str()); println!("{}", p.to_str());
} }

View file

@ -12,13 +12,14 @@
macro_rules! print_hd_tl ( macro_rules! print_hd_tl (
($field_hd:ident, $($field_tl:ident),+) => ({ ($field_hd:ident, $($field_tl:ident),+) => ({
print(stringify!($field)); //~ ERROR unknown macro variable print!("{}", stringify!($field)); //~ ERROR unknown macro variable
print("::["); print!("::[");
$( $(
print(stringify!($field_tl)); print!("{}", stringify!($field_tl));
print(", "); print!(", ");
)+ )+
print("]\n"); // FIXME: #9970
print!("{}", "]\n");
}) })
) )

View file

@ -7,7 +7,7 @@ fn main() {
} }
match ~[~"foo", ~"bar", ~"baz"] { match ~[~"foo", ~"bar", ~"baz"] {
[a, _, _, ..] => { println(a); } [a, _, _, ..] => { println!("{}", a); }
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern [~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
_ => { } _ => { }
} }

View file

@ -18,7 +18,7 @@ fn main() {
f(&s, |hellothere| { f(&s, |hellothere| {
match hellothere.x { match hellothere.x {
~Foo(_) => {} ~Foo(_) => {}
~Bar(x) => println(x.to_str()), //~ ERROR cannot move out ~Bar(x) => println!("{}", x.to_str()), //~ ERROR cannot move out
~Baz => {} ~Baz => {}
} }
}) })

View file

@ -3,7 +3,7 @@ use std::task;
fn main() { fn main() {
let x = ~"Hello world!"; let x = ~"Hello world!";
do task::spawn { do task::spawn {
println(x); println!("{}", x);
} }
println(x); //~ ERROR use of moved value println!("{}", x); //~ ERROR use of moved value
} }

View file

@ -25,8 +25,7 @@ mod foo {
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() { fn foo() {
print("foo"); //~ ERROR: unresolved name drop(2) //~ ERROR: unresolved name
println("bar"); //~ ERROR: unresolved name
} }
} }
@ -38,8 +37,7 @@ mod foo {
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() { fn foo() {
print("foo"); //~ ERROR: unresolved name drop(2) //~ ERROR: unresolved name
println("bar"); //~ ERROR: unresolved name
} }
} }
@ -54,8 +52,7 @@ fn qux() {
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn foo() { fn foo() {
print("foo"); //~ ERROR: unresolved name drop(2) //~ ERROR: unresolved name
println("bar"); //~ ERROR: unresolved name
} }
} }
} }
@ -63,6 +60,5 @@ fn qux() {
fn main() { fn main() {
// these should work fine // these should work fine
print("foo"); drop(2)
println("bar");
} }

View file

@ -24,6 +24,5 @@ impl ToStr for Test {} //~ ERROR: attempt to implement a nonexistent trait
impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait impl Writer for Test {} //~ ERROR: attempt to implement a nonexistent trait
fn main() { fn main() {
print("foo"); //~ ERROR: unresolved name drop(2) //~ ERROR: unresolved name
println("bar"); //~ ERROR: unresolved name
} }

View file

@ -9,6 +9,6 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let f = |3: int| println("hello"); //~ ERROR refutable pattern let f = |3: int| println!("hello"); //~ ERROR refutable pattern
f(4); f(4);
} }

View file

@ -18,7 +18,7 @@ struct Foo {
impl Drop for Foo { impl Drop for Foo {
fn drop(&mut self) { fn drop(&mut self) {
println("Goodbye!"); println!("Goodbye!");
} }
} }

View file

@ -1,7 +1,7 @@
enum E {} enum E {}
fn f(e: E) { fn f(e: E) {
println((e as int).to_str()); //~ ERROR non-scalar cast println!("{}", (e as int).to_str()); //~ ERROR non-scalar cast
} }
fn main() {} fn main() {}

View file

@ -22,7 +22,7 @@ impl Drop for Bar {
impl Foo for Bar { impl Foo for Bar {
fn f(&self) { fn f(&self) {
println("hi"); println!("hi");
} }
} }

View file

@ -11,5 +11,5 @@
fn main() { fn main() {
let x = ~"Hello!"; let x = ~"Hello!";
let _y = x; let _y = x;
println(x); //~ ERROR use of moved value println!("{}", x); //~ ERROR use of moved value
} }

View file

@ -17,5 +17,5 @@ impl S {
fn main() { fn main() {
let x = S { x: 1 }; let x = S { x: 1 };
println(x.foo().to_str()); println!("{}", x.foo());
} }

View file

@ -13,5 +13,5 @@ impl S {
fn main() { fn main() {
let x = S { x: ~1 }; let x = S { x: ~1 };
println(x.foo().to_str()); println!("{}", x.foo());
} }

View file

@ -163,7 +163,7 @@ fn assignment(mut a: u64, b: u64, c: f64) {
} }
fn function_call(x: u64, y: u64, z: f64) { fn function_call(x: u64, y: u64, z: f64) {
print("Hi!") std::io::stdio::print("Hi!")
} }
fn identifier(x: u64, y: u64, z: f64) -> u64 { fn identifier(x: u64, y: u64, z: f64) -> u64 {

View file

@ -162,7 +162,7 @@ fn assignment(mut a: u64, b: u64, c: f64) {
#[no_split_stack] #[no_split_stack]
fn function_call(x: u64, y: u64, z: f64) { fn function_call(x: u64, y: u64, z: f64) {
print("Hi!") std::io::stdio::print("Hi!")
} }
#[no_split_stack] #[no_split_stack]

View file

@ -20,5 +20,5 @@ impl Foo {
pub fn main() { pub fn main() {
let x = Foo::new(); let x = Foo::new();
println(x.x.to_str()); println!("{}", x.x);
} }

View file

@ -16,5 +16,5 @@ use anon_trait_static_method_lib::Foo;
pub fn main() { pub fn main() {
let x = Foo::new(); let x = Foo::new();
println(x.x.to_str()); println!("{}", x.x);
} }

View file

@ -28,7 +28,7 @@ impl<T:Baz> Foo for T {
impl Baz for Bar { impl Baz for Bar {
fn g(&self) { fn g(&self) {
println(self.x.to_str()); println!("{}", self.x);
} }
} }

View file

@ -10,5 +10,5 @@
pub fn main() { pub fn main() {
let x: &'static str = "foo"; let x: &'static str = "foo";
println(x); println!("{}", x);
} }

View file

@ -16,7 +16,7 @@ trait Foo {
impl Foo for int { impl Foo for int {
fn foo(@self) { fn foo(@self) {
println("Hello world!"); println!("Hello world!");
} }
} }

View file

@ -2,9 +2,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
use std::cast; use std::cast;
use std::io::stdio::println;
fn call_it(f: proc(~str) -> ~str) { fn call_it(f: proc(~str) -> ~str) {
println(f(~"Fred")) println!("{}", f(~"Fred"))
} }
fn call_a_thunk(f: ||) { fn call_a_thunk(f: ||) {
@ -57,9 +58,9 @@ pub fn main() {
// Closures // Closures
call_a_thunk(|| println("Hello world!")); call_a_thunk(|| println!("Hello world!"));
call_this(|s| println(s)); call_this(|s| println!("{}", s));
call_that(|x, y| *x + *y); call_that(|x, y| *x + *y);

View file

@ -11,7 +11,7 @@
trait Foo { trait Foo {
fn f(&self) { fn f(&self) {
println("Hello!"); println!("Hello!");
self.g(); self.g();
} }
fn g(&self); fn g(&self);
@ -23,7 +23,7 @@ struct A {
impl Foo for A { impl Foo for A {
fn g(&self) { fn g(&self) {
println("Goodbye!"); println!("Goodbye!");
} }
} }

View file

@ -15,7 +15,7 @@ struct S<T> {
#[unsafe_destructor] #[unsafe_destructor]
impl<T> ::std::ops::Drop for S<T> { impl<T> ::std::ops::Drop for S<T> {
fn drop(&mut self) { fn drop(&mut self) {
println("bye"); println!("bye");
} }
} }

View file

@ -14,7 +14,7 @@ struct Foo {
impl Drop for Foo { impl Drop for Foo {
fn drop(&mut self) { fn drop(&mut self) {
println("bye"); println!("bye");
} }
} }

View file

@ -2,15 +2,15 @@
pub fn main() { pub fn main() {
let v: ~[int] = ~[ 1, ..5 ]; let v: ~[int] = ~[ 1, ..5 ];
println(v[0].to_str()); println!("{}", v[0]);
println(v[1].to_str()); println!("{}", v[1]);
println(v[2].to_str()); println!("{}", v[2]);
println(v[3].to_str()); println!("{}", v[3]);
println(v[4].to_str()); println!("{}", v[4]);
let v: @[int] = @[ 2, ..5 ]; let v: @[int] = @[ 2, ..5 ];
println(v[0].to_str()); println!("{}", v[0]);
println(v[1].to_str()); println!("{}", v[1]);
println(v[2].to_str()); println!("{}", v[2]);
println(v[3].to_str()); println!("{}", v[3]);
println(v[4].to_str()); println!("{}", v[4]);
} }

View file

@ -16,5 +16,5 @@ extern mod extra;
use extra::json::Object; use extra::json::Object;
pub fn main() { pub fn main() {
println("Hello world!"); println!("Hello world!");
} }

View file

@ -14,9 +14,9 @@ struct S {
pub fn main() { pub fn main() {
let x: f32 = 4.0; let x: f32 = 4.0;
println(x.to_str()); println!("{}", x);
let y: f64 = 64.0; let y: f64 = 64.0;
println(y.to_str()); println!("{}", y);
let z = S { z: 1.0 }; let z = S { z: 1.0 };
println(z.z.to_str()); println!("{}", z.z);
} }

View file

@ -11,7 +11,7 @@
pub fn main() { pub fn main() {
let v : &[(int,int)] = &[ (1, 2), (3, 4), (5, 6) ]; let v : &[(int,int)] = &[ (1, 2), (3, 4), (5, 6) ];
for &(x, y) in v.iter() { for &(x, y) in v.iter() {
println(y.to_str()); println!("{}", y);
println(x.to_str()); println!("{}", x);
} }
} }

View file

@ -9,5 +9,5 @@
// except according to those terms. // except according to those terms.
pub fn main() { pub fn main() {
println("hello, world"); println!("hello, world");
} }

View file

@ -6,5 +6,5 @@ extern mod impl_privacy_xc_2;
pub fn main() { pub fn main() {
let fish1 = impl_privacy_xc_2::Fish { x: 1 }; let fish1 = impl_privacy_xc_2::Fish { x: 1 };
let fish2 = impl_privacy_xc_2::Fish { x: 2 }; let fish2 = impl_privacy_xc_2::Fish { x: 2 };
println(if fish1.eq(&fish2) { "yes" } else { "no " }); if fish1.eq(&fish2) { println!("yes") } else { println!("no") };
} }

View file

@ -15,7 +15,7 @@ struct trie_node {
fn print_str_vector(vector: ~[~str]) { fn print_str_vector(vector: ~[~str]) {
for string in vector.iter() { for string in vector.iter() {
println(*string); println!("{}", *string);
} }
} }

Some files were not shown because too many files have changed in this diff Show more