Skip to content

Commit

Permalink
Auto merge of rust-lang#24967 - alexcrichton:rollup, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Apr 30, 2015
2 parents 551a74d + 1b34c09 commit 5449f5d
Show file tree
Hide file tree
Showing 134 changed files with 6,856 additions and 4,782 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
opt docs 1 "build standard library documentation"
opt compiler-docs 0 "build compiler documentation"
opt optimize-tests 1 "build tests with optimizations"
opt debuginfo-tests 0 "build tests with debugger metadata"
opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
opt llvm-assertions 0 "build LLVM with assertions"
opt debug-assertions 0 "build with debugging assertions"
Expand Down
7 changes: 7 additions & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ ifndef CFG_DISABLE_OPTIMIZE_TESTS
CTEST_RUSTC_FLAGS += -O
endif

# Analogously to the above, whether to pass `-g` when compiling tests
# is a separate choice from whether to pass `-g` when building the
# compiler and standard library themselves.
CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
ifdef CFG_ENABLE_DEBUGINFO_TESTS
CTEST_RUSTC_FLAGS += -g
endif

CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
Expand Down
6 changes: 5 additions & 1 deletion src/doc/not_found.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ function populate_rust_search() {

// #18540, use a single token

var a = document.createElement("a");
a.href = "http://doc.rust-lang.org/core/?search=" + encodeURIComponent(lt);
a.textContent = lt;
var search = document.getElementById('core-search');
search.innerHTML = "<a href=\"http://doc.rust-lang.org/core/?search=" + lt + "\">" + lt + "</a>";
search.innerHTML = "";
search.appendChild(a);
}
populate_site_search();
populate_rust_search();
Expand Down
6 changes: 3 additions & 3 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Non-doc comments are interpreted as a form of whitespace.

## Whitespace

Whitespace is any non-empty string containing any the following characters:
Whitespace is any non-empty string containing only the following characters:

- `U+0020` (space, `' '`)
- `U+0009` (tab, `'\t'`)
Expand Down Expand Up @@ -1897,8 +1897,8 @@ release builds.

There are two kinds of configuration options, one that is either defined or not
(`#[cfg(foo)]`), and the other that contains a string that can be checked
against (`#[cfg(bar = "baz")]` (currently only compiler-defined configuration
options can have the latter form).
against (`#[cfg(bar = "baz")]`). Currently, only compiler-defined configuration
options can have the latter form.

```
// The function is only included in the build when compiling for OSX
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ vector. When we try to compile this program, we get an error:

```text
error: cannot borrow `x` as mutable because it is also borrowed as immutable
x.push(4);
x.push("foo");
^
note: previous borrow of `x` occurs here; the immutable borrow prevents
subsequent moves or mutable borrows of `x` until the borrow ends
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/benchmark-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn add_two(a: i32) -> i32 {
}
#[cfg(test)]
mod test {
mod tests {
use super::*;
use test::Bencher;
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ as `unimplemented!` until you’re ready to write them.
# Procedural macros

If Rust’s macro system can’t do what you need, you may want to write a
[compiler plugin](plugins.html) instead. Compared to `macro_rules!`
[compiler plugin](compiler-plugins.html) instead. Compared to `macro_rules!`
macros, this is significantly more work, the interfaces are much less stable,
and bugs can be much harder to track down. In exchange you get the
flexibility of running arbitrary Rust code within the compiler. Syntax
Expand Down
43 changes: 40 additions & 3 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ extern "rust-intrinsic" {
pub fn atomic_fence_rel();
pub fn atomic_fence_acqrel();

/// A compiler-only memory barrier.
///
/// Memory accesses will never be reordered across this barrier by the compiler,
/// but no instructions will be emitted for it. This is appropriate for operations
/// on the same thread that may be preempted, such as when interacting with signal
/// handlers.
#[cfg(not(stage0))] // SNAP 857ef6e
pub fn atomic_singlethreadfence();
#[cfg(not(stage0))] // SNAP 857ef6e
pub fn atomic_singlethreadfence_acq();
#[cfg(not(stage0))] // SNAP 857ef6e
pub fn atomic_singlethreadfence_rel();
#[cfg(not(stage0))] // SNAP 857ef6e
pub fn atomic_singlethreadfence_acqrel();

/// Aborts the execution of the process.
pub fn abort() -> !;

Expand Down Expand Up @@ -255,12 +270,17 @@ extern "rust-intrinsic" {
/// Returns `true` if a type is managed (will be allocated on the local heap)
pub fn owns_managed<T>() -> bool;

/// Calculates the offset from a pointer. The offset *must* be in-bounds of
/// the object, or one-byte-past-the-end. An arithmetic overflow is also
/// undefined behaviour.
/// Calculates the offset from a pointer.
///
/// This is implemented as an intrinsic to avoid converting to and from an
/// integer, since the conversion would throw away aliasing information.
///
/// # Safety
///
/// Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object. If either pointer is out of
/// bounds or arithmetic overflow occurs then any further use of the
/// returned value will result in undefined behavior.
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;

/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source
Expand Down Expand Up @@ -562,3 +582,20 @@ extern "rust-intrinsic" {
/// cast to a `u64`; if `T` has no discriminant, returns 0.
pub fn discriminant_value<T>(v: &T) -> u64;
}

#[cfg(not(stage0))]
extern "rust-intrinsic" {
/// Performs an unchecked signed division, which results in undefined behavior,
/// in cases where y == 0, or x == int::MIN and y == -1
pub fn unchecked_sdiv<T>(x: T, y: T) -> T;
/// Performs an unchecked unsigned division, which results in undefined behavior,
/// in cases where y == 0
pub fn unchecked_udiv<T>(x: T, y: T) -> T;

/// Returns the remainder of an unchecked signed division, which results in
/// undefined behavior, in cases where y == 0, or x == int::MIN and y == -1
pub fn unchecked_urem<T>(x: T, y: T) -> T;
/// Returns the remainder of an unchecked signed division, which results in
/// undefined behavior, in cases where y == 0
pub fn unchecked_srem<T>(x: T, y: T) -> T;
}
15 changes: 14 additions & 1 deletion src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,20 @@ macro_rules! uint_impl {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn trailing_zeros(self) -> u32 {
unsafe { $cttz(self as $ActualT) as u32 }
// As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic
// emits two conditional moves on x86_64. By promoting the value to
// u16 and setting bit 8, we get better code without any conditional
// operations.
// FIXME: There's a LLVM patch (http://reviews.llvm.org/D9284)
// pending, remove this workaround once LLVM generates better code
// for cttz8.
unsafe {
if $BITS == 8 {
intrinsics::cttz16(self as u16 | 0x100) as u32
} else {
$cttz(self as $ActualT) as u32
}
}
}

/// Shifts the bits to the left by a specified amount, `n`,
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ impl<T: ?Sized> *const T {
///
/// # Safety
///
/// The offset must be in-bounds of the object, or one-byte-past-the-end.
/// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
/// the pointer is used.
/// Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object. If either pointer is out of
/// bounds or arithmetic overflow occurs then
/// any further use of the returned value will result in undefined behavior.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub unsafe fn offset(self, count: isize) -> *const T where T: Sized {
Expand Down
19 changes: 8 additions & 11 deletions src/libcoretest/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ fn test_ord() {
assert!(big > None);
}

/* FIXME(#20575)
#[test]
fn test_collect() {
let v: Option<Vec<isize>> = (0..0).map(|_| Some(0)).collect();
Expand All @@ -241,28 +240,26 @@ fn test_collect() {

assert!(v == None);
}
*/


#[test]
fn test_cloned() {
let val1 = 1u32;
let mut val2 = 2u32;
let val1_ref = &val1;
let val = 1u32;
let val_ref = &val;
let opt_none: Option<&'static u32> = None;
let opt_ref = Some(&val1);
let opt_ref_ref = Some(&val1_ref);
let opt_mut_ref = Some(&mut val2);
let opt_ref = Some(&val);
let opt_ref_ref = Some(&val_ref);

// None works
assert_eq!(opt_none.clone(), None);
assert_eq!(opt_none.cloned(), None);

// Immutable ref works
assert_eq!(opt_ref.clone(), Some(&val1));
assert_eq!(opt_ref.clone(), Some(&val));
assert_eq!(opt_ref.cloned(), Some(1u32));

// Double Immutable ref works
assert_eq!(opt_ref_ref.clone(), Some(&val1_ref));
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val1));
assert_eq!(opt_ref_ref.clone(), Some(&val_ref));
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val));
assert_eq!(opt_ref_ref.cloned().cloned(), Some(1u32));
}
24 changes: 11 additions & 13 deletions src/libcoretest/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub fn op1() -> Result<isize, &'static str> { Ok(666) }
pub fn op2() -> Result<isize, &'static str> { Err("sadface") }
fn op1() -> Result<isize, &'static str> { Ok(666) }
fn op2() -> Result<isize, &'static str> { Err("sadface") }

#[test]
pub fn test_and() {
fn test_and() {
assert_eq!(op1().and(Ok(667)).unwrap(), 667);
assert_eq!(op1().and(Err::<i32, &'static str>("bad")).unwrap_err(),
"bad");
Expand All @@ -23,7 +23,7 @@ pub fn test_and() {
}

#[test]
pub fn test_and_then() {
fn test_and_then() {
assert_eq!(op1().and_then(|i| Ok::<isize, &'static str>(i + 1)).unwrap(), 667);
assert_eq!(op1().and_then(|_| Err::<isize, &'static str>("bad")).unwrap_err(),
"bad");
Expand All @@ -35,7 +35,7 @@ pub fn test_and_then() {
}

#[test]
pub fn test_or() {
fn test_or() {
assert_eq!(op1().or(Ok::<_, &'static str>(667)).unwrap(), 666);
assert_eq!(op1().or(Err("bad")).unwrap(), 666);

Expand All @@ -44,7 +44,7 @@ pub fn test_or() {
}

#[test]
pub fn test_or_else() {
fn test_or_else() {
assert_eq!(op1().or_else(|_| Ok::<isize, &'static str>(667)).unwrap(), 666);
assert_eq!(op1().or_else(|e| Err::<isize, &'static str>(e)).unwrap(), 666);

Expand All @@ -54,18 +54,17 @@ pub fn test_or_else() {
}

#[test]
pub fn test_impl_map() {
fn test_impl_map() {
assert!(Ok::<isize, isize>(1).map(|x| x + 1) == Ok(2));
assert!(Err::<isize, isize>(1).map(|x| x + 1) == Err(1));
}

#[test]
pub fn test_impl_map_err() {
fn test_impl_map_err() {
assert!(Ok::<isize, isize>(1).map_err(|x| x + 1) == Ok(1));
assert!(Err::<isize, isize>(1).map_err(|x| x + 1) == Err(2));
}

/* FIXME(#20575)
#[test]
fn test_collect() {
let v: Result<Vec<isize>, ()> = (0..0).map(|_| Ok::<isize, ()>(0)).collect();
Expand All @@ -86,10 +85,9 @@ fn test_collect() {
let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();
assert!(v == Err(1));
}
*/

#[test]
pub fn test_fmt_default() {
fn test_fmt_default() {
let ok: Result<isize, &'static str> = Ok(100);
let err: Result<isize, &'static str> = Err("Err");

Expand All @@ -100,7 +98,7 @@ pub fn test_fmt_default() {
}

#[test]
pub fn test_unwrap_or() {
fn test_unwrap_or() {
let ok: Result<isize, &'static str> = Ok(100);
let ok_err: Result<isize, &'static str> = Err("Err");

Expand All @@ -109,7 +107,7 @@ pub fn test_unwrap_or() {
}

#[test]
pub fn test_unwrap_or_else() {
fn test_unwrap_or_else() {
fn handler(msg: &'static str) -> isize {
if msg == "I got this." {
50
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The rustc crate itself consists of the following submodules
- util: ubiquitous types and helper functions
- lib: bindings to LLVM

The entry-point for the compiler is main() in the librustc_trans
The entry-point for the compiler is main() in the librustc_driver
crate.

The 3 central data structures:
Expand Down
17 changes: 16 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,22 @@ enum Method { GET, POST }
```
"##,

E0265: r##"
This error indicates that a static or constant references itself.
All statics and constants need to resolve to a value in an acyclic manner.
For example, neither of the following can be sensibly compiled:
```
const X: u32 = X;
```
```
const X: u32 = Y;
const Y: u32 = X;
```
"##,

E0267: r##"
This error indicates the use of loop keyword (break or continue) inside a
closure but outside of any loop. Break and continue can be used as normal
Expand Down Expand Up @@ -500,7 +516,6 @@ register_diagnostics! {
E0262, // illegal lifetime parameter name
E0263, // lifetime name declared twice in same scope
E0264, // unknown external lang item
E0265, // recursive constant
E0266, // expected item
E0269, // not all control paths return a value
E0270, // computation may converge in a function marked as diverging
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]

#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(fs_canonicalize)]
#![feature(hash)]
#![feature(into_cow)]
#![feature(libc)]
#![feature(path_ext)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(path_ext)]
#![feature(str_char)]
#![feature(into_cow)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test))]

#![allow(trivial_casts)]
Expand Down Expand Up @@ -138,7 +140,6 @@ pub mod plugin;
pub mod lint;

pub mod util {
pub use rustc_back::fs;
pub use rustc_back::sha2;

pub mod common;
Expand Down
Loading

0 comments on commit 5449f5d

Please sign in to comment.