Skip to content
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

Rollup of 12 pull requests #39869

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
51a2e2f
Allow more Cell methods for non-Copy types
RalfJung Feb 13, 2017
044ed10
Remove Copy bound from some Cell trait impls
RalfJung Feb 14, 2017
ca54fc7
Show five traits implementation in help when there are exactly five
seppo0010 Feb 14, 2017
b2c4e74
rustc: Link statically to the MSVCRT
alexcrichton Feb 14, 2017
aebd94f
Stabilize field init shorthand
est31 Feb 12, 2017
5156ded
make doc consistent with var name
king6cong Feb 15, 2017
938fed7
Update procedural-macros.md
DaseinPhaos Feb 15, 2017
b821313
sys/mod doc update and mod import order adjust
king6cong Feb 15, 2017
577497b
Fix typo
comonadd Feb 15, 2017
b6a1618
book: don’t use GNU extensions in the example unnecessarily
mina86 Feb 13, 2017
cf20d8e
static recursion test added to compile-fail test suite
cseale Feb 15, 2017
d5a4db3
Fix parameter to GetUserProfileDirectoryW
retep998 Feb 15, 2017
e77f856
Add a test that -fPIC is applied
brson Feb 14, 2017
7a028e5
Rollup merge of #39761 - est31:master, r=aturon
frewsxcv Feb 16, 2017
016f73b
Rollup merge of #39775 - mina86:master, r=steveklabnik
frewsxcv Feb 16, 2017
54d75ac
Rollup merge of #39793 - RalfJung:cell, r=alexcrichton
frewsxcv Feb 16, 2017
10d2f6c
Rollup merge of #39803 - brson:fpic, r=alexcrichton
frewsxcv Feb 16, 2017
4f8d4be
Rollup merge of #39804 - seppo0010:recommend-five-traits, r=jonathand…
frewsxcv Feb 16, 2017
bf5604c
Rollup merge of #39834 - cseale:feature-gate-static-recursion, r=est31
frewsxcv Feb 16, 2017
e359698
Rollup merge of #39837 - alexcrichton:llvm-crt-static, r=brson
frewsxcv Feb 16, 2017
c6bdab9
Rollup merge of #39839 - king6cong:refine-doc, r=frewsxcv
frewsxcv Feb 16, 2017
1b28c13
Rollup merge of #39840 - DaseinPhaos:patch-2, r=frewsxcv
frewsxcv Feb 16, 2017
047e310
Rollup merge of #39844 - king6cong:sys, r=alexcrichton
frewsxcv Feb 16, 2017
034acc1
Rollup merge of #39846 - WRONGWAY4YOU:typo-fix, r=frewsxcv
frewsxcv Feb 16, 2017
6343542
Rollup merge of #39861 - retep998:small-fix, r=alexcrichton
frewsxcv Feb 16, 2017
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
5 changes: 5 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ fn main() {
}
}
}

if target.contains("pc-windows-msvc") {
cmd.arg("-Z").arg("unstable-options");
cmd.arg("-C").arg("target-feature=+crt-static");
}
}

if verbose > 1 {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ pub fn llvm(build: &Build, target: &str) {
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);

if target.contains("msvc") {
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
}

if target.starts_with("i686") {
cfg.define("LLVM_BUILD_32_BITS", "ON");
}
Expand Down
14 changes: 6 additions & 8 deletions src/doc/book/src/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,36 +261,34 @@ The metavariable `$x` is parsed as a single expression node, and keeps its
place in the syntax tree even after substitution.

Another common problem in macro systems is ‘variable capture’. Here’s a C
macro, using [a GNU C extension] to emulate Rust’s expression blocks.

[a GNU C extension]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
macro using a block with multiple statements.

```text
#define LOG(msg) ({ \
#define LOG(msg) do { \
int state = get_log_state(); \
if (state > 0) { \
printf("log(%d): %s\n", state, msg); \
} \
})
} while (0)
```

Here’s a simple use case that goes terribly wrong:

```text
const char *state = "reticulating splines";
LOG(state)
LOG(state);
```

This expands to

```text
const char *state = "reticulating splines";
{
do {
int state = get_log_state();
if (state > 0) {
printf("log(%d): %s\n", state, state);
}
}
} while (0);
```

The second variable named `state` shadows the first one. This is a problem
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/src/procedural-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ created, we'll add it to our toml:
hello-world-derive = { path = "hello-world-derive" }
```

As for our the source of our `hello-world-derive` crate, here's an example:
As for the source of our `hello-world-derive` crate, here's an example:

```rust,ignore
extern crate proc_macro;
Expand Down
2 changes: 0 additions & 2 deletions src/doc/book/src/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ fields of the data structure are initialized with variables of the same
names as the fields.

```
#![feature(field_init_shorthand)]

#[derive(Debug)]
struct Person<'a> {
name: &'a str,
Expand Down
1 change: 0 additions & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2825,7 +2825,6 @@ This allows a compact syntax with less duplication.
Example:

```
# #![feature(field_init_shorthand)]
# struct Point3d { x: i32, y: i32, z: i32 }
# let x = 0;
# let y_value = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/grammar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The build of the rust part is included with `make tidy` and can be run with `mak

# Manual build

To use manually, assuming antlr4 ist installed at `/usr/share/java/antlr-complete.jar`:
To use manually, assuming antlr4 is installed at `/usr/share/java/antlr-complete.jar`:

```
antlr4 RustLexer.g4
Expand All @@ -20,8 +20,8 @@ for file in ../*/**.rs; do
done
```

Note That the `../*/**.rs` glob will match every `*.rs` file in the above
directory and all of its recursive children. This is a zsh extension.
Note that the `../*/**.rs` glob will match every `*.rs` file in the above
directory and all of its recursive children. This is a Zsh extension.


## Cleanup
Expand Down
124 changes: 62 additions & 62 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,66 +213,6 @@ impl<T:Copy> Cell<T> {
pub fn get(&self) -> T {
unsafe{ *self.value.get() }
}

/// Returns a reference to the underlying `UnsafeCell`.
///
/// # Examples
///
/// ```
/// #![feature(as_unsafe_cell)]
///
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
///
/// let uc = c.as_unsafe_cell();
/// ```
#[inline]
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
&self.value
}

/// Returns a raw pointer to the underlying data in this cell.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
///
/// let ptr = c.as_ptr();
/// ```
#[inline]
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
pub fn as_ptr(&self) -> *mut T {
self.value.get()
}

/// Returns a mutable reference to the underlying data.
///
/// This call borrows `Cell` mutably (at compile-time) which guarantees
/// that we possess the only reference.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
///
/// let mut c = Cell::new(5);
/// *c.get_mut() += 1;
///
/// assert_eq!(c.get(), 6);
/// ```
#[inline]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
pub fn get_mut(&mut self) -> &mut T {
unsafe {
&mut *self.value.get()
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -290,7 +230,7 @@ impl<T:Copy> Clone for Cell<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T:Default + Copy> Default for Cell<T> {
impl<T:Default> Default for Cell<T> {
/// Creates a `Cell<T>`, with the `Default` value for T.
#[inline]
fn default() -> Cell<T> {
Expand Down Expand Up @@ -346,7 +286,7 @@ impl<T:Ord + Copy> Ord for Cell<T> {
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T: Copy> From<T> for Cell<T> {
impl<T> From<T> for Cell<T> {
fn from(t: T) -> Cell<T> {
Cell::new(t)
}
Expand All @@ -370,6 +310,66 @@ impl<T> Cell<T> {
}
}

/// Returns a reference to the underlying `UnsafeCell`.
///
/// # Examples
///
/// ```
/// #![feature(as_unsafe_cell)]
///
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
///
/// let uc = c.as_unsafe_cell();
/// ```
#[inline]
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
&self.value
}

/// Returns a raw pointer to the underlying data in this cell.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
///
/// let ptr = c.as_ptr();
/// ```
#[inline]
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
pub fn as_ptr(&self) -> *mut T {
self.value.get()
}

/// Returns a mutable reference to the underlying data.
///
/// This call borrows `Cell` mutably (at compile-time) which guarantees
/// that we possess the only reference.
///
/// # Examples
///
/// ```
/// use std::cell::Cell;
///
/// let mut c = Cell::new(5);
/// *c.get_mut() += 1;
///
/// assert_eq!(c.get(), 6);
/// ```
#[inline]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
pub fn get_mut(&mut self) -> &mut T {
unsafe {
&mut *self.value.get()
}
}

/// Sets the contained value.
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(field_init_shorthand)]
#![cfg_attr(stage0,feature(field_init_shorthand))]
#![feature(i128_type)]
#![feature(libc)]
#![feature(loop_break_value)]
Expand Down
9 changes: 6 additions & 3 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use ty::fold::TypeFolder;
use ty::subst::Subst;
use util::nodemap::{FxHashMap, FxHashSet};

use std::cmp;
use std::fmt;
use syntax::ast;
use hir::{intravisit, Local, Pat};
Expand Down Expand Up @@ -392,12 +391,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
return;
}

let end = cmp::min(4, impl_candidates.len());
let end = if impl_candidates.len() <= 5 {
impl_candidates.len()
} else {
4
};
err.help(&format!("the following implementations were found:{}{}",
&impl_candidates[0..end].iter().map(|candidate| {
format!("\n {:?}", candidate)
}).collect::<String>(),
if impl_candidates.len() > 4 {
if impl_candidates.len() > 5 {
format!("\nand {} others", impl_candidates.len() - 4)
} else {
"".to_owned()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#![feature(rand)]
#![feature(core_intrinsics)]
#![feature(conservative_impl_trait)]
#![feature(field_init_shorthand)]
#![cfg_attr(stage0,feature(field_init_shorthand))]
#![feature(pub_restricted)]

extern crate graphviz;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This API is completely unstable and subject to change.
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![feature(field_init_shorthand)]
#![cfg_attr(stage0,feature(field_init_shorthand))]
#![feature(loop_break_value)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn pop_internal<K, V>(starting_bucket: FullBucketMut<K, V>)
/// Perform robin hood bucket stealing at the given `bucket`. You must
/// also pass that bucket's displacement so we don't have to recalculate it.
///
/// `hash`, `k`, and `v` are the elements to "robin hood" into the hashtable.
/// `hash`, `key`, and `val` are the elements to "robin hood" into the hashtable.
fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
mut displacement: usize,
mut hash: SafeHash,
Expand Down
12 changes: 6 additions & 6 deletions src/libstd/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//! The `std::sys` module is the abstracted interface through which
//! `std` talks to the underlying operating system. It has different
//! implementations for different operating system families, today
//! just Unix and Windows.
//! just Unix and Windows, and initial support for Redox.
//!
//! The centralization of platform-specific code in this module is
//! enforced by the "platform abstraction layer" tidy script in
//! `tools/tidy/pal.rs`.
//! `tools/tidy/src/pal.rs`.
//!
//! This module is closely related to the platform-independent system
//! integration code in `std::sys_common`. See that module's
Expand All @@ -34,14 +34,14 @@

pub use self::imp::*;

#[cfg(target_os = "redox")]
#[path = "redox/mod.rs"]
mod imp;

#[cfg(unix)]
#[path = "unix/mod.rs"]
mod imp;

#[cfg(windows)]
#[path = "windows/mod.rs"]
mod imp;

#[cfg(target_os = "redox")]
#[path = "redox/mod.rs"]
mod imp;
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ extern "system" {
pub fn Sleep(dwMilliseconds: DWORD);
pub fn GetProcessId(handle: HANDLE) -> DWORD;
pub fn GetUserProfileDirectoryW(hToken: HANDLE,
lpProfileDir: LPCWSTR,
lpProfileDir: LPWSTR,
lpcchSize: *mut DWORD) -> BOOL;
pub fn SetHandleInformation(hObject: HANDLE,
dwMask: DWORD,
Expand Down
Loading