Skip to content

Commit 63f3537

Browse files
committed
---
yaml --- r: 152947 b: refs/heads/try2 c: ca7fb82 h: refs/heads/master i: 152945: 61d5ea9 152943: e273e08 v: v3
1 parent e535f0c commit 63f3537

File tree

345 files changed

+1203
-1162
lines changed

Some content is hidden

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

345 files changed

+1203
-1162
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: ff94f867d29a90ab59060c10a62f65994776a8c4
8+
refs/heads/try2: ca7fb82e0b9fb47e4addcee7b993993e7ce27fde
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-unsafe.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ impl<T: Send> Drop for Unique<T> {
267267
// A comparison between the built-in `Box` and this reimplementation
268268
fn main() {
269269
{
270-
let mut x = box 5i;
270+
let mut x = box 5;
271271
*x = 10;
272272
} // `x` is freed here
273273
274274
{
275-
let mut y = Unique::new(5i);
275+
let mut y = Unique::new(5);
276276
*y.borrow_mut() = 10;
277277
} // `y` is freed here
278278
}
@@ -678,7 +678,7 @@ unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
678678
679679
#[start]
680680
fn main(argc: int, argv: *const *const u8) -> int {
681-
let x = box 1i;
681+
let x = box 1;
682682
683683
0
684684
}

branches/try2/src/doc/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Check it out:
133133
```
134134
135135
fn dangling() -> Box<int> {
136-
let i = box 1234i;
136+
let i = box 1234;
137137
return i;
138138
}
139139
@@ -143,16 +143,16 @@ fn add_one() -> int {
143143
}
144144
```
145145

146-
Now instead of a stack allocated `1234i`,
147-
we have a heap allocated `box 1234i`.
146+
Now instead of a stack allocated `1234`,
147+
we have a heap allocated `box 1234`.
148148
Whereas `&` borrows a pointer to existing memory,
149149
creating an owned box allocates memory on the heap and places a value in it,
150150
giving you the sole pointer to that memory.
151151
You can roughly compare these two lines:
152152

153153
```
154154
// Rust
155-
let i = box 1234i;
155+
let i = box 1234;
156156
```
157157

158158
```cpp

branches/try2/src/doc/rust.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,17 @@ of integer literal suffix:
442442
The type of an _unsuffixed_ integer literal is determined by type inference.
443443
If an integer type can be _uniquely_ determined from the surrounding program
444444
context, the unsuffixed integer literal has that type. If the program context
445-
underconstrains the type, it is considered a static type error;
446-
if the program context overconstrains the type,
447-
it is also considered a static type error.
445+
underconstrains the type, the unsuffixed integer literal's type is `int`; if
446+
the program context overconstrains the type, it is considered a static type
447+
error.
448448

449449
Examples of integer literals of various forms:
450450

451451
~~~~
452-
123i; // type int
452+
123; 0xff00; // type determined by program context
453+
// defaults to int in absence of type
454+
// information
455+
453456
123u; // type uint
454457
123_u; // type uint
455458
0xff_u8; // type u8
@@ -466,19 +469,17 @@ A _floating-point literal_ has one of two forms:
466469
second decimal literal.
467470
* A single _decimal literal_ followed by an _exponent_.
468471

469-
By default, a floating-point literal has a generic type,
470-
and, like integer literals, the type must be uniquely determined
471-
from the context.
472-
A floating-point literal may be followed (immediately, without any
472+
By default, a floating-point literal has a generic type, but will fall back to
473+
`f64`. A floating-point literal may be followed (immediately, without any
473474
spaces) by a _floating-point suffix_, which changes the type of the literal.
474475
There are two floating-point suffixes: `f32`, and `f64` (the 32-bit and 64-bit
475476
floating point types).
476477

477478
Examples of floating-point literals of various forms:
478479

479480
~~~~
480-
123.0f64; // type f64
481-
0.1f64; // type f64
481+
123.0; // type f64
482+
0.1; // type f64
482483
0.1f32; // type f32
483484
12E+99_f64; // type f64
484485
~~~~
@@ -2699,9 +2700,9 @@ must be a constant expression that can be evaluated at compile time, such
26992700
as a [literal](#literals) or a [static item](#static-items).
27002701

27012702
~~~~
2702-
[1i, 2, 3, 4];
2703+
[1, 2, 3, 4];
27032704
["a", "b", "c", "d"];
2704-
[0i, ..128]; // vector with 128 zeros
2705+
[0, ..128]; // vector with 128 zeros
27052706
[0u8, 0u8, 0u8, 0u8];
27062707
~~~~
27072708

@@ -2880,7 +2881,7 @@ equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
28802881
Evaluating an assignment expression [either copies or moves](#moved-and-copied-types) its right-hand operand to its left-hand operand.
28812882

28822883
~~~~
2883-
# let mut x = 0i;
2884+
# let mut x = 0;
28842885
# let y = 0;
28852886
28862887
x = y;
@@ -2931,7 +2932,7 @@ paren_expr : '(' expr ')' ;
29312932
An example of a parenthesized expression:
29322933

29332934
~~~~
2934-
let x: int = (2 + 3) * 4;
2935+
let x = (2 + 3) * 4;
29352936
~~~~
29362937

29372938

@@ -3015,7 +3016,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
30153016
An example:
30163017

30173018
~~~~
3018-
let mut i = 0u;
3019+
let mut i = 0;
30193020
30203021
while i < 10 {
30213022
println!("hello");
@@ -3261,7 +3262,7 @@ Patterns can also dereference pointers by using the `&`,
32613262
on `x: &int` are equivalent:
32623263

32633264
~~~~
3264-
# let x = &3i;
3265+
# let x = &3;
32653266
let y = match *x { 0 => "zero", _ => "some" };
32663267
let z = match x { &0 => "zero", _ => "some" };
32673268
@@ -3284,7 +3285,7 @@ A range of values may be specified with `..`.
32843285
For example:
32853286

32863287
~~~~
3287-
# let x = 2i;
3288+
# let x = 2;
32883289
32893290
let message = match x {
32903291
0 | 1 => "not many",

branches/try2/src/doc/tutorial.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ write function, variable, and module names with lowercase letters, using
262262
underscores where they help readability, while writing types in camel case.
263263

264264
~~~
265-
let my_variable = 100i;
265+
let my_variable = 100;
266266
type MyType = int; // primitive types are _not_ camel case
267267
~~~
268268

@@ -276,7 +276,7 @@ write a piece of code like this:
276276

277277
~~~~
278278
# let item = "salad";
279-
let price: f64;
279+
let price;
280280
if item == "salad" {
281281
price = 3.50;
282282
} else if item == "muffin" {
@@ -290,7 +290,7 @@ But, in Rust, you don't have to repeat the name `price`:
290290

291291
~~~~
292292
# let item = "salad";
293-
let price: f64 =
293+
let price =
294294
if item == "salad" {
295295
3.50
296296
} else if item == "muffin" {
@@ -337,10 +337,11 @@ suffix that can be used to indicate the type of a literal: `i` for `int`,
337337
In the absence of an integer literal suffix, Rust will infer the
338338
integer type based on type annotations and function signatures in the
339339
surrounding program. In the absence of any type information at all,
340-
Rust will report an error and request that the type be specified explicitly.
340+
Rust will assume that an unsuffixed integer literal has type
341+
`int`.
341342

342343
~~~~
343-
let a: int = 1; // `a` is an `int`
344+
let a = 1; // `a` is an `int`
344345
let b = 10i; // `b` is an `int`, due to the `i` suffix
345346
let c = 100u; // `c` is a `uint`
346347
let d = 1000i32; // `d` is an `i32`
@@ -474,7 +475,7 @@ against each pattern in order until one matches. The matching pattern
474475
executes its corresponding arm.
475476

476477
~~~~
477-
let my_number = 1i;
478+
let my_number = 1;
478479
match my_number {
479480
0 => println!("zero"),
480481
1 | 2 => println!("one or two"),
@@ -500,7 +501,7 @@ matches any single value. (`..`) is a different wildcard that can match
500501
one or more fields in an `enum` variant.
501502

502503
~~~
503-
# let my_number = 1i;
504+
# let my_number = 1;
504505
match my_number {
505506
0 => { println!("zero") }
506507
_ => { println!("something else") }
@@ -583,7 +584,7 @@ keyword `break` aborts the loop, and `continue` aborts the current
583584
iteration and continues with the next.
584585

585586
~~~~
586-
let mut cake_amount = 8i;
587+
let mut cake_amount = 8;
587588
while cake_amount > 0 {
588589
cake_amount -= 1;
589590
}
@@ -943,7 +944,7 @@ The `box` operator performs memory allocation on the heap:
943944
~~~~
944945
{
945946
// an integer allocated on the heap
946-
let y = box 10i;
947+
let y = box 10;
947948
}
948949
// the destructor frees the heap memory as soon as `y` goes out of scope
949950
~~~~
@@ -1164,7 +1165,7 @@ let z = x;
11641165
The mutability of a value may be changed by moving it to a new owner:
11651166

11661167
~~~~
1167-
let r = box 13i;
1168+
let r = box 13;
11681169
let mut s = r; // box becomes mutable
11691170
*s += 1;
11701171
let t = s; // box becomes immutable
@@ -1284,9 +1285,9 @@ Using the generic `List<T>` works much like before, thanks to type inference:
12841285
# Cons(value, box xs)
12851286
# }
12861287
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
1287-
xs = prepend(xs, 10i); // Here the compiler infers `xs`'s type as `List<int>`.
1288-
xs = prepend(xs, 15i);
1289-
xs = prepend(xs, 20i);
1288+
xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
1289+
xs = prepend(xs, 15);
1290+
xs = prepend(xs, 20);
12901291
~~~
12911292

12921293
The code sample above demonstrates type inference making most type annotations optional. It is
@@ -1409,12 +1410,12 @@ Beyond the properties granted by the size, an owned box behaves as a regular
14091410
value by inheriting the mutability and lifetime of the owner:
14101411

14111412
~~~~
1412-
let x = 5i; // immutable
1413-
let mut y = 5i; // mutable
1413+
let x = 5; // immutable
1414+
let mut y = 5; // mutable
14141415
y += 2;
14151416
1416-
let x = box 5i; // immutable
1417-
let mut y = box 5i; // mutable
1417+
let x = box 5; // immutable
1418+
let mut y = box 5; // mutable
14181419
*y += 2; // the `*` operator is needed to access the contained value
14191420
~~~~
14201421

@@ -1506,7 +1507,7 @@ freezing enforced statically at compile-time. An example of a non-`Freeze` type
15061507
is [`RefCell<T>`][refcell].
15071508

15081509
~~~~
1509-
let mut x = 5i;
1510+
let mut x = 5;
15101511
{
15111512
let y = &x; // `x` is now frozen. It cannot be modified or re-assigned.
15121513
}
@@ -1522,8 +1523,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
15221523
box or pointer, similarly to C.
15231524

15241525
~~~
1525-
let owned = box 10i;
1526-
let borrowed = &20i;
1526+
let owned = box 10;
1527+
let borrowed = &20;
15271528
15281529
let sum = *owned + *borrowed;
15291530
~~~
@@ -1533,9 +1534,9 @@ assignments. Such an assignment modifies the value that the pointer
15331534
points to.
15341535

15351536
~~~
1536-
let mut owned = box 10i;
1537+
let mut owned = box 10;
15371538
1538-
let mut value = 20i;
1539+
let mut value = 20;
15391540
let borrowed = &mut value;
15401541
15411542
*owned = *borrowed + 100;
@@ -1653,12 +1654,12 @@ Unicode code points, so they cannot be freely mutated without the ability to
16531654
alter the length.
16541655

16551656
~~~
1656-
let mut xs = [1i, 2i, 3i];
1657+
let mut xs = [1, 2, 3];
16571658
let view = xs.mut_slice(0, 2);
16581659
view[0] = 5;
16591660
16601661
// The type of a mutable slice is written as `&mut [T]`
1661-
let ys: &mut [int] = &mut [1i, 2i, 3i];
1662+
let ys: &mut [int] = &mut [1, 2, 3];
16621663
~~~
16631664

16641665
Square brackets denote indexing into a slice or fixed-size vector:

branches/try2/src/liballoc/arc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,14 @@ mod tests {
376376

377377
#[test]
378378
fn test_live() {
379-
let x = Arc::new(5i);
379+
let x = Arc::new(5);
380380
let y = x.downgrade();
381381
assert!(y.upgrade().is_some());
382382
}
383383

384384
#[test]
385385
fn test_dead() {
386-
let x = Arc::new(5i);
386+
let x = Arc::new(5);
387387
let y = x.downgrade();
388388
drop(x);
389389
assert!(y.upgrade().is_none());

branches/try2/src/liballoc/heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ mod bench {
329329
#[bench]
330330
fn alloc_owned_small(b: &mut Bencher) {
331331
b.iter(|| {
332-
box 10i
332+
box 10
333333
})
334334
}
335335
}

branches/try2/src/libcollections/hash/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@ mod tests {
342342
assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
343343

344344
unsafe {
345-
let ptr: *const int = mem::transmute(5i);
345+
let ptr: *const int = mem::transmute(5);
346346
assert_eq!(hasher.hash(&ptr), 5);
347347
}
348348

349349
unsafe {
350-
let ptr: *mut int = mem::transmute(5i);
350+
let ptr: *mut int = mem::transmute(5);
351351
assert_eq!(hasher.hash(&ptr), 5);
352352
}
353353
}

0 commit comments

Comments
 (0)