Skip to content

Rolling up PRs in the queue #16141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
571f6cf
fix variable name in tutorial
colinvh Jul 5, 2014
134946d
rustrt: Make begin_unwind take a single file/line pointer
brson Jul 29, 2014
4db68e6
Modify failure lang items to take less pointers.
brson Jul 29, 2014
678814a
core: Add #[inline(never)] to failure functions
brson Jul 30, 2014
4562803
core: Fix failure doc comment
brson Jul 30, 2014
4c196c2
Fix deprecation commment on `core::cmp::lexical_ordering`
tbu- Jul 30, 2014
ea1b637
fix formatting in pointer guide table
steveklabnik Jul 30, 2014
e1dcbef
remove serialize::ebml, add librbml
erickt Jul 30, 2014
fd9ad77
Move SeekableMemWriter into librbml
erickt Jul 30, 2014
20658f7
Fix heading levels in pointer guide
steveklabnik Jul 30, 2014
ecac4d2
rustrt: Don't conditionally init the at_exit QUEUE
alexcrichton Jul 30, 2014
c3fcc0b
hexfloat: Deprecate to move out of the repo
alexcrichton Jul 30, 2014
9956aff
Add examples for GenericPath methods.
nham Jul 30, 2014
a0238d5
Use byte strings throughout examples. Add an example that was missed …
nham Jul 30, 2014
acbac84
Add logic to skip the doc tests on windows since these examples are u…
nham Jul 30, 2014
efd42a3
Byte literals!
SimonSapin Jul 30, 2014
cdb8a88
Add a non-regression test for issue #8372
SimonSapin Jul 30, 2014
5446aed
Deprecate semver.
errordeveloper Jul 30, 2014
a8f58a0
Deprecate uuid.
errordeveloper Jul 30, 2014
a5e74a9
Deprecate fourcc.
errordeveloper Jul 30, 2014
daaa20e
Remove incorrect example
steveklabnik Jul 30, 2014
fd08d5f
Add note about production deployments.
steveklabnik Jul 30, 2014
bd15854
librustc: Don't ICE when trying to subst regions in destructor call.
luqmana Jul 31, 2014
bc24819
librustc: Don't ICE with struct exprs where the name is not a valid s…
luqmana Jul 31, 2014
2467c6e
Implement slice::Vector for Option<T> and CVec<T>
donkopotamus Jul 31, 2014
f861848
alloc, arena, test, url, uuid: Elide lifetimes.
omasanori Jul 30, 2014
ec79d36
Test fixes from the rollup
alexcrichton Jul 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
uuid serialize sync getopts collections num test time rand \
url log regex graphviz core rlibc alloc debug rustrt \
url log regex graphviz core rbml rlibc alloc debug rustrt \
unicode
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
rustc_llvm rustc_back
Expand All @@ -71,7 +71,7 @@ DEPS_green := std native:context_switch
DEPS_rustuv := std native:uv native:uv_support
DEPS_native := std
DEPS_syntax := std term serialize log fmt_macros debug
DEPS_rustc := syntax flate arena serialize getopts \
DEPS_rustc := syntax flate arena serialize getopts rbml \
time log graphviz debug rustc_llvm rustc_back
DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
Expand All @@ -82,6 +82,7 @@ DEPS_arena := std
DEPS_graphviz := std
DEPS_glob := std
DEPS_serialize := std log
DEPS_rbml := std log serialize
DEPS_term := std log
DEPS_semver := std
DEPS_uuid := std serialize
Expand All @@ -91,7 +92,7 @@ DEPS_collections := core alloc unicode
DEPS_fourcc := rustc syntax std
DEPS_hexfloat := rustc syntax std
DEPS_num := std
DEPS_test := std getopts serialize term time regex native:rust_test_helpers
DEPS_test := std getopts serialize rbml term time regex native:rust_test_helpers
DEPS_time := std serialize
DEPS_rand := core
DEPS_url := std
Expand Down
13 changes: 12 additions & 1 deletion src/doc/complement-lang-faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
% Language FAQ


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

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.
Expand Down Expand Up @@ -29,6 +28,18 @@ You may also be interested in browsing [GitHub's Rust][github-rust] page.

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

## Is anyone using Rust in production?

Currently, Rust is still pre-1.0, and so we don't recommend that you use Rust
in production unless you know exactly what you're getting into.

That said, there are two production deployments of Rust that we're aware of:

* [OpenDNS](http://labs.opendns.com/2013/10/04/zeromq-helping-us-block-malicious-domains/)
* [Skylight](http://skylight.io)

Let the fact that this is an easily countable number be a warning.

## Does it run on Windows?

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].
Expand Down
30 changes: 0 additions & 30 deletions src/doc/guide-lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,36 +431,6 @@ In any case, whatever the lifetime of `r` is, the pointer produced by
field of a struct is valid as long as the struct is valid. Therefore,
the compiler accepts the function `get_x()`.

To emphasize this point, let’s look at a variation on the example, this
time one that does not compile:

~~~ {.ignore}
struct Point {x: f64, y: f64}
fn get_x_sh(p: &Point) -> &f64 {
&p.x // Error reported here
}
~~~

Here, the function `get_x_sh()` takes a reference as input and
returns a reference. As before, the lifetime of the reference
that will be returned is a parameter (specified by the
caller). That means that `get_x_sh()` promises to return a reference
that is valid for as long as the caller would like: this is
subtly different from the first example, which promised to return a
pointer that was valid for as long as its pointer argument was valid.

Within `get_x_sh()`, we see the expression `&p.x` which takes the
address of a field of a Point. The presence of this expression
implies that the compiler must guarantee that , so long as the
resulting pointer is valid, the original Point won't be moved or changed.

But recall that `get_x_sh()` also promised to
return a pointer that was valid for as long as the caller wanted it to
be. Clearly, `get_x_sh()` is not in a position to make both of these
guarantees; in fact, it cannot guarantee that the pointer will remain
valid at all once it returns, as the parameter `p` may or may not be
live in the caller. Therefore, the compiler will report an error here.

In general, if you borrow a struct or box to create a
reference, it will only be valid within the function
and cannot be returned. This is why the typical way to return references
Expand Down
27 changes: 12 additions & 15 deletions src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ fn main() {

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

# Best practices
## Best practices

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

## Recursive data structures
### Recursive data structures

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

## Returning data
### Returning data

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

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

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

# Related resources

Expand Down
2 changes: 1 addition & 1 deletion src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ reference. We also call this _borrowing_ the local variable
`on_the_stack`, because we are creating an alias: that is, another
route to the same data.

Likewise, in the case of `owned_box`,
Likewise, in the case of `on_the_heap`,
the `&` operator is used in conjunction with the `*` operator
to take a reference to the contents of the box.

Expand Down
10 changes: 5 additions & 5 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
/// data is cloned if the reference count is greater than one.
#[inline]
#[experimental]
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
pub fn make_unique(&mut self) -> &mut T {
// Note that we hold a strong reference, which also counts as
// a weak reference, so we only clone if there is an
// additional reference of either kind.
Expand All @@ -247,7 +247,7 @@ impl<T: Clone> Rc<T> {
impl<T> Deref<T> for Rc<T> {
/// Borrow the value contained in the reference-counted box
#[inline(always)]
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
&self.inner().value
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ impl<T> Clone for Weak<T> {

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

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

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

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

#[cfg(test)]
Expand Down
12 changes: 6 additions & 6 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Arena {
}

#[inline]
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_copy<T>(&self, op: || -> T) -> &T {
unsafe {
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
mem::min_align_of::<T>());
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Arena {
}

#[inline]
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
unsafe {
let tydesc = get_tydesc::<T>();
let (ty_ptr, ptr) =
Expand All @@ -285,7 +285,7 @@ impl Arena {
/// Allocate a new item in the arena, using `op` to initialize the value
/// and returning a reference to it.
#[inline]
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
pub fn alloc<T>(&self, op: || -> T) -> &T {
unsafe {
if intrinsics::needs_drop::<T>() {
self.alloc_noncopy(op)
Expand Down Expand Up @@ -458,13 +458,13 @@ impl<T> TypedArena<T> {

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

let ptr: &'a T = unsafe {
let ptr: &'a mut T = mem::transmute(self.ptr);
let ptr: &T = unsafe {
let ptr: &mut T = mem::transmute(self.ptr);
ptr::write(ptr, object);
self.ptr.set(self.ptr.get().offset(1));
ptr
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl PartialOrd for Ordering {
/// If the first ordering is different, the first ordering is all that must be returned.
/// If the first ordering is equal, then second ordering is returned.
#[inline]
#[deprecated = "Just call .cmp() on an Ordering"]
#[deprecated = "Just call .cmp() on a tuple"]
pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
match o1 {
Equal => o2,
Expand Down
30 changes: 28 additions & 2 deletions src/libcore/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! interface for failure is:
//!
//! ```ignore
//! fn begin_unwind(fmt: &fmt::Arguments, file: &str, line: uint) -> !;
//! fn begin_unwind(fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
//! ```
//!
//! This definition allows for failing with any general message, but it does not
Expand All @@ -33,6 +33,7 @@
use fmt;
use intrinsics;

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

#[cfg(stage0)]
#[cold]
#[lang="fail_bounds_check"]
fn fail_bounds_check(file: &'static str, line: uint,
Expand All @@ -53,7 +55,31 @@ fn fail_bounds_check(file: &'static str, line: uint,
unsafe { intrinsics::abort() }
}

#[cold]
#[cfg(not(stage0))]
#[cold] #[inline(never)] // this is the slow path, always
#[lang="fail_"]
fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
let (expr, file, line) = *expr_file_line;
let ref file_line = (file, line);
format_args!(|args| -> () {
begin_unwind(args, file_line);
}, "{}", expr);

unsafe { intrinsics::abort() }
}

#[cfg(not(stage0))]
#[cold] #[inline(never)]
#[lang="fail_bounds_check"]
fn fail_bounds_check(file_line: &(&'static str, uint),
index: uint, len: uint) -> ! {
format_args!(|args| -> () {
begin_unwind(args, file_line);
}, "index out of bounds: the len is {} but the index is {}", len, index);
unsafe { intrinsics::abort() }
}

#[cold] #[inline(never)]
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
#[allow(ctypes)]
extern {
Expand Down
21 changes: 12 additions & 9 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@

use cmp::{PartialEq, Eq, Ord};
use default::Default;
use slice::Vector;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use mem;
use slice;
Expand Down Expand Up @@ -216,15 +217,6 @@ impl<T> Option<T> {
match *self { Some(ref mut x) => Some(x), None => None }
}

/// Convert from `Option<T>` to `&[T]` (without copying)
#[inline]
pub fn as_slice<'r>(&'r self) -> &'r [T] {
match *self {
Some(ref x) => slice::ref_slice(x),
None => &[]
}
}

/// Convert from `Option<T>` to `&mut [T]` (without copying)
#[inline]
pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
Expand Down Expand Up @@ -526,6 +518,17 @@ impl<T: Default> Option<T> {
// Trait implementations
/////////////////////////////////////////////////////////////////////////////

impl<T> Vector<T> for Option<T> {
/// Convert from `Option<T>` to `&[T]` (without copying)
#[inline]
fn as_slice<'a>(&'a self) -> &'a [T] {
match *self {
Some(ref x) => slice::ref_slice(x),
None => &[]
}
}
}

impl<T> Default for Option<T> {
#[inline]
fn default() -> Option<T> { None }
Expand Down
3 changes: 2 additions & 1 deletion src/libfourcc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fn main() {
*/

#![crate_name = "fourcc"]
#![experimental]
#![deprecated = "This is now a cargo package located at: \
https://github.com/rust-lang/fourcc"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
Expand Down
3 changes: 2 additions & 1 deletion src/libhexfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ fn main() {
*/

#![crate_name = "hexfloat"]
#![experimental]
#![deprecated = "This is now a cargo package located at: \
https://github.com/rust-lang/hexfloat"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/util/io.rs → src/librbml/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64>
///
/// ```rust
/// # #![allow(unused_must_use)]
/// use std::io::SeekableMemWriter;
/// use rbml::io::SeekableMemWriter;
///
/// let mut w = SeekableMemWriter::new();
/// w.write([0, 1, 2]);
Expand Down Expand Up @@ -128,6 +128,7 @@ impl Seek for SeekableMemWriter {

#[cfg(test)]
mod tests {
extern crate test;
use super::SeekableMemWriter;
use std::io;
use test::Bencher;
Expand Down
Loading