Skip to content

Commit

Permalink
Auto merge of #67080 - JohnTitor:rollup-2t6fm3u, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #66649 (VxWorks: fix issues in accessing environment variables)
 - #66764 (Tweak wording of `collect()` on bad target type)
 - #66900 (Clean up error codes)
 - #66974 ([CI] fix the `! isCI` check in src/ci/run.sh)
 - #66979 (Add long error for E0631 and update ui tests.)
 - #67017 (cleanup long error explanations)
 - #67021 (Fix docs for formatting delegations)
 - #67041 (add ExitStatusExt into prelude)
 - #67065 (Fix fetching arguments on the wasm32-wasi target)
 - #67066 (Update the revision of wasi-libc used in wasm32-wasi)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 6, 2019
2 parents 7b482cd + acd2b08 commit d0126e8
Show file tree
Hide file tree
Showing 37 changed files with 148 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/ci/docker/dist-various-2/build-wasi-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
git clone https://github.com/CraneStation/wasi-libc

cd wasi-libc
git reset --hard a94d2d04e7722b323573da2bd04e909a5763d35b
git reset --hard f645f498dfbbbc00a7a97874d33082d3605c3f21
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install

cd ..
Expand Down
2 changes: 1 addition & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi
ci_dir=`cd $(dirname $0) && pwd`
source "$ci_dir/shared.sh"

if [ ! isCI ] || isCiBranch auto || isCiBranch beta; then
if ! isCI || isCiBranch auto || isCiBranch beta; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests"
fi

Expand Down
11 changes: 6 additions & 5 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ pub trait Display {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:o}", val) // delegate to i32's implementation
/// fmt::Octal::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -712,7 +712,7 @@ pub trait Octal {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:b}", val) // delegate to i32's implementation
/// fmt::Binary::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -771,7 +771,7 @@ pub trait Binary {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:x}", val) // delegate to i32's implementation
/// fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -824,7 +824,7 @@ pub trait LowerHex {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:X}", val) // delegate to i32's implementation
/// fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -869,7 +869,8 @@ pub trait UpperHex {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// // use `as` to convert to a `*const T`, which implements Pointer, which we can use
///
/// write!(f, "{:p}", self as *const Length)
/// let ptr = self as *const Self;
/// fmt::Pointer::fmt(&ptr, f)
/// }
/// }
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(
message="a collection of type `{Self}` cannot be built from an iterator \
message="a value of type `{Self}` cannot be built from an iterator \
over elements of type `{A}`",
label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
label="value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
)]
pub trait FromIterator<A>: Sized {
/// Creates a value from an iterator.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0631: include_str!("./error_codes/E0631.md"),
E0633: include_str!("./error_codes/E0633.md"),
E0635: include_str!("./error_codes/E0635.md"),
E0636: include_str!("./error_codes/E0636.md"),
Expand Down Expand Up @@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"),
// rustc_const_unstable attribute must be paired with stable/unstable
// attribute
E0630,
E0631, // type mismatch in closure arguments
E0632, // cannot provide explicit generic arguments when `impl Trait` is
// used in argument position
E0634, // type has conflicting packed representaton hints
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_error_codes/error_codes/E0092.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You tried to declare an undefined atomic operation function.
An undefined atomic operation function was declared.

Erroneous code example:

```compile_fail,E0092
Expand All @@ -11,8 +12,8 @@ extern "rust-intrinsic" {
```

Please check you didn't make a mistake in the function's name. All intrinsic
functions are defined in librustc_codegen_llvm/intrinsic.rs and in
libcore/intrinsics.rs in the Rust source code. Example:
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
`libcore/intrinsics.rs` in the Rust source code. Example:

```
#![feature(intrinsics)]
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_error_codes/error_codes/E0093.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
You declared an unknown intrinsic function. Erroneous code example:
An unknown intrinsic function was declared.

Erroneous code example:

```compile_fail,E0093
#![feature(intrinsics)]
Expand All @@ -15,8 +17,8 @@ fn main() {
```

Please check you didn't make a mistake in the function's name. All intrinsic
functions are defined in librustc_codegen_llvm/intrinsic.rs and in
libcore/intrinsics.rs in the Rust source code. Example:
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
`libcore/intrinsics.rs` in the Rust source code. Example:

```
#![feature(intrinsics)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0094.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You gave an invalid number of type parameters to an intrinsic function.
An invalid number of type parameters was given to an intrinsic function.

Erroneous code example:

```compile_fail,E0094
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0106.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This error indicates that a lifetime is missing from a type. If it is an error
inside a function signature, the problem may be with failing to adhere to the
lifetime elision rules (see below).

Here are some simple examples of where you'll run into this error:
Erroneous code examples:

```compile_fail,E0106
struct Foo1 { x: &bool }
Expand All @@ -27,7 +27,7 @@ function signatures which allows you to leave out lifetimes in certain cases.
For more background on lifetime elision see [the book][book-le].

The lifetime elision rules require that any function signature with an elided
output lifetime must either have
output lifetime must either have:

- exactly one input lifetime
- or, multiple input lifetimes, but the function must also be a method with a
Expand Down
23 changes: 20 additions & 3 deletions src/librustc_error_codes/error_codes/E0107.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
This error means that an incorrect number of generic arguments were provided:
An incorrect number of generic arguments were provided.

Erroneous code example:

```compile_fail,E0107
struct Foo<T> { x: T }
Expand All @@ -9,19 +11,34 @@ struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:
// expected 1, found 2
fn foo<T, U>(x: T, y: U) {}
fn f() {}
fn main() {
let x: bool = true;
foo::<bool>(x); // error: wrong number of type arguments:
// expected 2, found 1
foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:
// expected 2, found 3
f::<'static>(); // error: wrong number of lifetime arguments
// expected 0, found 1
}
```

When using/declaring an item with generic arguments, you must provide the exact
same number:

```
struct Foo<T> { x: T }
struct Bar<T> { x: Foo<T> } // ok!
struct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok!
fn foo<T, U>(x: T, y: U) {}
fn f() {}
fn main() {
f::<'static>(); // error: wrong number of lifetime arguments:
// expected 0, found 1
let x: bool = true;
foo::<bool, u32>(x, 12); // ok!
f(); // ok!
}
```
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes/E0109.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You tried to provide a generic argument to a type which doesn't need it.

Erroneous code example:

```compile_fail,E0109
Expand Down
10 changes: 7 additions & 3 deletions src/librustc_error_codes/error_codes/E0116.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
You can only define an inherent implementation for a type in the same crate
where the type was defined. For example, an `impl` block as below is not allowed
since `Vec` is defined in the standard library:
An inherent implementation was defined for a type outside the current crate.

Erroneous code example:

```compile_fail,E0116
impl Vec<u8> { } // error
```

You can only define an inherent implementation for a type in the same crate
where the type was defined. For example, an `impl` block as above is not allowed
since `Vec` is defined in the standard library.

To fix this problem, you can do either of these things:

- define a trait that has the desired associated functions/types/constants and
Expand Down
14 changes: 8 additions & 6 deletions src/librustc_error_codes/error_codes/E0117.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
The `Drop` trait was implemented on a non-struct type.

Erroneous code example:

```compile_fail,E0117
impl Drop for u32 {}
```

This error indicates a violation of one of Rust's orphan rules for trait
implementations. The rule prohibits any implementation of a foreign trait (a
trait defined in another crate) where
Expand All @@ -6,12 +14,6 @@ trait defined in another crate) where
- all of the parameters being passed to the trait (if there are any) are also
foreign.

Here's one example of this error:

```compile_fail,E0117
impl Drop for u32 {}
```

To avoid this kind of error, ensure that at least one local type is referenced
by the `impl`:

Expand Down
6 changes: 4 additions & 2 deletions src/librustc_error_codes/error_codes/E0118.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
You're trying to write an inherent implementation for something which isn't a
struct nor an enum. Erroneous code example:
An inherent implementation was defined for something which isn't a struct nor
an enum.

Erroneous code example:

```compile_fail,E0118
impl (u8, u8) { // error: no base type found for inherent implementation
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0119.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
There are conflicting trait implementations for the same type.
Example of erroneous code:

Erroneous code example:

```compile_fail,E0119
trait MyTrait {
Expand Down
27 changes: 27 additions & 0 deletions src/librustc_error_codes/error_codes/E0631.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This error indicates a type mismatch in closure arguments.

Erroneous code example:

```compile_fail,E0631
fn foo<F: Fn(i32)>(f: F) {
}
fn main() {
foo(|x: &str| {});
}
```

The error occurs because `foo` accepts a closure that takes an `i32` argument,
but in `main`, it is passed a closure with a `&str` argument.

This can be resolved by changing the type annotation or removing it entirely
if it can be inferred.

```
fn foo<F: Fn(i32)>(f: F) {
}
fn main() {
foo(|x: i32| {});
}
```
3 changes: 3 additions & 0 deletions src/libstd/sys/vxworks/ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ pub mod prelude {
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::process::ExitStatusExt;
}
19 changes: 12 additions & 7 deletions src/libstd/sys/vxworks/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ use crate::path::{self, PathBuf, Path};
use crate::ptr;
use crate::slice;
use crate::str;
use crate::sys_common::mutex::Mutex;
use crate::sys_common::mutex::{Mutex, MutexGuard};
use crate::sys::cvt;
/*use sys::fd; this one is probably important */
use crate::vec;

const TMPBUF_SZ: usize = 128;
static ENV_LOCK: Mutex = Mutex::new();


// This is a terrible fix
use crate::sys::os_str::Buf;
Expand Down Expand Up @@ -200,11 +198,18 @@ pub unsafe fn environ() -> *mut *const *const c_char {
&mut environ
}

pub unsafe fn env_lock() -> MutexGuard<'static> {
// We never call `ENV_LOCK.init()`, so it is UB to attempt to
// acquire this mutex reentrantly!
static ENV_LOCK: Mutex = Mutex::new();
ENV_LOCK.lock()
}

/// Returns a vector of (variable, value) byte-vector pairs for all the
/// environment variables of the current process.
pub fn env() -> Env {
unsafe {
let _guard = ENV_LOCK.lock();
let _guard = env_lock();
let mut environ = *environ();
if environ == ptr::null() {
panic!("os::env() failure getting env string from OS: {}",
Expand Down Expand Up @@ -244,7 +249,7 @@ pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
// always None as well
let k = CString::new(k.as_bytes())?;
unsafe {
let _guard = ENV_LOCK.lock();
let _guard = env_lock();
let s = libc::getenv(k.as_ptr()) as *const libc::c_char;
let ret = if s.is_null() {
None
Expand All @@ -260,7 +265,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
let v = CString::new(v.as_bytes())?;

unsafe {
let _guard = ENV_LOCK.lock();
let _guard = env_lock();
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ())
}
}
Expand All @@ -269,7 +274,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {
let nbuf = CString::new(n.as_bytes())?;

unsafe {
let _guard = ENV_LOCK.lock();
let _guard = env_lock();
cvt(libc::unsetenv(nbuf.as_ptr())).map(|_| ())
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/libstd/sys/vxworks/process/process_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl Command {
-> io::Result<(Process, StdioPipes)> {
use crate::sys::{cvt_r};
const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX";
let envp = self.capture_env();

if self.saw_nul() {
return Err(io::Error::new(ErrorKind::InvalidInput,
Expand Down Expand Up @@ -52,12 +53,19 @@ impl Command {
t!(cvt(libc::chdir(cwd.as_ptr())));
}

let c_envp = envp.as_ref().map(|c| c.as_ptr())
.unwrap_or_else(|| *sys::os::environ() as *const _);
let stack_size = thread::min_stack();

// ensure that access to the environment is synchronized
let _lock = sys::os::env_lock();

let ret = libc::rtpSpawn(
self.get_argv()[0], // executing program
self.get_argv().as_ptr() as *mut *const c_char, // argv
*sys::os::environ() as *mut *const c_char,
c_envp as *mut *const c_char,
100 as c_int, // initial priority
thread::min_stack(), // initial stack size.
stack_size, // initial stack size.
0, // options
0 // task options
);
Expand Down
Loading

0 comments on commit d0126e8

Please sign in to comment.