Skip to content

Commit 7f01f0b

Browse files
committed
---
yaml --- r: 82047 b: refs/heads/master c: f6df7ab h: refs/heads/master i: 82045: 7da9315 82043: c1cbcb4 82039: 43e2cd5 82031: 7f5c862 82015: de6181b 81983: a224f2f 81919: 274cca6 v: v3
1 parent 5e0e638 commit 7f01f0b

File tree

819 files changed

+4795
-4797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

819 files changed

+4795
-4797
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1f52cf439bec551cd88010fa6d9bcdf681a8b3af
2+
refs/heads/master: f6df7ab839fef099af163463ae99b9541d3d12c5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
8888
CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
8989
endif
9090

91-
CFG_RUSTC_FLAGS := $(RUSTFLAGS) --cfg nofmt
91+
CFG_RUSTC_FLAGS := $(RUSTFLAGS)
9292
CFG_GCCISH_CFLAGS :=
9393
CFG_GCCISH_LINK_FLAGS :=
9494

trunk/doc/rust.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,15 @@ mod math {
683683
type complex = (f64, f64);
684684
fn sin(f: f64) -> f64 {
685685
...
686-
# fail2!();
686+
# fail!();
687687
}
688688
fn cos(f: f64) -> f64 {
689689
...
690-
# fail2!();
690+
# fail!();
691691
}
692692
fn tan(f: f64) -> f64 {
693693
...
694-
# fail2!();
694+
# fail!();
695695
}
696696
}
697697
~~~~~~~~
@@ -817,14 +817,12 @@ An example of `use` declarations:
817817
use std::num::sin;
818818
use std::option::{Some, None};
819819
820-
# fn foo<T>(_: T){}
821-
822820
fn main() {
823-
// Equivalent to 'std::num::sin(1.0);'
824-
sin(1.0);
821+
// Equivalent to 'info!(std::num::sin(1.0));'
822+
info!(sin(1.0));
825823
826-
// Equivalent to 'foo(~[std::option::Some(1.0), std::option::None]);'
827-
foo(~[Some(1.0), None]);
824+
// Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);'
825+
info!(~[Some(1.0), None]);
828826
}
829827
~~~~
830828

@@ -1042,8 +1040,8 @@ output slot type would normally be. For example:
10421040

10431041
~~~~
10441042
fn my_err(s: &str) -> ! {
1045-
info2!("{}", s);
1046-
fail2!();
1043+
info!(s);
1044+
fail!();
10471045
}
10481046
~~~~
10491047

@@ -1061,7 +1059,7 @@ were declared without the `!` annotation, the following code would not
10611059
typecheck:
10621060

10631061
~~~~
1064-
# fn my_err(s: &str) -> ! { fail2!() }
1062+
# fn my_err(s: &str) -> ! { fail!() }
10651063
10661064
fn f(i: int) -> int {
10671065
if i == 42 {
@@ -2384,7 +2382,7 @@ fn ten_times(f: &fn(int)) {
23842382
}
23852383
}
23862384
2387-
ten_times(|j| println!("hello, {}", j));
2385+
ten_times(|j| println(fmt!("hello, %d", j)));
23882386
23892387
~~~~
23902388

@@ -2596,9 +2594,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
25962594
let x: List<int> = Cons(10, @Cons(11, @Nil));
25972595
25982596
match x {
2599-
Cons(_, @Nil) => fail2!("singleton list"),
2597+
Cons(_, @Nil) => fail!("singleton list"),
26002598
Cons(*) => return,
2601-
Nil => fail2!("empty list")
2599+
Nil => fail!("empty list")
26022600
}
26032601
~~~~
26042602

@@ -2635,7 +2633,7 @@ match x {
26352633
return;
26362634
}
26372635
_ => {
2638-
fail2!();
2636+
fail!();
26392637
}
26402638
}
26412639
~~~~
@@ -2689,7 +2687,7 @@ guard may refer to the variables bound within the pattern they follow.
26892687
let message = match maybe_digit {
26902688
Some(x) if x < 10 => process_digit(x),
26912689
Some(x) => process_other(x),
2692-
None => fail2!()
2690+
None => fail!()
26932691
};
26942692
~~~~
26952693

@@ -3474,20 +3472,20 @@ that demonstrates all four of them:
34743472

34753473
```rust
34763474
fn main() {
3477-
error2!("This is an error log")
3478-
warn2!("This is a warn log")
3479-
info2!("this is an info log")
3480-
debug2!("This is a debug log")
3475+
error!("This is an error log")
3476+
warn!("This is a warn log")
3477+
info!("this is an info log")
3478+
debug!("This is a debug log")
34813479
}
34823480
```
34833481

34843482
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
34853483

34863484
```bash
34873485
$ RUST_LOG=rust=3 ./rust
3488-
This is an error log
3489-
This is a warn log
3490-
this is an info log
3486+
rust: ~"\"This is an error log\""
3487+
rust: ~"\"This is a warn log\""
3488+
rust: ~"\"this is an info log\""
34913489
```
34923490

34933491
# Appendix: Rationales and design tradeoffs

trunk/doc/tutorial-conditions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use std::int;
6666
fn main() {
6767
let pairs = read_int_pairs();
6868
for &(a,b) in pairs.iter() {
69-
println!("{:4.4d}, {:4.4d}", a, b);
69+
println(fmt!("%4.4d, %4.4d", a, b));
7070
}
7171
}
7272
@@ -281,7 +281,7 @@ fn main() {
281281
// The protected logic.
282282
let pairs = read_int_pairs();
283283
for &(a,b) in pairs.iter() {
284-
println!("{:4.4d}, {:4.4d}", a, b);
284+
println(fmt!("%4.4d, %4.4d", a, b));
285285
}
286286
287287
};
@@ -387,7 +387,7 @@ condition! {
387387
fn main() {
388388
let pairs = read_int_pairs();
389389
for &(a,b) in pairs.iter() {
390-
println!("{:4.4d}, {:4.4d}", a, b);
390+
println(fmt!("%4.4d, %4.4d", a, b));
391391
}
392392
}
393393
@@ -462,7 +462,7 @@ fn main() {
462462
// The protected logic.
463463
let pairs = read_int_pairs();
464464
for &(a,b) in pairs.iter() {
465-
println!("{:4.4d}, {:4.4d}", a, b);
465+
println(fmt!("%4.4d, %4.4d", a, b));
466466
}
467467
468468
}
@@ -540,7 +540,7 @@ fn main() {
540540
// The protected logic.
541541
let pairs = read_int_pairs();
542542
for &(a,b) in pairs.iter() {
543-
println!("{:4.4d}, {:4.4d}", a, b);
543+
println(fmt!("%4.4d, %4.4d", a, b));
544544
}
545545
546546
}
@@ -636,7 +636,7 @@ fn main() {
636636
// The protected logic.
637637
let pairs = read_int_pairs();
638638
for &(a,b) in pairs.iter() {
639-
println!("{:4.4d}, {:4.4d}", a, b);
639+
println(fmt!("%4.4d, %4.4d", a, b));
640640
}
641641
642642
}
@@ -766,7 +766,7 @@ fn main() {
766766
// The protected logic.
767767
let pairs = read_int_pairs();
768768
for &(a,b) in pairs.iter() {
769-
println!("{:4.4d}, {:4.4d}", a, b);
769+
println(fmt!("%4.4d, %4.4d", a, b));
770770
}
771771
772772
}

trunk/doc/tutorial-macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ match x {
226226
// complicated stuff goes here
227227
return result + val;
228228
},
229-
_ => fail2!("Didn't get good_2")
229+
_ => fail!("Didn't get good_2")
230230
}
231231
}
232232
_ => return 0 // default value
@@ -268,7 +268,7 @@ macro_rules! biased_match (
268268
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
269269
binds g1, val )
270270
biased_match!((g1.body) ~ (good_2(result) )
271-
else { fail2!("Didn't get good_2") };
271+
else { fail!("Didn't get good_2") };
272272
binds result )
273273
// complicated stuff goes here
274274
return result + val;
@@ -369,7 +369,7 @@ macro_rules! biased_match (
369369
# fn f(x: t1) -> uint {
370370
biased_match!(
371371
(x) ~ (good_1(g1, val)) else { return 0 };
372-
(g1.body) ~ (good_2(result) ) else { fail2!("Didn't get good_2") };
372+
(g1.body) ~ (good_2(result) ) else { fail!("Didn't get good_2") };
373373
binds val, result )
374374
// complicated stuff goes here
375375
return result + val;

trunk/doc/tutorial-tasks.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ execution. Like any closure, the function passed to `spawn` may capture
9999
an environment that it carries across tasks.
100100

101101
~~~
102+
# use std::io::println;
102103
# use std::task::spawn;
103104
# fn generate_task_number() -> int { 0 }
104105
// Generate some state locally
105106
let child_task_number = generate_task_number();
106107
107108
do spawn {
108109
// Capture it in the remote task
109-
println!("I am child number {}", child_task_number);
110+
println(fmt!("I am child number %d", child_task_number));
110111
}
111112
~~~
112113

@@ -281,7 +282,7 @@ fn fib(n: uint) -> uint {
281282
282283
let mut delayed_fib = extra::future::Future::spawn (|| fib(50) );
283284
make_a_sandwich();
284-
println!("fib(50) = {:?}", delayed_fib.get())
285+
println(fmt!("fib(50) = %?", delayed_fib.get()))
285286
~~~
286287

287288
The call to `future::spawn` returns immediately a `future` object regardless of how long it
@@ -309,7 +310,7 @@ fn main() {
309310
for ft in futures.mut_iter() {
310311
final_res += ft.get();
311312
}
312-
println!("π^2/6 is not far from : {}", final_res);
313+
println(fmt!("π^2/6 is not far from : %?", final_res));
313314
}
314315
~~~
315316

@@ -337,7 +338,7 @@ fn pnorm(nums: &~[float], p: uint) -> float {
337338
338339
fn main() {
339340
let numbers = vec::from_fn(1000000, |_| rand::random::<float>());
340-
println!("Inf-norm = {}", *numbers.iter().max().unwrap());
341+
println(fmt!("Inf-norm = %?", *numbers.iter().max().unwrap()));
341342
342343
let numbers_arc = Arc::new(numbers);
343344
@@ -348,7 +349,7 @@ fn main() {
348349
do spawn {
349350
let local_arc : Arc<~[float]> = port.recv();
350351
let task_numbers = local_arc.get();
351-
println!("{}-norm = {}", num, pnorm(task_numbers, num));
352+
println(fmt!("%u-norm = %?", num, pnorm(task_numbers, num)));
352353
}
353354
}
354355
}

trunk/doc/tutorial.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ let hi = "hi";
225225
let mut count = 0;
226226
227227
while count < 10 {
228-
println!("count: {}", count);
228+
println(fmt!("count: %?", count));
229229
count += 1;
230230
}
231231
~~~~
@@ -388,26 +388,23 @@ assert!(y == 4u);
388388
but are instead provided by the libraries. To make it clear to the reader when
389389
a name refers to a syntax extension, the names of all syntax extensions end
390390
with `!`. The standard library defines a few syntax extensions, the most
391-
useful of which is [`format!`][fmt], a `sprintf`-like text formatter that you
392-
will often see in examples, and its related family of macros: `print!`,
393-
`println!`, and `write!`.
391+
useful of which is `fmt!`, a `sprintf`-style text formatter that you will
392+
often see in examples.
394393

395-
`format!` draws syntax from python, but contains many of the same principles
396-
that [printf][pf] has. Unlike printf, `format!` will give you a compile-time
397-
error when the types of the directives don't match the types of the arguments.
394+
`fmt!` supports most of the directives that [printf][pf] supports, but unlike
395+
printf, will give you a compile-time error when the types of the directives
396+
don't match the types of the arguments.
398397

399398
~~~~
400399
# let mystery_object = ();
401400
402-
// {} will print the "default format" of a type
403-
println!("{} is {}", "the answer", 43);
401+
println(fmt!("%s is %d", "the answer", 43));
404402
405-
// {:?} will conveniently print any type
406-
println!("what is this thing: {:?}", mystery_object);
403+
// %? will conveniently print any type
404+
println(fmt!("what is this thing: %?", mystery_object));
407405
~~~~
408406

409407
[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf
410-
[fmt]: http://static.rust-lang.org/doc/master/std/fmt/index.html
411408

412409
You can define your own syntax extensions with the macro system. For details, see the [macro tutorial][macros].
413410

@@ -740,7 +737,7 @@ fn area(sh: Shape) -> float {
740737
match sh {
741738
Circle { radius: radius, _ } => float::consts::pi * square(radius),
742739
Rectangle { top_left: top_left, bottom_right: bottom_right } => {
743-
(bottom_right.x - top_left.x) * (top_left.y - bottom_right.y)
740+
(bottom_right.x - top_left.x) * (top_left.y - bottom_right.y)
744741
}
745742
}
746743
}
@@ -756,7 +753,7 @@ unit, `()`, as the empty tuple if you like).
756753
~~~~
757754
let mytup: (int, int, float) = (10, 20, 30.0);
758755
match mytup {
759-
(a, b, c) => info2!("{}", a + b + (c as int))
756+
(a, b, c) => info!(a + b + (c as int))
760757
}
761758
~~~~
762759

@@ -772,7 +769,7 @@ For example:
772769
struct MyTup(int, int, float);
773770
let mytup: MyTup = MyTup(10, 20, 30.0);
774771
match mytup {
775-
MyTup(a, b, c) => info2!("{}", a + b + (c as int))
772+
MyTup(a, b, c) => info!(a + b + (c as int))
776773
}
777774
~~~~
778775

@@ -1241,7 +1238,7 @@ something silly like
12411238
~~~
12421239
# struct Point { x: float, y: float }
12431240
let point = &@~Point { x: 10f, y: 20f };
1244-
println!("{:f}", point.x);
1241+
println(fmt!("%f", point.x));
12451242
~~~
12461243
12471244
The indexing operator (`[]`) also auto-dereferences.
@@ -1446,7 +1443,7 @@ the enclosing scope.
14461443
fn call_closure_with_ten(b: &fn(int)) { b(10); }
14471444
14481445
let captured_var = 20;
1449-
let closure = |arg| println!("captured_var={}, arg={}", captured_var, arg);
1446+
let closure = |arg| println(fmt!("captured_var=%d, arg=%d", captured_var, arg));
14501447
14511448
call_closure_with_ten(closure);
14521449
~~~~
@@ -1569,7 +1566,7 @@ arguments.
15691566
use std::task::spawn;
15701567
15711568
do spawn() || {
1572-
debug2!("I'm a task, whatever");
1569+
debug!("I'm a task, whatever");
15731570
}
15741571
~~~~
15751572

@@ -1581,7 +1578,7 @@ may be omitted from `do` expressions.
15811578
use std::task::spawn;
15821579
15831580
do spawn {
1584-
debug2!("Kablam!");
1581+
debug!("Kablam!");
15851582
}
15861583
~~~~
15871584

@@ -1919,7 +1916,7 @@ and `~str`.
19191916
~~~~
19201917
# trait Printable { fn print(&self); }
19211918
impl Printable for int {
1922-
fn print(&self) { println!("{}", *self) }
1919+
fn print(&self) { println(fmt!("%d", *self)) }
19231920
}
19241921
19251922
impl Printable for ~str {

0 commit comments

Comments
 (0)