Auto merge of #67080 - JohnTitor:rollup-2t6fm3u, r=JohnTitor

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
This commit is contained in:
bors 2019-12-06 07:43:56 +00:00
commit d0126e8ed3
37 changed files with 148 additions and 59 deletions

View File

@ -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 ..

View File

@ -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

View File

@ -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
/// }
/// }
///
@ -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
/// }
/// }
///
@ -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
/// }
/// }
///
@ -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
/// }
/// }
///
@ -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)
/// }
/// }
///

View File

@ -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.

View File

@ -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"),
@ -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

View File

@ -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
@ -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)]

View File

@ -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)]
@ -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)]

View File

@ -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

View File

@ -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 }
@ -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

View File

@ -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 }
@ -9,6 +11,7 @@ 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;
@ -16,12 +19,26 @@ fn main() {
// 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!
}
```

View File

@ -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

View File

@ -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

View File

@ -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
@ -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`:

View File

@ -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

View File

@ -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 {

View File

@ -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| {});
}
```

View File

@ -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;
}

View File

@ -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;
@ -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: {}",
@ -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
@ -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(|_| ())
}
}
@ -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(|_| ())
}
}

View File

@ -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,
@ -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
);

View File

@ -26,6 +26,7 @@ fn maybe_args() -> Option<Vec<OsString>> {
let mut argv = Vec::with_capacity(argc);
let mut buf = Vec::with_capacity(buf_size);
wasi::args_get(argv.as_mut_ptr(), buf.as_mut_ptr()).ok()?;
argv.set_len(argc);
let mut ret = Vec::with_capacity(argc);
for ptr in argv {
let s = CStr::from_ptr(ptr.cast());

View File

@ -121,3 +121,4 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(),
error: aborting due to 11 previous errors
For more information about this error, try `rustc --explain E0631`.

View File

@ -39,3 +39,4 @@ LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0631`.

View File

@ -77,4 +77,5 @@ LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0308, E0631.
For more information about an error, try `rustc --explain E0308`.

View File

@ -13,3 +13,4 @@ LL | with_closure(|x: u32, y: i32| {
error: aborting due to previous error
For more information about this error, try `rustc --explain E0631`.

View File

@ -19,4 +19,5 @@ LL | (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.

View File

@ -25,4 +25,5 @@ LL | break_me::<Type, fn(_)>;
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.

View File

@ -27,4 +27,5 @@ LL | foo((), drop)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.

View File

@ -46,3 +46,4 @@ LL | bar(f);
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0631`.

View File

@ -45,4 +45,5 @@ LL | baz(f);
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.

View File

@ -24,4 +24,5 @@ LL | baz(|_| ());
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0631.
For more information about an error, try `rustc --explain E0271`.

View File

@ -24,3 +24,4 @@ LL | apply(&mut 3, takes_imm);
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0631`.

View File

@ -18,4 +18,5 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.
Some errors have detailed explanations: E0599, E0631.
For more information about an error, try `rustc --explain E0599`.

View File

@ -12,3 +12,4 @@ LL | let z = call_it(3, f);
error: aborting due to previous error
For more information about this error, try `rustc --explain E0631`.

View File

@ -4,9 +4,9 @@ use std::ops::Add;
struct Foo<T, U: FromIterator<T>>(T, U);
struct WellFormed<Z = Foo<i32, i32>>(Z);
//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`
struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`
struct Bounds<T:Copy=String>(T);
//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277]

View File

@ -1,21 +1,21 @@
error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
--> $DIR/type-check-defaults.rs:6:19
|
LL | struct Foo<T, U: FromIterator<T>>(T, U);
| ---------------------------------------- required by `Foo`
LL | struct WellFormed<Z = Foo<i32, i32>>(Z);
| ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
| ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`
error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
--> $DIR/type-check-defaults.rs:8:27
|
LL | struct Foo<T, U: FromIterator<T>>(T, U);
| ---------------------------------------- required by `Foo`
...
LL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
| ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
| ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`

View File

@ -3,5 +3,5 @@ fn main() {
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
let s: [u32; l] = v.into_iter().collect();
//~^ ERROR evaluation of constant value failed
//~^^ ERROR a collection of type
//~^^ ERROR a value of type
}

View File

@ -10,11 +10,11 @@ error[E0080]: evaluation of constant value failed
LL | let s: [u32; l] = v.into_iter().collect();
| ^ referenced constant has errors
error[E0277]: a collection of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
error[E0277]: a value of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
--> $DIR/type-dependent-def-issue-49241.rs:4:37
|
LL | let s: [u32; l] = v.into_iter().collect();
| ^^^^^^^ a collection of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
| ^^^^^^^ value of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
|
= help: the trait `std::iter::FromIterator<{integer}>` is not implemented for `[u32; _]`