Skip to content

Commit 99093b7

Browse files
committed
---
yaml --- r: 145226 b: refs/heads/try2 c: 4c6bf48 h: refs/heads/master v: v3
1 parent b0c1b52 commit 99093b7

File tree

359 files changed

+10099
-3828
lines changed

Some content is hidden

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

359 files changed

+10099
-3828
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: af72e4108d46673f17cdcad125d2049d296d89cf
8+
refs/heads/try2: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.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/try2/Makefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc)
214214
CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax)
215215
CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg)
216216
CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc)
217+
CFG_LIBRUSTDOCNG_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc_ng)
217218
CFG_LIBRUSTI_$(1) :=$(call CFG_LIB_NAME_$(1),rusti)
218219
CFG_LIBRUST_$(1) :=$(call CFG_LIB_NAME_$(1),rust)
219220

@@ -223,6 +224,7 @@ LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc)
223224
LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax)
224225
LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg)
225226
LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc)
227+
LIBRUSTDOCNG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc_ng)
226228
LIBRUSTI_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rusti)
227229
LIBRUST_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rust)
228230
EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra)
@@ -231,6 +233,7 @@ LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc)
231233
LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax)
232234
LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
233235
LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
236+
LIBRUSTDOCNG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc_ng)
234237
LIBRUSTI_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rusti)
235238
LIBRUST_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rust)
236239

@@ -439,10 +442,12 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
439442
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
440443
$$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
441444
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
445+
$$(HBIN$(1)_H_$(3))/rustdoc_ng$$(X_$(3)) \
442446
$$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
443447
$$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
444448
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
445449
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOC_$(3)) \
450+
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOCNG_$(3)) \
446451
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTI_$(3)) \
447452
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUST_$(3)) \
448453
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
@@ -451,6 +456,7 @@ CSREQ$(1)_T_$(2)_H_$(3) = \
451456
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \
452457
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2)) \
453458
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC_$(2)) \
459+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOCNG_$(2)) \
454460
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTI_$(2)) \
455461
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUST_$(2))
456462

branches/try2/doc/rust.md

Lines changed: 65 additions & 12 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

@@ -1717,7 +1769,8 @@ Supported traits for `deriving` are:
17171769
* `Clone` and `DeepClone`, to perform (deep) copies.
17181770
* `IterBytes`, to iterate over the bytes in a data type.
17191771
* `Rand`, to create a random instance of a data type.
1720-
* `Zero`, to create an zero (or empty) instance of a data type.
1772+
* `Default`, to create an empty instance of a data type.
1773+
* `Zero`, to create an zero instance of a numeric data type.
17211774
* `ToStr`, to convert to a string. For a type with this instance,
17221775
`obj.to_str()` has similar output as `fmt!("%?", obj)`, but it differs in that
17231776
each constituent field of the type must also implement `ToStr` and will have

branches/try2/doc/rustpkg.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ A valid workspace must contain each of the following subdirectories:
5252
rustpkg will install libraries for bar to `foo/lib/x86_64-apple-darwin/`.
5353
The libraries will have names of the form `foo/lib/x86_64-apple-darwin/libbar-[hash].dylib`,
5454
where [hash] is a hash of the package ID.
55-
* 'bin/': `rustpkg install` installs executable binaries into a target-specific subdirectory of this directory.
55+
* 'bin/': `rustpkg install` installs executable binaries into this directory.
5656

57-
For example, on a 64-bit machine running Mac OS X,
58-
if `foo` is a workspace, containing the package `bar`,
59-
rustpkg will install executables for `bar` to
60-
`foo/bin/x86_64-apple-darwin/`.
61-
The executables will have names of the form `foo/bin/x86_64-apple-darwin/bar`.
57+
For example, rustpkg will install executables for `bar` to
58+
`foo/bin`.
59+
The executables will have names of the form `foo/bin/bar`.
6260
* 'build/': `rustpkg build` stores temporary build artifacts in a target-specific subdirectory of this directory.
6361

6462
For example, on a 64-bit machine running Mac OS X,
@@ -85,6 +83,12 @@ rustpkg also interprets any dependencies on such a package ID literally
8583
Thus, `github.com/mozilla/rust#5c4cd30f80` is also a valid package ID,
8684
since git can deduce that 5c4cd30f80 refers to a revision of the desired repository.
8785

86+
A package identifier can name a subdirectory of another package.
87+
For example, if `foo` is a workspace, and `foo/src/bar/lib.rs` exists,
88+
as well as `foo/src/bar/extras/baz/lib.rs`,
89+
then both `bar` and `bar/extras/baz` are valid package identifiers
90+
in the workspace `foo`.
91+
8892
## Source files
8993

9094
rustpkg searches for four different fixed filenames in order to determine the crates to build:
@@ -140,9 +144,11 @@ but not in their `lib` or `bin` directories.
140144

141145
## install
142146

143-
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`,
144-
and then installs them either into `foo`'s `lib` and `bin` directories,
145-
or into the `lib` and `bin` subdirectories of the first entry in `RUST_PATH`.
147+
`rustpkg install foo` builds the libraries and/or executables that are targets for `foo`.
148+
If `RUST_PATH` is declared as an environment variable, then rustpkg installs the
149+
libraries and executables into the `lib` and `bin` subdirectories
150+
of the first entry in `RUST_PATH`.
151+
Otherwise, it installs them into `foo`'s `lib` and `bin` directories.
146152

147153
## test
148154

branches/try2/doc/tutorial-conditions.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn read_int_pairs() -> ~[(int,int)] {
9191
[a, b] => {
9292
9393
// 5. Try parsing both fields as ints.
94-
match (int::from_str(a), int::from_str(b)) {
94+
match (from_str::<int>(a), from_str::<int>(b)) {
9595
9696
// 6. If parsing succeeded for both, push both.
9797
(Some(a), Some(b)) => pairs.push((a,b)),
@@ -124,7 +124,7 @@ for conveying a value of type `T`, represented as `Some(T)`
124124
_or_ the sentinel `None`, to indicate the absence of a `T` value.
125125
For simple APIs, it may be sufficient to encode errors as `Option<T>`,
126126
returning `Some(T)` on success and `None` on error.
127-
In the example program, the call to `int::from_str` returns `Option<int>`
127+
In the example program, the call to `from_str::<int>` returns `Option<int>`
128128
with the understanding that "all parse errors" result in `None`.
129129
The resulting `Option<int>` values are matched against the pattern `(Some(a), Some(b))`
130130
in steps 5 and 6 in the example program,
@@ -161,7 +161,7 @@ This second mechanism for indicating an error is called a `Result`.
161161
The type `std::result::Result<T,E>` is another simple `enum` type with two forms, `Ok(T)` and `Err(E)`.
162162
The `Result` type is not substantially different from the `Option` type in terms of its ergonomics.
163163
Its main advantage is that the error constructor `Err(E)` can convey _more detail_ about the error.
164-
For example, the `int::from_str` API could be reformed
164+
For example, the `from_str` API could be reformed
165165
to return a `Result` carrying an informative description of a parse error,
166166
like this:
167167

@@ -172,7 +172,7 @@ enum IntParseErr {
172172
BadChar(char)
173173
}
174174
175-
fn int::from_str(&str) -> Result<int,IntParseErr> {
175+
fn from_str(&str) -> Result<int,IntParseErr> {
176176
// ...
177177
}
178178
~~~~
@@ -297,8 +297,8 @@ fn read_int_pairs() -> ~[(int,int)] {
297297
let line = fi.read_line();
298298
let fields = line.word_iter().to_owned_vec();
299299
match fields {
300-
[a, b] => pairs.push((int::from_str(a).unwrap(),
301-
int::from_str(b).unwrap())),
300+
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
301+
from_str::<int>(b).unwrap())),
302302
303303
// Explicitly fail on malformed lines.
304304
_ => fail!()
@@ -398,8 +398,8 @@ fn read_int_pairs() -> ~[(int,int)] {
398398
let line = fi.read_line();
399399
let fields = line.word_iter().to_owned_vec();
400400
match fields {
401-
[a, b] => pairs.push((int::from_str(a).unwrap(),
402-
int::from_str(b).unwrap())),
401+
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
402+
from_str::<int>(b).unwrap())),
403403
404404
// On malformed lines, call the condition handler and
405405
// push whatever the condition handler returns.
@@ -475,8 +475,8 @@ fn read_int_pairs() -> ~[(int,int)] {
475475
let line = fi.read_line();
476476
let fields = line.word_iter().to_owned_vec();
477477
match fields {
478-
[a, b] => pairs.push((int::from_str(a).unwrap(),
479-
int::from_str(b).unwrap())),
478+
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
479+
from_str::<int>(b).unwrap())),
480480
_ => pairs.push(malformed_line::cond.raise(line.clone()))
481481
}
482482
}
@@ -553,8 +553,8 @@ fn read_int_pairs() -> ~[(int,int)] {
553553
let line = fi.read_line();
554554
let fields = line.word_iter().to_owned_vec();
555555
match fields {
556-
[a, b] => pairs.push((int::from_str(a).unwrap(),
557-
int::from_str(b).unwrap())),
556+
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
557+
from_str::<int>(b).unwrap())),
558558
559559
// On malformed lines, call the condition handler and
560560
// either ignore the line (if the handler returns `None`)
@@ -649,8 +649,8 @@ fn read_int_pairs() -> ~[(int,int)] {
649649
let line = fi.read_line();
650650
let fields = line.word_iter().to_owned_vec();
651651
match fields {
652-
[a, b] => pairs.push((int::from_str(a).unwrap(),
653-
int::from_str(b).unwrap())),
652+
[a, b] => pairs.push((from_str::<int>(a).unwrap(),
653+
from_str::<int>(b).unwrap())),
654654
655655
// On malformed lines, call the condition handler and
656656
// take action appropriate to the enum value returned.
@@ -776,7 +776,7 @@ fn main() {
776776
// Parse an int; if parsing fails, call the condition handler and
777777
// return whatever it returns.
778778
fn parse_int(x: &str) -> int {
779-
match int::from_str(x) {
779+
match from_str::<int>(x) {
780780
Some(v) => v,
781781
None => malformed_int::cond.raise(x.to_owned())
782782
}
@@ -833,8 +833,8 @@ There are three other things to note in this variant of the example program:
833833
so long as the `raise` occurs within a callee (of any depth) of the logic protected by the `trap` call,
834834
it will invoke the handler.
835835

836-
- This variant insulates callers from a design choice in the `int` library:
837-
the `int::from_str` function was designed to return an `Option<int>`,
836+
- This variant insulates callers from a design choice in the library:
837+
the `from_str` function was designed to return an `Option<int>`,
838838
but this program insulates callers from that choice,
839839
routing all `None` values that arise from parsing integers in this file into the condition.
840840

@@ -873,4 +873,4 @@ To compensate for this risk, correct C++ and Java code must program in an extrem
873873
or else risk introducing silent and very difficult-to-debug errors due to control resuming in a corrupted heap after a caught exception.
874874
These errors are frequently memory-safety errors, which Rust strives to eliminate,
875875
and so Rust unwinding is unrecoverable within a single task:
876-
once unwinding starts, the entire local heap of a task is destroyed and the task is terminated.
876+
once unwinding starts, the entire local heap of a task is destroyed and the task is terminated.

branches/try2/doc/tutorial-ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<T: Send> Unique<T> {
321321
322322
#[unsafe_destructor]
323323
impl<T: Send> Drop for Unique<T> {
324-
fn drop(&self) {
324+
fn drop(&mut self) {
325325
#[fixed_stack_segment];
326326
#[inline(never)];
327327

0 commit comments

Comments
 (0)