Skip to content

Commit f0af8b3

Browse files
committed
---
yaml --- r: 139227 b: refs/heads/try2 c: 6f42738 h: refs/heads/master i: 139225: 22cc39d 139223: ef5ac86 v: v3
1 parent d481546 commit f0af8b3

File tree

197 files changed

+1506
-1483
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

+1506
-1483
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: 9aa0cedc84792e711f49951a2dfdc9f1586d5d38
8+
refs/heads/try2: 6f4273854438e8f9b034e1342f30392f70c0eaae
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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ The keywords are the following strings:
206206
~~~~~~~~ {.keyword}
207207
as
208208
break
209-
const copy
209+
copy
210210
do drop
211211
else enum extern
212212
false fn for
@@ -1099,7 +1099,7 @@ const_item : "const" ident ':' type '=' expr ';' ;
10991099

11001100
A *constant* is a named value stored in read-only memory in a crate.
11011101
The value bound to a constant is evaluated at compile time.
1102-
Constants are declared with the `const` keyword.
1102+
Constants are declared with the `static` keyword.
11031103
A constant item must have an expression giving its definition.
11041104
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
11051105

@@ -1108,18 +1108,18 @@ The derived types are borrowed pointers, static arrays, tuples, and structs.
11081108
Borrowed pointers must be have the `'static` lifetime.
11091109

11101110
~~~~
1111-
const bit1: uint = 1 << 0;
1112-
const bit2: uint = 1 << 1;
1111+
static bit1: uint = 1 << 0;
1112+
static bit2: uint = 1 << 1;
11131113
1114-
const bits: [uint * 2] = [bit1, bit2];
1115-
const string: &'static str = "bitstring";
1114+
static bits: [uint, ..2] = [bit1, bit2];
1115+
static string: &'static str = "bitstring";
11161116
11171117
struct BitsNStrings {
1118-
mybits: [uint *2],
1118+
mybits: [uint, ..2],
11191119
mystring: &'self str
11201120
}
11211121
1122-
const bits_n_strings: BitsNStrings<'static> = BitsNStrings {
1122+
static bits_n_strings: BitsNStrings<'static> = BitsNStrings {
11231123
mybits: bits,
11241124
mystring: string
11251125
};
@@ -1206,10 +1206,10 @@ For example:
12061206

12071207
~~~~
12081208
trait Num {
1209-
static fn from_int(n: int) -> Self;
1209+
fn from_int(n: int) -> Self;
12101210
}
12111211
impl Num for float {
1212-
static fn from_int(n: int) -> float { n as float }
1212+
fn from_int(n: int) -> float { n as float }
12131213
}
12141214
let x: float = Num::from_int(42);
12151215
~~~~

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-
# const tau: float = 6.28f;
397+
# static 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: 19 additions & 25 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-
const monster_factor: float = 57.8;
240+
static 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-
static fn new() -> Blob {
919+
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,32 +1768,25 @@ s.draw_borrowed();
17681768
(&@~s).draw_borrowed();
17691769
~~~
17701770

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`:
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.
17741774

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

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:
1782+
To call such a method, just prefix it with the type name and a double colon:
17901783

17911784
~~~~
17921785
# use core::float::consts::pi;
17931786
# use core::float::sqrt;
17941787
struct Circle { radius: float }
17951788
impl Circle {
1796-
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
1789+
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
17971790
}
17981791
let c = Circle::new(42.5);
17991792
~~~~
@@ -2055,22 +2048,23 @@ second parameter of type `self`.
20552048
In contrast, in the `impl`, `equals` takes a second parameter of
20562049
type `int`, only using `self` as the name of the receiver.
20572050

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.
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.
20612055

20622056
~~~~
2063-
trait Shape { static fn new(area: float) -> Self; }
2057+
trait Shape { fn new(area: float) -> Self; }
20642058
# use core::float::consts::pi;
20652059
# use core::float::sqrt;
20662060
struct Circle { radius: float }
20672061
struct Square { length: float }
20682062
20692063
impl Shape for Circle {
2070-
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
2064+
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
20712065
}
20722066
impl Shape for Square {
2073-
static fn new(area: float) -> Square { Square { length: sqrt(area) } }
2067+
fn new(area: float) -> Square { Square { length: sqrt(area) } }
20742068
}
20752069
20762070
let area = 42.5;
@@ -2312,7 +2306,7 @@ them. The `pub` keyword modifies an item's visibility, making it
23122306
visible outside its containing module. An expression with `::`, like
23132307
`farm::chicken`, can name an item outside of its containing
23142308
module. Items, such as those declared with `fn`, `struct`, `enum`,
2315-
`type`, or `const`, are module-private by default.
2309+
`type`, or `static`, are module-private by default.
23162310

23172311
Visibility restrictions in Rust exist only at module boundaries. This
23182312
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-
const valgrind_err: int = 100;
84+
static 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-
const rust_err: int = 101;
95+
static 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-
fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]);
294+
assert_eq!(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-
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"
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"
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-
const task_local_heap: Memory = 1;
215-
const exchange_heap: Memory = 2;
216-
const stack: Memory = 4;
214+
static task_local_heap: Memory = 1;
215+
static exchange_heap: Memory = 2;
216+
static stack: Memory = 4;
217217

218-
const need_cleanup: Memory = exchange_heap | stack;
218+
static 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-
const INITIAL_CAPACITY: uint = 32u; // 2^5
28+
static INITIAL_CAPACITY: uint = 32u; // 2^5
2929

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

0 commit comments

Comments
 (0)