Skip to content

Commit b495933

Browse files
committed
auto merge of #16141 : alexcrichton/rust/rollup, r=alexcrichton
2 parents 75a39e0 + ec79d36 commit b495933

Some content is hidden

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

45 files changed

+1580
-1240
lines changed

mk/crates.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
url log regex graphviz core rlibc alloc debug rustrt \
54+
url log regex graphviz core rbml rlibc alloc debug rustrt \
5555
unicode
5656
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
5757
rustc_llvm rustc_back
@@ -71,7 +71,7 @@ DEPS_green := std native:context_switch
7171
DEPS_rustuv := std native:uv native:uv_support
7272
DEPS_native := std
7373
DEPS_syntax := std term serialize log fmt_macros debug
74-
DEPS_rustc := syntax flate arena serialize getopts \
74+
DEPS_rustc := syntax flate arena serialize getopts rbml \
7575
time log graphviz debug rustc_llvm rustc_back
7676
DEPS_rustc_llvm := native:rustllvm libc std
7777
DEPS_rustc_back := std syntax rustc_llvm flate log libc
@@ -82,6 +82,7 @@ DEPS_arena := std
8282
DEPS_graphviz := std
8383
DEPS_glob := std
8484
DEPS_serialize := std log
85+
DEPS_rbml := std log serialize
8586
DEPS_term := std log
8687
DEPS_semver := std
8788
DEPS_uuid := std serialize
@@ -91,7 +92,7 @@ DEPS_collections := core alloc unicode
9192
DEPS_fourcc := rustc syntax std
9293
DEPS_hexfloat := rustc syntax std
9394
DEPS_num := std
94-
DEPS_test := std getopts serialize term time regex native:rust_test_helpers
95+
DEPS_test := std getopts serialize rbml term time regex native:rust_test_helpers
9596
DEPS_time := std serialize
9697
DEPS_rand := core
9798
DEPS_url := std

src/doc/complement-lang-faq.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
% Language FAQ
22

3-
43
## Are there any big programs written in it yet? I want to read big samples.
54

65
There aren't many large programs yet. The Rust [compiler][rustc], 60,000+ lines at the time of writing, is written in Rust. As the oldest body of Rust code it has gone through many iterations of the language, and some parts are nicer to look at than others. It may not be the best code to learn from, but [borrowck] and [resolve] were written recently.
@@ -29,6 +28,18 @@ You may also be interested in browsing [GitHub's Rust][github-rust] page.
2928

3029
[github-rust]: https://github.com/trending?l=rust
3130

31+
## Is anyone using Rust in production?
32+
33+
Currently, Rust is still pre-1.0, and so we don't recommend that you use Rust
34+
in production unless you know exactly what you're getting into.
35+
36+
That said, there are two production deployments of Rust that we're aware of:
37+
38+
* [OpenDNS](http://labs.opendns.com/2013/10/04/zeromq-helping-us-block-malicious-domains/)
39+
* [Skylight](http://skylight.io)
40+
41+
Let the fact that this is an easily countable number be a warning.
42+
3243
## Does it run on Windows?
3344

3445
Yes. All development happens in lock-step on all 3 target platforms. Using MinGW, not Cygwin. Note that the windows implementation currently has some limitations: in particular 64-bit build is [not fully supported yet][win64], and all executables created by rustc [depend on libgcc DLL at runtime][libgcc].

src/doc/guide-lifetimes.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -431,36 +431,6 @@ In any case, whatever the lifetime of `r` is, the pointer produced by
431431
field of a struct is valid as long as the struct is valid. Therefore,
432432
the compiler accepts the function `get_x()`.
433433

434-
To emphasize this point, let’s look at a variation on the example, this
435-
time one that does not compile:
436-
437-
~~~ {.ignore}
438-
struct Point {x: f64, y: f64}
439-
fn get_x_sh(p: &Point) -> &f64 {
440-
&p.x // Error reported here
441-
}
442-
~~~
443-
444-
Here, the function `get_x_sh()` takes a reference as input and
445-
returns a reference. As before, the lifetime of the reference
446-
that will be returned is a parameter (specified by the
447-
caller). That means that `get_x_sh()` promises to return a reference
448-
that is valid for as long as the caller would like: this is
449-
subtly different from the first example, which promised to return a
450-
pointer that was valid for as long as its pointer argument was valid.
451-
452-
Within `get_x_sh()`, we see the expression `&p.x` which takes the
453-
address of a field of a Point. The presence of this expression
454-
implies that the compiler must guarantee that , so long as the
455-
resulting pointer is valid, the original Point won't be moved or changed.
456-
457-
But recall that `get_x_sh()` also promised to
458-
return a pointer that was valid for as long as the caller wanted it to
459-
be. Clearly, `get_x_sh()` is not in a position to make both of these
460-
guarantees; in fact, it cannot guarantee that the pointer will remain
461-
valid at all once it returns, as the parameter `p` may or may not be
462-
live in the caller. Therefore, the compiler will report an error here.
463-
464434
In general, if you borrow a struct or box to create a
465435
reference, it will only be valid within the function
466436
and cannot be returned. This is why the typical way to return references

src/doc/guide-pointers.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,12 @@ fn main() {
578578

579579
Notice we changed the signature of `add_one()` to request a mutable reference.
580580

581-
# Best practices
581+
## Best practices
582582

583583
Boxes are appropriate to use in two situations: Recursive data structures,
584584
and occasionally, when returning data.
585585

586-
## Recursive data structures
586+
### Recursive data structures
587587

588588
Sometimes, you need a recursive data structure. The simplest is known as a
589589
'cons list':
@@ -615,7 +615,7 @@ we don't know the size, and therefore, we need to heap allocate our list.
615615
Working with recursive or other unknown-sized data structures is the primary
616616
use-case for boxes.
617617

618-
## Returning data
618+
### Returning data
619619

620620
This is important enough to have its own section entirely. The TL;DR is this:
621621
you don't generally want to return pointers, even when you might in a language
@@ -733,18 +733,15 @@ This part is coming soon.
733733

734734
Here's a quick rundown of Rust's pointer types:
735735

736-
| Type | Name | Summary |
737-
|--------------|---------------------|-------------------------------------------|
738-
| `&T` | Reference | Allows one or more references to read `T` |
739-
| `&mut T` | Mutable Reference | Allows a single reference to |
740-
| | | read and write `T` |
741-
| `Box<T>` | Box | Heap allocated `T` with a single owner |
742-
| | | that may read and write `T`. |
743-
| `Rc<T>` | "arr cee" pointer | Heap allocated `T` with many readers |
744-
| `Arc<T>` | Arc pointer | Same as above, but safe sharing across |
745-
| | | threads |
746-
| `*const T` | Raw pointer | Unsafe read access to `T` |
747-
| `*mut T` | Mutable raw pointer | Unsafe read and write access to `T` |
736+
| Type | Name | Summary |
737+
|--------------|---------------------|---------------------------------------------------------------------|
738+
| `&T` | Reference | Allows one or more references to read `T` |
739+
| `&mut T` | Mutable Reference | Allows a single reference to read and write `T` |
740+
| `Box<T>` | Box | Heap allocated `T` with a single owner that may read and write `T`. |
741+
| `Rc<T>` | "arr cee" pointer | Heap allocated `T` with many readers |
742+
| `Arc<T>` | Arc pointer | Same as above, but safe sharing across threads |
743+
| `*const T` | Raw pointer | Unsafe read access to `T` |
744+
| `*mut T` | Mutable raw pointer | Unsafe read and write access to `T` |
748745

749746
# Related resources
750747

src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ reference. We also call this _borrowing_ the local variable
15031503
`on_the_stack`, because we are creating an alias: that is, another
15041504
route to the same data.
15051505

1506-
Likewise, in the case of `owned_box`,
1506+
Likewise, in the case of `on_the_heap`,
15071507
the `&` operator is used in conjunction with the `*` operator
15081508
to take a reference to the contents of the box.
15091509

src/liballoc/rc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
226226
/// data is cloned if the reference count is greater than one.
227227
#[inline]
228228
#[experimental]
229-
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
229+
pub fn make_unique(&mut self) -> &mut T {
230230
// Note that we hold a strong reference, which also counts as
231231
// a weak reference, so we only clone if there is an
232232
// additional reference of either kind.
@@ -247,7 +247,7 @@ impl<T: Clone> Rc<T> {
247247
impl<T> Deref<T> for Rc<T> {
248248
/// Borrow the value contained in the reference-counted box
249249
#[inline(always)]
250-
fn deref<'a>(&'a self) -> &'a T {
250+
fn deref(&self) -> &T {
251251
&self.inner().value
252252
}
253253
}
@@ -390,7 +390,7 @@ impl<T> Clone for Weak<T> {
390390

391391
#[doc(hidden)]
392392
trait RcBoxPtr<T> {
393-
fn inner<'a>(&'a self) -> &'a RcBox<T>;
393+
fn inner(&self) -> &RcBox<T>;
394394

395395
#[inline]
396396
fn strong(&self) -> uint { self.inner().strong.get() }
@@ -413,12 +413,12 @@ trait RcBoxPtr<T> {
413413

414414
impl<T> RcBoxPtr<T> for Rc<T> {
415415
#[inline(always)]
416-
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
416+
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
417417
}
418418

419419
impl<T> RcBoxPtr<T> for Weak<T> {
420420
#[inline(always)]
421-
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
421+
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
422422
}
423423

424424
#[cfg(test)]

src/libarena/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Arena {
207207
}
208208

209209
#[inline]
210-
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
210+
fn alloc_copy<T>(&self, op: || -> T) -> &T {
211211
unsafe {
212212
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
213213
mem::min_align_of::<T>());
@@ -261,7 +261,7 @@ impl Arena {
261261
}
262262

263263
#[inline]
264-
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
264+
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
265265
unsafe {
266266
let tydesc = get_tydesc::<T>();
267267
let (ty_ptr, ptr) =
@@ -285,7 +285,7 @@ impl Arena {
285285
/// Allocate a new item in the arena, using `op` to initialize the value
286286
/// and returning a reference to it.
287287
#[inline]
288-
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
288+
pub fn alloc<T>(&self, op: || -> T) -> &T {
289289
unsafe {
290290
if intrinsics::needs_drop::<T>() {
291291
self.alloc_noncopy(op)
@@ -458,13 +458,13 @@ impl<T> TypedArena<T> {
458458

459459
/// Allocates an object in the TypedArena, returning a reference to it.
460460
#[inline]
461-
pub fn alloc<'a>(&'a self, object: T) -> &'a T {
461+
pub fn alloc(&self, object: T) -> &T {
462462
if self.ptr == self.end {
463463
self.grow()
464464
}
465465

466-
let ptr: &'a T = unsafe {
467-
let ptr: &'a mut T = mem::transmute(self.ptr);
466+
let ptr: &T = unsafe {
467+
let ptr: &mut T = mem::transmute(self.ptr);
468468
ptr::write(ptr, object);
469469
self.ptr.set(self.ptr.get().offset(1));
470470
ptr

src/libcore/cmp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl PartialOrd for Ordering {
149149
/// If the first ordering is different, the first ordering is all that must be returned.
150150
/// If the first ordering is equal, then second ordering is returned.
151151
#[inline]
152-
#[deprecated = "Just call .cmp() on an Ordering"]
152+
#[deprecated = "Just call .cmp() on a tuple"]
153153
pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
154154
match o1 {
155155
Equal => o2,

src/libcore/failure.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! interface for failure is:
1717
//!
1818
//! ```ignore
19-
//! fn begin_unwind(fmt: &fmt::Arguments, file: &str, line: uint) -> !;
19+
//! fn begin_unwind(fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
2020
//! ```
2121
//!
2222
//! This definition allows for failing with any general message, but it does not
@@ -33,6 +33,7 @@
3333
use fmt;
3434
use intrinsics;
3535

36+
#[cfg(stage0)]
3637
#[cold] #[inline(never)] // this is the slow path, always
3738
#[lang="fail_"]
3839
fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
@@ -43,6 +44,7 @@ fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
4344
unsafe { intrinsics::abort() }
4445
}
4546

47+
#[cfg(stage0)]
4648
#[cold]
4749
#[lang="fail_bounds_check"]
4850
fn fail_bounds_check(file: &'static str, line: uint,
@@ -53,7 +55,31 @@ fn fail_bounds_check(file: &'static str, line: uint,
5355
unsafe { intrinsics::abort() }
5456
}
5557

56-
#[cold]
58+
#[cfg(not(stage0))]
59+
#[cold] #[inline(never)] // this is the slow path, always
60+
#[lang="fail_"]
61+
fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
62+
let (expr, file, line) = *expr_file_line;
63+
let ref file_line = (file, line);
64+
format_args!(|args| -> () {
65+
begin_unwind(args, file_line);
66+
}, "{}", expr);
67+
68+
unsafe { intrinsics::abort() }
69+
}
70+
71+
#[cfg(not(stage0))]
72+
#[cold] #[inline(never)]
73+
#[lang="fail_bounds_check"]
74+
fn fail_bounds_check(file_line: &(&'static str, uint),
75+
index: uint, len: uint) -> ! {
76+
format_args!(|args| -> () {
77+
begin_unwind(args, file_line);
78+
}, "index out of bounds: the len is {} but the index is {}", len, index);
79+
unsafe { intrinsics::abort() }
80+
}
81+
82+
#[cold] #[inline(never)]
5783
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
5884
#[allow(ctypes)]
5985
extern {

src/libcore/option.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
144144
use cmp::{PartialEq, Eq, Ord};
145145
use default::Default;
146+
use slice::Vector;
146147
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
147148
use mem;
148149
use slice;
@@ -216,15 +217,6 @@ impl<T> Option<T> {
216217
match *self { Some(ref mut x) => Some(x), None => None }
217218
}
218219

219-
/// Convert from `Option<T>` to `&[T]` (without copying)
220-
#[inline]
221-
pub fn as_slice<'r>(&'r self) -> &'r [T] {
222-
match *self {
223-
Some(ref x) => slice::ref_slice(x),
224-
None => &[]
225-
}
226-
}
227-
228220
/// Convert from `Option<T>` to `&mut [T]` (without copying)
229221
#[inline]
230222
pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
@@ -526,6 +518,17 @@ impl<T: Default> Option<T> {
526518
// Trait implementations
527519
/////////////////////////////////////////////////////////////////////////////
528520

521+
impl<T> Vector<T> for Option<T> {
522+
/// Convert from `Option<T>` to `&[T]` (without copying)
523+
#[inline]
524+
fn as_slice<'a>(&'a self) -> &'a [T] {
525+
match *self {
526+
Some(ref x) => slice::ref_slice(x),
527+
None => &[]
528+
}
529+
}
530+
}
531+
529532
impl<T> Default for Option<T> {
530533
#[inline]
531534
fn default() -> Option<T> { None }

src/libfourcc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ fn main() {
4040
*/
4141

4242
#![crate_name = "fourcc"]
43-
#![experimental]
43+
#![deprecated = "This is now a cargo package located at: \
44+
https://github.com/rust-lang/fourcc"]
4445
#![crate_type = "rlib"]
4546
#![crate_type = "dylib"]
4647
#![license = "MIT/ASL2"]

src/libhexfloat/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ fn main() {
3737
*/
3838

3939
#![crate_name = "hexfloat"]
40-
#![experimental]
40+
#![deprecated = "This is now a cargo package located at: \
41+
https://github.com/rust-lang/hexfloat"]
4142
#![crate_type = "rlib"]
4243
#![crate_type = "dylib"]
4344
#![license = "MIT/ASL2"]

src/librustc/util/io.rs renamed to src/librbml/io.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64>
3939
///
4040
/// ```rust
4141
/// # #![allow(unused_must_use)]
42-
/// use std::io::SeekableMemWriter;
42+
/// use rbml::io::SeekableMemWriter;
4343
///
4444
/// let mut w = SeekableMemWriter::new();
4545
/// w.write([0, 1, 2]);
@@ -128,6 +128,7 @@ impl Seek for SeekableMemWriter {
128128

129129
#[cfg(test)]
130130
mod tests {
131+
extern crate test;
131132
use super::SeekableMemWriter;
132133
use std::io;
133134
use test::Bencher;

0 commit comments

Comments
 (0)