Skip to content

Commit 3e75bc3

Browse files
committed
---
yaml --- r: 139224 b: refs/heads/try2 c: a1b4afe h: refs/heads/master v: v3
1 parent ef5ac86 commit 3e75bc3

File tree

197 files changed

+1618
-1646
lines changed

Some content is hidden

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

197 files changed

+1618
-1646
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: 8aee0a6a2972f0c62777cb757184c01042513973
8+
refs/heads/try2: a1b4afe0670fb1603b056f317a301ed527064ef5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 142 additions & 153 deletions
Large diffs are not rendered by default.

branches/try2/doc/tutorial-borrowed-ptr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ copying.
394394
# Circle(Point, float), // origin, radius
395395
# Rectangle(Point, Size) // upper-left, dimensions
396396
# }
397-
# static tau: float = 6.28f;
397+
# const tau: float = 6.28f;
398398
fn compute_area(shape: &Shape) -> float {
399399
match *shape {
400400
Circle(_, radius) => 0.5 * tau * radius * radius,

branches/try2/doc/tutorial.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ can specify a variable's type by following it with a colon, then the type
237237
name. Constants, on the other hand, always require a type annotation.
238238

239239
~~~~
240-
static monster_factor: float = 57.8;
240+
const monster_factor: float = 57.8;
241241
let monster_size = monster_factor * 10.0;
242242
let monster_size: int = 50;
243243
~~~~
@@ -916,7 +916,7 @@ use core::libc::types::os::arch::c95::size_t;
916916
struct Blob { priv ptr: *c_void }
917917
918918
impl Blob {
919-
fn new() -> Blob {
919+
static fn new() -> Blob {
920920
unsafe { Blob{ptr: calloc(1, int::bytes as size_t)} }
921921
}
922922
}
@@ -1222,7 +1222,7 @@ pointers to vectors are also called 'slices'.
12221222
# Black, BlizzardBlue, Blue
12231223
# }
12241224
// A fixed-size stack vector
1225-
let stack_crayons: [Crayon, ..3] = [Almond, AntiqueBrass, Apricot];
1225+
let stack_crayons: [Crayon * 3] = [Almond, AntiqueBrass, Apricot];
12261226

12271227
// A borrowed pointer to stack-allocated vector
12281228
let stack_crayons: &[Crayon] = &[Aquamarine, Asparagus, AtomicTangerine];
@@ -1264,7 +1264,7 @@ Square brackets denote indexing into a vector:
12641264
# Aquamarine, Asparagus, AtomicTangerine,
12651265
# BananaMania, Beaver, Bittersweet };
12661266
# fn draw_scene(c: Crayon) { }
1267-
let crayons: [Crayon, ..3] = [BananaMania, Beaver, Bittersweet];
1267+
let crayons: [Crayon * 3] = [BananaMania, Beaver, Bittersweet];
12681268
match crayons[0] {
12691269
Bittersweet => draw_scene(crayons[0]),
12701270
_ => ()
@@ -1274,7 +1274,7 @@ match crayons[0] {
12741274
A vector can be destructured using pattern matching:
12751275
12761276
~~~~
1277-
let numbers: [int, ..3] = [1, 2, 3];
1277+
let numbers: [int * 3] = [1, 2, 3];
12781278
let score = match numbers {
12791279
[] => 0,
12801280
[a] => a * 10,
@@ -1768,25 +1768,32 @@ s.draw_borrowed();
17681768
(&@~s).draw_borrowed();
17691769
~~~
17701770

1771-
Implementations may also define standalone (sometimes called "static")
1772-
methods. The absence of a `self` paramater distinguishes such methods.
1773-
These methods are the preferred way to define constructor functions.
1771+
Implementations may also define _static_ methods,
1772+
which don't have an explicit `self` argument.
1773+
The `static` keyword distinguishes static methods from methods that have a `self`:
17741774

17751775
~~~~ {.xfail-test}
17761776
impl Circle {
17771777
fn area(&self) -> float { ... }
1778-
fn new(area: float) -> Circle { ... }
1778+
static fn new(area: float) -> Circle { ... }
17791779
}
17801780
~~~~
17811781

1782-
To call such a method, just prefix it with the type name and a double colon:
1782+
> ***Note***: In the future the `static` keyword will be removed and static methods
1783+
> will be distinguished solely by the presence or absence of the `self` argument.
1784+
> In the current langugage instance methods may also be declared without an explicit
1785+
> `self` argument, in which case `self` is an implicit reference.
1786+
> That form of method is deprecated.
1787+
1788+
Constructors are one common application for static methods, as in `new` above.
1789+
To call a static method, you have to prefix it with the type name and a double colon:
17831790

17841791
~~~~
17851792
# use core::float::consts::pi;
17861793
# use core::float::sqrt;
17871794
struct Circle { radius: float }
17881795
impl Circle {
1789-
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
1796+
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
17901797
}
17911798
let c = Circle::new(42.5);
17921799
~~~~
@@ -2048,23 +2055,22 @@ second parameter of type `self`.
20482055
In contrast, in the `impl`, `equals` takes a second parameter of
20492056
type `int`, only using `self` as the name of the receiver.
20502057

2051-
Just as in type implementations, traits can define standalone (static)
2052-
methods. These methods are called by prefixing the method name with the trait
2053-
name and a double colon. The compiler uses type inference to decide which
2054-
implementation to use.
2058+
Traits can also define static methods which are called by prefixing
2059+
the method name with the trait name.
2060+
The compiler will use type inference to decide which implementation to call.
20552061

20562062
~~~~
2057-
trait Shape { fn new(area: float) -> Self; }
2063+
trait Shape { static fn new(area: float) -> Self; }
20582064
# use core::float::consts::pi;
20592065
# use core::float::sqrt;
20602066
struct Circle { radius: float }
20612067
struct Square { length: float }
20622068
20632069
impl Shape for Circle {
2064-
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
2070+
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
20652071
}
20662072
impl Shape for Square {
2067-
fn new(area: float) -> Square { Square { length: sqrt(area) } }
2073+
static fn new(area: float) -> Square { Square { length: sqrt(area) } }
20682074
}
20692075
20702076
let area = 42.5;
@@ -2306,7 +2312,7 @@ them. The `pub` keyword modifies an item's visibility, making it
23062312
visible outside its containing module. An expression with `::`, like
23072313
`farm::chicken`, can name an item outside of its containing
23082314
module. Items, such as those declared with `fn`, `struct`, `enum`,
2309-
`type`, or `static`, are module-private by default.
2315+
`type`, or `const`, are module-private by default.
23102316

23112317
Visibility restrictions in Rust exist only at module boundaries. This
23122318
is quite different from most object-oriented languages that also

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
8181
};
8282
8383
// The value our Makefile configures valgrind to return on failure
84-
static valgrind_err: int = 100;
84+
const valgrind_err: int = 100;
8585
if ProcRes.status == valgrind_err {
8686
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes);
8787
}
@@ -92,7 +92,7 @@ fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
9292
9393
fn check_correct_failure_status(ProcRes: ProcRes) {
9494
// The value the rust runtime returns on failure
95-
static rust_err: int = 101;
95+
const rust_err: int = 101;
9696
if ProcRes.status != rust_err {
9797
fatal_ProcRes(
9898
fmt!("failure produced the wrong error code: %d",

branches/try2/src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn test() {
291291
}
292292
}
293293

294-
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
294+
fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]);
295295
fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
296296
fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
297297
}

branches/try2/src/libcore/condition.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ pub struct Handler<T, U> {
2222

2323
pub struct Condition<T, U> {
2424
name: &'static str,
25-
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
25+
key: task::local_data::LocalDataKey/&self<Handler<T, U>>
2626
}
2727

28-
pub impl<T, U> Condition<'self, T, U> {
29-
fn trap(&self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
28+
pub impl<T, U> Condition/&self<T, U> {
29+
fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self<T, U> {
3030
unsafe {
3131
let p : *RustClosure = ::cast::transmute(&h);
3232
let prev = task::local_data::local_data_get(self.key);
@@ -65,11 +65,11 @@ pub impl<T, U> Condition<'self, T, U> {
6565
}
6666

6767
struct Trap<T, U> {
68-
cond: &'self Condition<'self, T, U>,
68+
cond: &'self Condition/&self<T, U>,
6969
handler: @Handler<T, U>
7070
}
7171

72-
pub impl<T, U> Trap<'self, T, U> {
72+
pub impl<T, U> Trap/&self<T, U> {
7373
fn in<V>(&self, inner: &'self fn() -> V) -> V {
7474
unsafe {
7575
let _g = Guard { cond: self.cond };
@@ -81,11 +81,11 @@ pub impl<T, U> Trap<'self, T, U> {
8181
}
8282

8383
struct Guard<T, U> {
84-
cond: &'self Condition<'self, T, U>
84+
cond: &'self Condition/&self<T, U>
8585
}
8686

8787
#[unsafe_destructor]
88-
impl<T, U> Drop for Guard<'self, T, U> {
88+
impl<T, U> Drop for Guard/&self<T, U> {
8989
fn finalize(&self) {
9090
unsafe {
9191
debug!("Guard: popping handler from TLS");

branches/try2/src/libcore/flate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ pub mod rustrt {
4141
}
4242
}
4343

44-
static lz_none : c_int = 0x0; // Huffman-coding only.
45-
static lz_fast : c_int = 0x1; // LZ with only one probe
46-
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
47-
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
44+
const lz_none : c_int = 0x0; // Huffman-coding only.
45+
const lz_fast : c_int = 0x1; // LZ with only one probe
46+
const lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
47+
const lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
4848

4949
pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
5050
do vec::as_const_buf(bytes) |b, len| {

branches/try2/src/libcore/gc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ unsafe fn find_segment_for_frame(fp: *Word, segment: *StackSegment)
211211

212212
type Memory = uint;
213213

214-
static task_local_heap: Memory = 1;
215-
static exchange_heap: Memory = 2;
216-
static stack: Memory = 4;
214+
const task_local_heap: Memory = 1;
215+
const exchange_heap: Memory = 2;
216+
const stack: Memory = 4;
217217

218-
static need_cleanup: Memory = exchange_heap | stack;
218+
const need_cleanup: Memory = exchange_heap | stack;
219219

220220
// Walks stack, searching for roots of the requested type, and passes
221221
// each root to the visitor.

branches/try2/src/libcore/hashmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod linear {
2525
use uint;
2626
use vec;
2727

28-
static INITIAL_CAPACITY: uint = 32u; // 2^5
28+
const INITIAL_CAPACITY: uint = 32u; // 2^5
2929

3030
struct Bucket<K,V> {
3131
hash: uint,

0 commit comments

Comments
 (0)