Skip to content

Commit f917edc

Browse files
blake2-ppcthestinger
authored andcommitted
---
yaml --- r: 80923 b: refs/heads/snap-stage3 c: bf0e2a6 h: refs/heads/master i: 80921: 8ab839d 80919: afade18 v: v3
1 parent ef76ce1 commit f917edc

File tree

183 files changed

+1468
-854
lines changed

Some content is hidden

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

183 files changed

+1468
-854
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3bd0eb9f637794cefbdb700d4fbe125369de53dd
4+
refs/heads/snap-stage3: bf0e2a6f578251c093f935a9cdf100bba7ebf581
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/.gitattributes

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4
22

3-
* text=auto
3+
* text eol=lf
44
*.cpp rust
55
*.h rust
66
*.rs rust
77
src/rt/msvc/* -whitespace
88
src/rt/vg/* -whitespace
99
src/rt/linenoise/* -whitespace
1010
src/rt/jemalloc/**/* -whitespace
11-
src/rt/jemalloc/include/jemalloc/jemalloc.h.in text eol=lf
12-
src/rt/jemalloc/include/jemalloc/jemalloc_defs.h.in text eol=lf
13-
src/rt/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in text eol=lf

branches/snap-stage3/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
442442
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
443443
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
444444
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
445+
$$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
445446
$$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
446447
$$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
447448
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \

branches/snap-stage3/RELEASES.txt

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,3 @@
1-
Version 0.8 (October 2013)
2-
--------------------------
3-
4-
* ~2100 changes, numerous bugfixes
5-
6-
* Language
7-
* The `for` loop syntax has changed to work with the `Iterator` trait.
8-
* At long last, unwinding works on Windows.
9-
* Default methods definitely mostly work.
10-
* Many trait inheritance bugs fixed.
11-
* Owned and borrowed trait objects work more reliably.
12-
* `copy` is no longer a keyword. It has been replaced by the `Clone` trait.
13-
* rustc no longer emits code for the `debug!` macro unless it is passed
14-
`--cfg debug`
15-
* mod.rs is now "blessed". When loading `mod foo;`, rustc will now look
16-
for foo.rs, then foo/mod.rs, and will generate an error when both are
17-
present.
18-
* Strings no longer contain trailing nulls. The new `std::c_str` module
19-
provides new mechanisms for converting to C strings.
20-
* The type of foreign functions is now `extern "C" fn` instead of `*u8'.
21-
* The FFI has been overhauled such that foreign functions are called directly,
22-
instead of through a stack-switching wrapper.
23-
* Calling a foreign function must be done through a Rust function with the
24-
`#[fixed_stack_segment]` attribute.
25-
* The `externfn!` macro can be used to declare both a foreign function and
26-
a `#[fixed_stack_segment]` wrapper at once.
27-
* `pub` and `priv` modifiers on `extern` blocks are no longer parsed.
28-
* `unsafe` is no longer allowed on extern fns - they are all unsafe.
29-
* `priv` is disallowed everywhere except for struct fields and enum variants.
30-
* `&T` (besides `&'static T`) is no longer allowed in `@T`.
31-
* `ref` bindings in irrefutable patterns work correctly now.
32-
* `char` is now prevented from containing invalid code points.
33-
* Casting to `bool` is no longer allowed.
34-
* `yield` is a reserved keyword.
35-
* `typeof` is a reserved keyword.
36-
* Crates may be imported by URL with `extern mod foo = "url";`.
37-
* Explicit enum discriminants may be given as uints as in `enum E { V = 0u }`
38-
* Static vectors can be initialized with repeating elements,
39-
e.g. `static foo: [u8, .. 100]: [0, .. 100];`.
40-
* Static structs can be initialized with functional record update,
41-
e.g. `static foo: Foo = Foo { a: 5, .. bar };`.
42-
* `cfg!` can be used to conditionally execute code based on the crate
43-
configuration, similarly to `#[cfg(...)]`.
44-
* The `unnecessary_qualification` lint detects unneeded module
45-
prefixes (default: allow).
46-
* Arithmetic operations have been implemented on the SIMD types in
47-
`std::unstable::simd`.
48-
* Exchange allocation headers were removed, reducing memory usage.
49-
* `format!` implements a completely new, extensible, and higher-performance
50-
string formatting system. It will replace `fmt!`.
51-
* `print!` and `println!` write formatted strings (using the `format!`
52-
extension) to stdout.
53-
* `write!` and `writeln!` write formatted strings (using the `format!`
54-
extension) to the new Writers in `std::rt::io`.
55-
* The library section in which a function or static is placed may
56-
be specified with `#[link_section = "..."]`.
57-
* The `proto!` syntax extension for defining bounded message protocols
58-
was removed.
59-
* `macro_rules!` is hygenic for `let` declarations.
60-
* The `#[export_name]` attribute specifies the name of a symbol.
61-
* `unreachable!` can be used to indicate unreachable code, and fails
62-
if executed.
63-
64-
* Libraries
65-
* std: Transitioned to the new runtime, written in Rust.
66-
* std: Added an experimental I/O library, `rt::io`, based on the new
67-
runtime.
68-
* std: A new generic `range` function was added to the prelude, replacing
69-
`uint::range` and friends.
70-
* std: `range_rev` no longer exists. Since range is an iterator it can be
71-
reversed with `range(lo, hi).invert()`.
72-
* std: The `chain` method on option renamed to `and_then`; `unwrap_or_default`
73-
renamed to `unwrap_or`.
74-
* std: The `iterator` module was renamed to `iter`.
75-
* std: Integral types now support the `checked_add`, `checked_sub`, and
76-
`checked_mul` operations for detecting overflow.
77-
* std: Many methods in `str`, `vec`, `option, `result` were renamed for
78-
consistency.
79-
* std: Methods are standardizing on conventions for casting methods:
80-
`to_foo` for copying, `into_foo` for moving, `as_foo` for temporary
81-
and cheap casts.
82-
* std: The `CString` type in `c_str` provides new ways to convert to and
83-
from C strings.
84-
* std: `DoubleEndedIterator` can yield elements in two directions.
85-
* std: The `mut_split` method on vectors partitions an `&mut [T]` into
86-
two splices.
87-
* std: `str::from_bytes` renamed to `str::from_utf8`.
88-
* std: `pop_opt` and `shift_opt` methods added to vectors.
89-
* std: The task-local data interface no longer uses @, and keys are
90-
no longer function pointers.
91-
* std: The `swap_unwrap` method of `Option` renamed to `take_unwrap`.
92-
* std: Added `SharedPort` to `comm`.
93-
* std: `Eq` has a default method for `ne`; only `eq` is required
94-
in implementations.
95-
* std: `Ord` has default methods for `le`, `gt` and `le`; only `lt`
96-
is required in implementations.
97-
* std: `is_utf8` performance is improved, impacting many string functions.
98-
* std: `os::MemoryMap` provides cross-platform mmap.
99-
* std: `ptr::offset` is now unsafe, but also more optimized. Offsets that
100-
are not 'in-bounds' are considered undefined.
101-
* std: Many freestanding functions in `vec` removed in favor of methods.
102-
* std: Many freestanding functions on scalar types removed in favor of
103-
methods.
104-
* std: Many options to task builders were removed since they don't make
105-
sense in the new scheduler design.
106-
* std: More containers implement `FromIterator` so can be created by the
107-
`collect` method.
108-
* std: More complete atomic types in `unstable::atomics`.
109-
* std: `comm::PortSet` removed.
110-
* std: Mutating methods in the `Set` and `Map` traits have been moved into
111-
the `MutableSet` and `MutableMap` traits. `Container::is_empty`,
112-
`Map::contains_key`, `MutableMap::insert`, and `MutableMap::remove` have
113-
default implementations.
114-
* extra: `dlist`, the doubly-linked list was modernized.
115-
* extra: Added a `hex` module with `ToHex` and `FromHex` traits.
116-
* extra: Added `glob` module, replacing `std::os::glob`.
117-
* extra: `rope` was removed.
118-
* extra: `deque` was renamed to `ringbuf`. `RingBuf` implements `Deque`.
119-
* extra: `net`, and `timer` were removed. The experimental replacements
120-
are `std::rt::io::net` and `std::rt::io::timer`.
121-
* extra: Iterators implemented for `SmallIntMap`.
122-
* extra: Iterators implemented for `Bitv` and `BitvSet`.
123-
* extra: `SmallIntSet` removed. Use `BitvSet`.
124-
* extra: Performance of JSON parsing greatly improved.
125-
* extra: `semver` updated to SemVer 2.0.0.
126-
* extra: `term` handles more terminals correctly.
127-
* extra: `dbg` module removed.
128-
129-
* Other
130-
* rustc's debug info generation (`-Z debug-info`) is greatly improved.
131-
* rustc accepts `--target-cpu` to compile to a specific CPU architecture,
132-
similarly to gcc's `--march` flag.
133-
* rustpkg has received many improvements.
134-
* rustpkg supports git tags as package IDs.
135-
* rustpkg builds into target-specific directories so it can be used for
136-
cross-compiling.
137-
* The number of concurrent test tasks is controlled by the environment
138-
variable RUST_TEST_TASKS.
139-
* The test harness can now report metrics for benchmarks.
140-
* All tools have man pages.
141-
* Programs compiled with `--test` now support the `-h` and `--help` flags.
142-
* The runtime uses jemalloc for allocations.
143-
* Segmented stacks are temporarily disabled as part of the transition to
144-
the new runtime. Stack overflows are possible!
145-
1461
Version 0.7 (July 2013)
1472
-----------------------
1483

branches/snap-stage3/doc/rust.md

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -962,24 +962,76 @@ parameters to allow methods with that trait to be called on values
962962
of that type.
963963

964964

965-
#### Unsafe functions
966-
967-
Unsafe functions are those containing unsafe operations that are not contained in an [`unsafe` block](#unsafe-blocks).
968-
Such a function must be prefixed with the keyword `unsafe`.
965+
#### Unsafety
969966

970967
Unsafe operations are those that potentially violate the memory-safety guarantees of Rust's static semantics.
971-
Specifically, the following operations are considered unsafe:
968+
969+
The following language level features cannot be used in the safe subset of Rust:
972970

973971
- Dereferencing a [raw pointer](#pointer-types).
974-
- Casting a [raw pointer](#pointer-types) to a safe pointer type.
975-
- Calling an unsafe function.
972+
- Calling an unsafe function (including an intrinsic or foreign function).
976973

977-
##### Unsafe blocks
974+
##### Unsafe functions
978975

979-
A block of code can also be prefixed with the `unsafe` keyword, to permit a sequence of unsafe operations in an otherwise-safe function.
980-
This facility exists because the static semantics of Rust are a necessary approximation of the dynamic semantics.
981-
When a programmer has sufficient conviction that a sequence of unsafe operations is actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The compiler will consider uses of such code "safe", to the surrounding context.
976+
Unsafe functions are functions that are not safe in all contexts and/or for all possible inputs.
977+
Such a function must be prefixed with the keyword `unsafe`.
978+
979+
##### Unsafe blocks
982980

981+
A block of code can also be prefixed with the `unsafe` keyword, to permit calling `unsafe` functions
982+
or dereferencing raw pointers within a safe function.
983+
984+
When a programmer has sufficient conviction that a sequence of potentially unsafe operations is
985+
actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The
986+
compiler will consider uses of such code safe, in the surrounding context.
987+
988+
Unsafe blocks are used to wrap foreign libraries, make direct use of hardware or implement features
989+
not directly present in the language. For example, Rust provides the language features necessary to
990+
implement memory-safe concurrency in the language but the implementation of tasks and message
991+
passing is in the standard library.
992+
993+
Rust's type system is a conservative approximation of the dynamic safety requirements, so in some
994+
cases there is a performance cost to using safe code. For example, a doubly-linked list is not a
995+
tree structure and can only be represented with managed or reference-counted pointers in safe code.
996+
By using `unsafe` blocks to represent the reverse links as raw pointers, it can be implemented with
997+
only owned pointers.
998+
999+
##### Behavior considered unsafe
1000+
1001+
This is a list of behavior which is forbidden in all Rust code. Type checking provides the guarantee
1002+
that these issues are never caused by safe code. An `unsafe` block or function is responsible for
1003+
never invoking this behaviour or exposing an API making it possible for it to occur in safe code.
1004+
1005+
* Data races
1006+
* Dereferencing a null/dangling raw pointer
1007+
* Mutating an immutable value/reference, if it is not marked as non-`Freeze`
1008+
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values) (uninitialized) memory
1009+
* Breaking the [pointer aliasing rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules)
1010+
with raw pointers (a subset of the rules used by C)
1011+
* Invoking undefined behavior via compiler intrinsics:
1012+
* Indexing outside of the bounds of an object with `std::ptr::offset` (`offset` intrinsic), with
1013+
the exception of one byte past the end which is permitted.
1014+
* Using `std::ptr::copy_nonoverlapping_memory` (`memcpy32`/`memcpy64` instrinsics) on
1015+
overlapping buffers
1016+
* Invalid values in primitive types, even in private fields/locals:
1017+
* Dangling/null pointers in non-raw pointers, or slices
1018+
* A value other than `false` (0) or `true` (1) in a `bool`
1019+
* A discriminant in an `enum` not included in the type definition
1020+
* A value in a `char` which is a surrogate or above `char::MAX`
1021+
* non-UTF-8 byte sequences in a `str`
1022+
1023+
##### Behaviour not considered unsafe
1024+
1025+
This is a list of behaviour not considered *unsafe* in Rust terms, but that may be undesired.
1026+
1027+
* Deadlocks
1028+
* Reading data from private fields (`std::repr`, `format!("{:?}", x)`)
1029+
* Leaks due to reference count cycles, even in the global heap
1030+
* Exiting without calling destructors
1031+
* Sending signals
1032+
* Accessing/modifying the file system
1033+
* Unsigned integer overflow (well-defined as wrapping)
1034+
* Signed integer overflow (well-defined as two's complement representation wrapping)
9831035

9841036
#### Diverging functions
9851037

branches/snap-stage3/doc/tutorial-container.md

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
The container traits are defined in the `std::container` module.
66

7-
## Unique and managed vectors
7+
## Unique vectors
88

9-
Vectors have `O(1)` indexing and removal from the end, along with `O(1)`
10-
amortized insertion. Vectors are the most common container in Rust, and are
11-
flexible enough to fit many use cases.
9+
Vectors have `O(1)` indexing, push (to the end) and pop (from the end). Vectors
10+
are the most common container in Rust, and are flexible enough to fit many use
11+
cases.
1212

1313
Vectors can also be sorted and used as efficient lookup tables with the
14-
`std::vec::bsearch` function, if all the elements are inserted at one time and
14+
`bsearch()` method, if all the elements are inserted at one time and
1515
deletions are unnecessary.
1616

1717
## Maps and sets
@@ -42,10 +42,15 @@ implementing the `IterBytes` trait.
4242

4343
## Double-ended queues
4444

45-
The `extra::deque` module implements a double-ended queue with `O(1)` amortized
46-
inserts and removals from both ends of the container. It also has `O(1)`
47-
indexing like a vector. The contained elements are not required to be copyable,
48-
and the queue will be sendable if the contained type is sendable.
45+
The `extra::ringbuf` module implements a double-ended queue with `O(1)`
46+
amortized inserts and removals from both ends of the container. It also has
47+
`O(1)` indexing like a vector. The contained elements are not required to be
48+
copyable, and the queue will be sendable if the contained type is sendable.
49+
Its interface `Deque` is defined in `extra::collections`.
50+
51+
The `extra::dlist` module implements a double-ended linked list, also
52+
implementing the `Deque` trait, with `O(1)` removals and inserts at either end,
53+
and `O(1)` concatenation.
4954

5055
## Priority queues
5156

@@ -197,11 +202,11 @@ The function `range` (or `range_inclusive`) allows to simply iterate through a g
197202
198203
~~~
199204
for i in range(0, 5) {
200-
printf!("%d ", i) // prints "0 1 2 3 4"
205+
print!("{} ", i) // prints "0 1 2 3 4"
201206
}
202207

203208
for i in std::iter::range_inclusive(0, 5) { // needs explicit import
204-
printf!("%d ", i) // prints "0 1 2 3 4 5"
209+
print!("{} ", i) // prints "0 1 2 3 4 5"
205210
}
206211
~~~
207212
@@ -233,15 +238,15 @@ let mut it = xs.iter().zip(ys.iter());
233238

234239
// print out the pairs of elements up to (&3, &"baz")
235240
for (x, y) in it {
236-
printfln!("%d %s", *x, *y);
241+
println!("{} {}", *x, *y);
237242

238243
if *x == 3 {
239244
break;
240245
}
241246
}
242247

243248
// yield and print the last pair from the iterator
244-
printfln!("last: %?", it.next());
249+
println!("last: {:?}", it.next());
245250

246251
// the iterator is now fully consumed
247252
assert!(it.next().is_none());
@@ -335,13 +340,13 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged.
335340
~~~
336341
let xs = [1, 2, 3, 4, 5, 6];
337342
let mut it = xs.iter();
338-
printfln!("%?", it.next()); // prints `Some(&1)`
339-
printfln!("%?", it.next()); // prints `Some(&2)`
340-
printfln!("%?", it.next_back()); // prints `Some(&6)`
343+
println!("{:?}", it.next()); // prints `Some(&1)`
344+
println!("{:?}", it.next()); // prints `Some(&2)`
345+
println!("{:?}", it.next_back()); // prints `Some(&6)`
341346
342347
// prints `5`, `4` and `3`
343348
for &x in it.invert() {
344-
printfln!("%?", x)
349+
println!("{}", x)
345350
}
346351
~~~
347352

@@ -356,11 +361,11 @@ let xs = [1, 2, 3, 4];
356361
let ys = [5, 6, 7, 8];
357362
let mut it = xs.iter().chain(ys.iter()).map(|&x| x * 2);
358363
359-
printfln!("%?", it.next()); // prints `Some(2)`
364+
println!("{:?}", it.next()); // prints `Some(2)`
360365
361366
// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`
362367
for x in it.invert() {
363-
printfln!("%?", x);
368+
println!("{}", x);
364369
}
365370
~~~
366371

@@ -387,17 +392,17 @@ underlying iterators are.
387392
let xs = [1, 2, 3, 4, 5];
388393
let ys = ~[7, 9, 11];
389394
let mut it = xs.iter().chain(ys.iter());
390-
printfln!("%?", it.idx(0)); // prints `Some(&1)`
391-
printfln!("%?", it.idx(5)); // prints `Some(&7)`
392-
printfln!("%?", it.idx(7)); // prints `Some(&11)`
393-
printfln!("%?", it.idx(8)); // prints `None`
395+
println!("{:?}", it.idx(0)); // prints `Some(&1)`
396+
println!("{:?}", it.idx(5)); // prints `Some(&7)`
397+
println!("{:?}", it.idx(7)); // prints `Some(&11)`
398+
println!("{:?}", it.idx(8)); // prints `None`
394399
395400
// yield two elements from the beginning, and one from the end
396401
it.next();
397402
it.next();
398403
it.next_back();
399404
400-
printfln!("%?", it.idx(0)); // prints `Some(&3)`
401-
printfln!("%?", it.idx(4)); // prints `Some(&9)`
402-
printfln!("%?", it.idx(6)); // prints `None`
405+
println!("{:?}", it.idx(0)); // prints `Some(&3)`
406+
println!("{:?}", it.idx(4)); // prints `Some(&9)`
407+
println!("{:?}", it.idx(6)); // prints `None`
403408
~~~

0 commit comments

Comments
 (0)