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 9 pull requests #47859

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c2e2612
Punctuation and clarity fixes.
jimmantooth Jan 17, 2018
831ff77
implement Send for process::Command on unix
little-dude Jan 25, 2018
9e6ed17
make Command.argv Send on unix platforms
little-dude Jan 26, 2018
0ac4659
Add line numbers and columns to error messages spanning multiple files
varkor Jan 26, 2018
077d343
add test checking that process::Command is Send
little-dude Jan 26, 2018
aa6cc6e
Fix test in macro_backtrace
varkor Jan 26, 2018
a21b7b3
Improve formatting of else block
varkor Jan 27, 2018
2497d10
Whitelist aes x86 feature flag
gnzlbg Jan 28, 2018
b32dbbc
Whitelist v7 feature for ARM and AARCH64.
gnzlbg Jan 28, 2018
7b4cbbd
Document that `Index` ops can panic on `HashMap` & `BTreeMap`.
frewsxcv Jan 29, 2018
e09a8bd
Add per-stage RUSTFLAGS: RUSTFLAGS_STAGE_{0,1,2} and RUSTFLAGS_STAGE_…
Mark-Simulacrum Jan 29, 2018
8389b66
Increase test coverage of use_nested_groups
pietroalbini Jan 29, 2018
898fdcc
Make run-pass/env-home-dir.rs test more robust
malbarbo Jan 24, 2018
adeb0ae
move comment right onto the line in question
nikomatsakis Jan 29, 2018
525c8d0
Rollup merge of #47515 - jimmantooth:patch-1, r=QuietMisdreavus
kennytm Jan 29, 2018
fdf6dad
Rollup merge of #47718 - malbarbo:env-home-dir, r=nikomatsakis
kennytm Jan 29, 2018
d82532a
Rollup merge of #47760 - little-dude:master, r=alexcrichton
kennytm Jan 29, 2018
f504a9b
Rollup merge of #47780 - varkor:cross-file-errors-line-col, r=estebank
kennytm Jan 29, 2018
0de9a8a
Rollup merge of #47822 - gnzlbg:patch-1, r=alexcrichton
kennytm Jan 29, 2018
a07de32
Rollup merge of #47826 - gnzlbg:patch-2, r=alexcrichton
kennytm Jan 29, 2018
1705668
Rollup merge of #47836 - Mark-Simulacrum:stage-flags, r=alexcrichton
kennytm Jan 29, 2018
c4b1ee5
Rollup merge of #47839 - frewsxcv:frewsxcv-map-index, r=QuietMisdreavus
kennytm Jan 29, 2018
667f6df
Rollup merge of #47853 - rust-lang:increase-nested-groups-test-covera…
kennytm Jan 29, 2018
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
12 changes: 12 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,18 @@ impl<'a> Builder<'a> {
stage = compiler.stage;
}

let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default();
if stage != 0 {
let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default();
extra_args.push_str(" ");
extra_args.push_str(&s);
}

if !extra_args.is_empty() {
cargo.env("RUSTFLAGS",
format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args));
}

// Customize the compiler we're running. Specify the compiler to cargo
// as our shim and then pass it some various options used to configure
// how the actual compiler itself is called.
Expand Down
6 changes: 3 additions & 3 deletions src/doc/unstable-book/src/language-features/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ closure-like semantics. Namely:
types and such.

* Traits like `Send` and `Sync` are automatically implemented for a `Generator`
depending on the captured variables of the environment. Unlike closures though
depending on the captured variables of the environment. Unlike closures,
generators also depend on variables live across suspension points. This means
that although the ambient environment may be `Send` or `Sync`, the generator
itself may not be due to internal variables live across `yield` points being
not-`Send` or not-`Sync`. Note, though, that generators, like closures, do
not-`Send` or not-`Sync`. Note that generators, like closures, do
not implement traits like `Copy` or `Clone` automatically.

* Whenever a generator is dropped it will drop all captured environment
Expand All @@ -155,7 +155,7 @@ lifted at a future date, the design is ongoing!

### Generators as state machines

In the compiler generators are currently compiled as state machines. Each
In the compiler, generators are currently compiled as state machines. Each
`yield` expression will correspond to a different state that stores all live
variables over that suspension point. Resumption of a generator will dispatch on
the current state and then execute internally until a `yield` is reached, at
Expand Down
5 changes: 5 additions & 0 deletions src/liballoc/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,11 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
{
type Output = V;

/// Returns a reference to the value corresponding to the supplied key.
///
/// # Panics
///
/// Panics if the key is not present in the `BTreeMap`.
#[inline]
fn index(&self, key: &Q) -> &V {
self.get(key).expect("no entry found for key")
Expand Down
15 changes: 14 additions & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,21 @@ impl EmitterWriter {

// Then, the secondary file indicator
buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber);
let loc = if let Some(first_line) = annotated_file.lines.first() {
let col = if let Some(first_annotation) = first_line.annotations.first() {
format!(":{}", first_annotation.start_col + 1)
} else {
"".to_string()
};
format!("{}:{}{}",
annotated_file.file.name,
cm.doctest_offset_line(first_line.line_index),
col)
} else {
annotated_file.file.name.to_string()
};
buffer.append(buffer_msg_line_offset + 1,
&annotated_file.file.name.to_string(),
&loc,
Style::LineAndColumn);
for _ in 0..max_line_num_len {
buffer.prepend(buffer_msg_line_offset + 1, " ", Style::NoStyle);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_errors/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub struct FileInfo {

/// The "primary file", if any, gets a `-->` marker instead of
/// `>>>`, and has a line-number/column printed and not just a
/// filename. It appears first in the listing. It is known to
/// filename (other files are not guaranteed to have line numbers
/// or columns). It appears first in the listing. It is known to
/// contain at least one primary span, though primary spans (which
/// are designated with `^^^`) may also occur in other files.
primary_span: Option<Span>,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ unsafe fn configure_llvm(sess: &Session) {
// detection code will walk past the end of the feature array,
// leading to crashes.

const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "vfp4\0"];
const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0", "vfp2\0", "vfp3\0", "vfp4\0"];

const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0"];
const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0"];

const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0",
"sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0",
"ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0",
"sse4a\0", "rdrnd\0", "rdseed\0", "fma\0",
"xsave\0", "xsaveopt\0", "xsavec\0",
"xsaves\0",
"xsaves\0", "aes\0",
"avx512bw\0", "avx512cd\0",
"avx512dq\0", "avx512er\0",
"avx512f\0", "avx512ifma\0",
Expand Down
9 changes: 7 additions & 2 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,9 +1384,14 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S>
{
type Output = V;

/// Returns a reference to the value corresponding to the supplied key.
///
/// # Panics
///
/// Panics if the key is not present in the `HashMap`.
#[inline]
fn index(&self, index: &Q) -> &V {
self.get(index).expect("no entry found for key")
fn index(&self, key: &Q) -> &V {
self.get(key).expect("no entry found for key")
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,4 +1843,10 @@ mod tests {
}
assert!(events > 0);
}

#[test]
fn test_command_implements_send() {
fn take_send_type<T: Send>(_: T) {}
take_send_type(Command::new(""))
}
}
16 changes: 11 additions & 5 deletions src/libstd/sys/unix/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Command {
// other keys.
program: CString,
args: Vec<CString>,
argv: Vec<*const c_char>,
argv: Argv,
env: CommandEnv<DefaultEnvKey>,

cwd: Option<CString>,
Expand All @@ -58,6 +58,12 @@ pub struct Command {
stderr: Option<Stdio>,
}

// Create a new type for argv, so that we can make it `Send`
struct Argv(Vec<*const c_char>);

// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args`
unsafe impl Send for Argv {}

// passed back to std::process with the pipes connected to the child, if any
// were requested
pub struct StdioPipes {
Expand Down Expand Up @@ -92,7 +98,7 @@ impl Command {
let mut saw_nul = false;
let program = os2c(program, &mut saw_nul);
Command {
argv: vec![program.as_ptr(), ptr::null()],
argv: Argv(vec![program.as_ptr(), ptr::null()]),
program,
args: Vec::new(),
env: Default::default(),
Expand All @@ -111,8 +117,8 @@ impl Command {
// Overwrite the trailing NULL pointer in `argv` and then add a new null
// pointer.
let arg = os2c(arg, &mut self.saw_nul);
self.argv[self.args.len() + 1] = arg.as_ptr();
self.argv.push(ptr::null());
self.argv.0[self.args.len() + 1] = arg.as_ptr();
self.argv.0.push(ptr::null());

// Also make sure we keep track of the owned value to schedule a
// destructor for this memory.
Expand All @@ -133,7 +139,7 @@ impl Command {
self.saw_nul
}
pub fn get_argv(&self) -> &Vec<*const c_char> {
&self.argv
&self.argv.0
}

#[allow(dead_code)]
Expand Down
5 changes: 4 additions & 1 deletion src/test/run-pass/env-home-dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ fn main() {
if cfg!(target_os = "android") {
assert!(home_dir().is_none());
} else {
assert!(home_dir().is_some());
// When HOME is not set, some platforms return `None`,
// but others return `Some` with a default.
// Just check that it is not "/home/MountainView".
assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView")));
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/run-pass/use-nested-groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ mod a {
}
}

// Test every possible part of the syntax
use a::{B, d::{self, *, g::H}};

// Test a more common use case
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};

fn main() {
let _: B;
let _: E;
let _: F;
let _: H;
let _: d::g::I;

let _: Arc<AtomicBool>;
let _: Ordering;
}
16 changes: 16 additions & 0 deletions src/test/ui/cross-file-errors/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[macro_use]
mod underscore;

fn main() {
underscore!();
}
11 changes: 11 additions & 0 deletions src/test/ui/cross-file-errors/main.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: expected expression, found `_`
--> $DIR/underscore.rs:18:9
|
18 | _
| ^
|
::: $DIR/main.rs:15:5
|
15 | underscore!();
| -------------- in this macro invocation

20 changes: 20 additions & 0 deletions src/test/ui/cross-file-errors/underscore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// We want this file only so we can test cross-file error
// messages, but we don't want it in an external crate.
// ignore-test
#![crate_type = "lib"]

macro_rules! underscore {
() => (
_
)
}
10 changes: 5 additions & 5 deletions src/test/ui/macro_backtrace/main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
27 | ping!();
| -------- in this macro invocation
|
::: <ping macros>
::: <ping macros>:1:1
|
1 | ( ) => { pong ! ( ) ; }
| -------------------------
Expand All @@ -42,31 +42,31 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
28 | deep!();
| -------- in this macro invocation (#1)
|
::: <deep macros>
::: <deep macros>:1:1
|
1 | ( ) => { foo ! ( ) ; }
| ------------------------
| | |
| | in this macro invocation (#2)
| in this expansion of `deep!` (#1)
|
::: <foo macros>
::: <foo macros>:1:1
|
1 | ( ) => { bar ! ( ) ; }
| ------------------------
| | |
| | in this macro invocation (#3)
| in this expansion of `foo!` (#2)
|
::: <bar macros>
::: <bar macros>:1:1
|
1 | ( ) => { ping ! ( ) ; }
| -------------------------
| | |
| | in this macro invocation (#4)
| in this expansion of `bar!` (#3)
|
::: <ping macros>
::: <ping macros>:1:1
|
1 | ( ) => { pong ! ( ) ; }
| -------------------------
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/use-nested-groups-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(use_nested_groups)]

mod a {
pub mod b1 {
pub enum C2 {}
}

pub enum B2 {}
}

use a::{b1::{C1, C2}, B2};
//~^ ERROR unresolved import `a::b1::C1`

fn main() {
let _: C2;
let _: B2;
}
8 changes: 8 additions & 0 deletions src/test/ui/use-nested-groups-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error[E0432]: unresolved import `a::b1::C1`
--> $DIR/use-nested-groups-error.rs:21:14
|
21 | use a::{b1::{C1, C2}, B2};
| ^^ no `C1` in `a::b1`. Did you mean to use `C2`?

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ impl<'test> TestCx<'test> {
}

/// For each `aux-build: foo/bar` annotation, we check to find the
/// file in a `aux` directory relative to the test itself.
/// file in a `auxiliary` directory relative to the test itself.
fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths {
let test_ab = self.testpaths
.file
Expand Down