From e20f630f1caf7e95a725ed524109fc168a9e1345 Mon Sep 17 00:00:00 2001 From: BaoshanPang Date: Mon, 4 Nov 2019 15:15:49 -0800 Subject: [PATCH 01/17] pass the captured environment variables to rtpSpawn --- src/libstd/sys/vxworks/process/process_vxworks.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/vxworks/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs index 7446471ae3122..1ec318e07454a 100644 --- a/src/libstd/sys/vxworks/process/process_vxworks.rs +++ b/src/libstd/sys/vxworks/process/process_vxworks.rs @@ -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,10 +53,13 @@ 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 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. 0, // options From de362b41468f71ab7b1843007f97d4c1ca93638c Mon Sep 17 00:00:00 2001 From: BaoshanPang Date: Wed, 20 Nov 2019 14:24:59 -0800 Subject: [PATCH 02/17] ensure that access to the environment is synchronized --- src/libstd/sys/vxworks/os.rs | 19 ++++++++++++------- .../sys/vxworks/process/process_vxworks.rs | 8 ++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libstd/sys/vxworks/os.rs b/src/libstd/sys/vxworks/os.rs index baa6c425d2e7f..71e1d1626c1d0 100644 --- a/src/libstd/sys/vxworks/os.rs +++ b/src/libstd/sys/vxworks/os.rs @@ -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> { // 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(|_| ()) } } diff --git a/src/libstd/sys/vxworks/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs index 1ec318e07454a..79bfd770f8ed7 100644 --- a/src/libstd/sys/vxworks/process/process_vxworks.rs +++ b/src/libstd/sys/vxworks/process/process_vxworks.rs @@ -55,13 +55,17 @@ impl Command { 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 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 ); From 481b18acd09b480cc1ca50ea726cf91847f928f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Nov 2019 13:28:53 +0100 Subject: [PATCH 03/17] Small error codes explanation cleanup (E0092, E0093 and E0094) --- src/librustc_error_codes/error_codes/E0092.md | 7 ++++--- src/librustc_error_codes/error_codes/E0093.md | 8 +++++--- src/librustc_error_codes/error_codes/E0094.md | 3 ++- src/librustc_error_codes/error_codes/E0106.md | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0092.md b/src/librustc_error_codes/error_codes/E0092.md index 2750a7d45b48e..e289534bf7abd 100644 --- a/src/librustc_error_codes/error_codes/E0092.md +++ b/src/librustc_error_codes/error_codes/E0092.md @@ -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)] diff --git a/src/librustc_error_codes/error_codes/E0093.md b/src/librustc_error_codes/error_codes/E0093.md index 9633f794d8bb7..8e7de1a9d37b3 100644 --- a/src/librustc_error_codes/error_codes/E0093.md +++ b/src/librustc_error_codes/error_codes/E0093.md @@ -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)] diff --git a/src/librustc_error_codes/error_codes/E0094.md b/src/librustc_error_codes/error_codes/E0094.md index 4d27f616d2d84..42baa65bf9faf 100644 --- a/src/librustc_error_codes/error_codes/E0094.md +++ b/src/librustc_error_codes/error_codes/E0094.md @@ -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 diff --git a/src/librustc_error_codes/error_codes/E0106.md b/src/librustc_error_codes/error_codes/E0106.md index 8a49c1f79e475..60ca1ddc2830c 100644 --- a/src/librustc_error_codes/error_codes/E0106.md +++ b/src/librustc_error_codes/error_codes/E0106.md @@ -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 From b1ececa669cf6b1481281efb580f2384dfcddfd5 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 2 Dec 2019 11:49:38 -0800 Subject: [PATCH 04/17] [CI] fix the `! isCI` check in src/ci/run.sh Using `if [ ! isCI ] || ...` doesn't run any command, just tests `isCI` as a string, whereas `if ! isCI || ...` will actually run the `isCI` command and negate its exit status. --- src/ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/run.sh b/src/ci/run.sh index ae5b22493ab07..38d1d2baf2507 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -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 From 7693bb9e1d122bea1b0645dcc201c6ed79c910e2 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Mon, 2 Dec 2019 21:52:04 -0500 Subject: [PATCH 05/17] Add long error for E0631 and update ui tests. --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0631.md | 29 +++++++++++++++++++ .../anonymous-higher-ranked-lifetime.stderr | 1 + .../expect-fn-supply-fn.stderr | 3 +- .../expect-infer-var-appearing-twice.stderr | 1 + src/test/ui/closures/issue-41366.stderr | 3 +- src/test/ui/issues/issue-43623.stderr | 3 +- src/test/ui/issues/issue-60283.stderr | 3 +- src/test/ui/mismatched_types/E0631.stderr | 1 + .../closure-arg-type-mismatch.stderr | 3 +- .../mismatched_types/closure-mismatch.stderr | 3 +- .../ui/mismatched_types/fn-variance-1.stderr | 1 + .../ui/mismatched_types/issue-36053-2.stderr | 3 +- .../unboxed-closures-vtable-mismatch.stderr | 1 + 14 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 src/librustc_error_codes/error_codes/E0631.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 7f111b42403b5..9e4b704170b9b 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -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 diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md new file mode 100644 index 0000000000000..ad419f82250cc --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0631.md @@ -0,0 +1,29 @@ +This error indicates a type mismatch in closure arguments. + +Erroneous code example: + +```compile_fail,E0631 +fn test_strings(string_vec: Vec) -> Vec { + string_vec + .iter() + .map(|arg: &i32| arg.eq("Test String")) + .collect() +} +``` + +The closure passed to `map` expects a `&String` argument, since `some_vec` +has the type `Vec`. +However, the closure argument is annotated as an `&i32`, which does not match +the type of the iterable. + +This can be resolved by changing the type annotation or removing it entirely +if it can be inferred. + +``` +fn test_strings(string_vec: Vec) -> Vec { + string_vec + .iter() + .map(|arg| arg.eq("Test String")) + .collect() +} +``` diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 9be44c7f44807..c6d9a61bdd95a 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -121,3 +121,4 @@ LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), error: aborting due to 11 previous errors +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index a15444207f5cd..0033395846815 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -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`. diff --git a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index 9fbe95a9c3945..1c6564ee426e5 100644 --- a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -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`. diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr index 91d26efbc4f35..2f2871e9f0e90 100644 --- a/src/test/ui/closures/issue-41366.stderr +++ b/src/test/ui/closures/issue-41366.stderr @@ -19,4 +19,5 @@ LL | (&|_|()) as &dyn for<'x> Fn(>::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`. diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr index 2c57b8585d924..d90eb53f9006f 100644 --- a/src/test/ui/issues/issue-43623.stderr +++ b/src/test/ui/issues/issue-43623.stderr @@ -25,4 +25,5 @@ LL | break_me::; 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`. diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr index 69c1d85e4e12d..d13dcd54a479a 100644 --- a/src/test/ui/issues/issue-60283.stderr +++ b/src/test/ui/issues/issue-60283.stderr @@ -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`. diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 88c1efdbb90f4..06f5c058f81f5 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -46,3 +46,4 @@ LL | bar(f); error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 85cad61210ebf..ed5028247124f 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -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`. diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index fd2b9f3c66b04..f3874c0907be0 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -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`. diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 1a82dd53edc70..88c92661994cb 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -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`. diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index 72f3220cc1aba..da018aa89482c 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -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`. diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 2daf4781c7e6f..3c999f200d9c7 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -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`. From 26a1ba85b890cdf7bbb7066c3a18aab84aef171f Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Tue, 3 Dec 2019 07:51:11 -0500 Subject: [PATCH 06/17] Use simpler code example for E0631 long error. --- src/librustc_error_codes/error_codes/E0631.md | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md index ad419f82250cc..6188d5f61a7f9 100644 --- a/src/librustc_error_codes/error_codes/E0631.md +++ b/src/librustc_error_codes/error_codes/E0631.md @@ -3,27 +3,25 @@ This error indicates a type mismatch in closure arguments. Erroneous code example: ```compile_fail,E0631 -fn test_strings(string_vec: Vec) -> Vec { - string_vec - .iter() - .map(|arg: &i32| arg.eq("Test String")) - .collect() +fn foo(f: F) { +} + +fn main() { + foo(|x: &str| {}); } ``` -The closure passed to `map` expects a `&String` argument, since `some_vec` -has the type `Vec`. -However, the closure argument is annotated as an `&i32`, which does not match -the type of the iterable. +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 test_strings(string_vec: Vec) -> Vec { - string_vec - .iter() - .map(|arg| arg.eq("Test String")) - .collect() +fn foo(f: F) { +} + +fn main() { + foo(|x: i32| {}); } ``` From 3091b823d1080cfd2851f13b2eed5deed20d5f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 25 Nov 2019 18:31:27 -0800 Subject: [PATCH 07/17] Tweak wording of `collect()` on bad target type --- src/libcore/iter/traits/collect.rs | 4 ++-- src/test/ui/type/type-check-defaults.rs | 4 ++-- src/test/ui/type/type-check-defaults.stderr | 8 ++++---- src/test/ui/type/type-dependent-def-issue-49241.rs | 2 +- src/test/ui/type/type-dependent-def-issue-49241.stderr | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcore/iter/traits/collect.rs b/src/libcore/iter/traits/collect.rs index bbdb169cac0fc..d6ae5cfe9e00e 100644 --- a/src/libcore/iter/traits/collect.rs +++ b/src/libcore/iter/traits/collect.rs @@ -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`", + label="value of type `{Self}` cannot be built from `std::iter::Iterator`", )] pub trait FromIterator: Sized { /// Creates a value from an iterator. diff --git a/src/test/ui/type/type-check-defaults.rs b/src/test/ui/type/type-check-defaults.rs index 5748c9bcff8cb..5380fae5417e4 100644 --- a/src/test/ui/type/type-check-defaults.rs +++ b/src/test/ui/type/type-check-defaults.rs @@ -4,9 +4,9 @@ use std::ops::Add; struct Foo>(T, U); struct WellFormed>(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); -//~^ 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); //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index 6802bc38b89c9..6f84b37d61249 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -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); | ---------------------------------------- required by `Foo` LL | struct WellFormed>(Z); - | ^ a collection of type `i32` cannot be built from `std::iter::Iterator` + | ^ value of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `std::iter::FromIterator` 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); | ---------------------------------------- required by `Foo` ... LL | struct WellFormedNoBounds>(Z); - | ^ a collection of type `i32` cannot be built from `std::iter::Iterator` + | ^ value of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `std::iter::FromIterator` is not implemented for `i32` diff --git a/src/test/ui/type/type-dependent-def-issue-49241.rs b/src/test/ui/type/type-dependent-def-issue-49241.rs index 5ad50ffcbc389..a25e3ba5fa89f 100644 --- a/src/test/ui/type/type-dependent-def-issue-49241.rs +++ b/src/test/ui/type/type-dependent-def-issue-49241.rs @@ -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 } diff --git a/src/test/ui/type/type-dependent-def-issue-49241.stderr b/src/test/ui/type/type-dependent-def-issue-49241.stderr index 851004d105897..18a69c50ebd6d 100644 --- a/src/test/ui/type/type-dependent-def-issue-49241.stderr +++ b/src/test/ui/type/type-dependent-def-issue-49241.stderr @@ -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` + | ^^^^^^^ value of type `[u32; _]` cannot be built from `std::iter::Iterator` | = help: the trait `std::iter::FromIterator<{integer}>` is not implemented for `[u32; _]` From 79849eed5d5617a181be89531a2abd9db4d74c84 Mon Sep 17 00:00:00 2001 From: BaoshanPang Date: Tue, 3 Dec 2019 10:16:45 -0800 Subject: [PATCH 08/17] add ExitStatusExt into prelude --- src/libstd/sys/vxworks/ext/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libstd/sys/vxworks/ext/mod.rs b/src/libstd/sys/vxworks/ext/mod.rs index 251a198f821d6..8fa9bd9d1e27f 100644 --- a/src/libstd/sys/vxworks/ext/mod.rs +++ b/src/libstd/sys/vxworks/ext/mod.rs @@ -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; } From 911b7d6d4dc19da085883d19b7a772b5ca35ffc9 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Tue, 3 Dec 2019 14:58:41 -0500 Subject: [PATCH 09/17] Update missed test. --- src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr index a6b52b258f005..7141c047d7f53 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -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`. From c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Nov 2019 13:42:50 +0100 Subject: [PATCH 10/17] clean up E0107 error explanation --- src/librustc_error_codes/error_codes/E0107.md | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0107.md b/src/librustc_error_codes/error_codes/E0107.md index bfe0d21f3129b..4d22b17fe1016 100644 --- a/src/librustc_error_codes/error_codes/E0107.md +++ b/src/librustc_error_codes/error_codes/E0107.md @@ -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 { x: T } @@ -9,6 +11,7 @@ struct Baz { x: Foo } // error: wrong number of type arguments: // expected 1, found 2 fn foo(x: T, y: U) {} +fn f() {} fn main() { let x: bool = true; @@ -16,12 +19,26 @@ fn main() { // expected 2, found 1 foo::(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 { x: T } + +struct Bar { x: Foo } // ok! +struct Baz { x: Foo, y: Foo } // ok! +fn foo(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::(x, 12); // ok! + f(); // ok! } ``` From c2ce7dd756c36cb619c7f231ab6596d6b180afed Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Dec 2019 13:27:17 +0100 Subject: [PATCH 11/17] Clean up E0116 error code long explanation --- src/librustc_error_codes/error_codes/E0116.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0116.md b/src/librustc_error_codes/error_codes/E0116.md index 27759a423433f..ca849c2a128f4 100644 --- a/src/librustc_error_codes/error_codes/E0116.md +++ b/src/librustc_error_codes/error_codes/E0116.md @@ -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 { } // 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 From 1e5450d4cb7bb951bbdb9bc2b09a984b132c4280 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Dec 2019 13:31:40 +0100 Subject: [PATCH 12/17] Clean up E0117 error code long explanation --- src/librustc_error_codes/error_codes/E0117.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0117.md b/src/librustc_error_codes/error_codes/E0117.md index bd36230566262..7fa211d4a27d4 100644 --- a/src/librustc_error_codes/error_codes/E0117.md +++ b/src/librustc_error_codes/error_codes/E0117.md @@ -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`: From 9eaea4d3ea1ae6d6858af1a83a7d44c759a31212 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Dec 2019 13:35:26 +0100 Subject: [PATCH 13/17] Clean up E0118 error code long explanation --- src/librustc_error_codes/error_codes/E0118.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0118.md b/src/librustc_error_codes/error_codes/E0118.md index baf35ffbb0b53..5cb5f506e0a4b 100644 --- a/src/librustc_error_codes/error_codes/E0118.md +++ b/src/librustc_error_codes/error_codes/E0118.md @@ -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 From ae753a55ac8b16772ad7617c8512433921271abc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Dec 2019 13:36:50 +0100 Subject: [PATCH 14/17] some error codes long explanation --- src/librustc_error_codes/error_codes/E0109.md | 1 + src/librustc_error_codes/error_codes/E0119.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0109.md b/src/librustc_error_codes/error_codes/E0109.md index 5bc229ade52f4..2eab9725a6f59 100644 --- a/src/librustc_error_codes/error_codes/E0109.md +++ b/src/librustc_error_codes/error_codes/E0109.md @@ -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 diff --git a/src/librustc_error_codes/error_codes/E0119.md b/src/librustc_error_codes/error_codes/E0119.md index 0af3bd4a0de79..e596349e5e2d1 100644 --- a/src/librustc_error_codes/error_codes/E0119.md +++ b/src/librustc_error_codes/error_codes/E0119.md @@ -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 { From 8be7223145c486f398863ddb55d115bf91651f59 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Wed, 4 Dec 2019 15:13:43 +0200 Subject: [PATCH 15/17] Fix docs for formatting delegations --- src/libcore/fmt/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 4c941e2dfe6de..e2f49ee25a756 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -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) /// } /// } /// From f7789ad5b23f0bb526f0cebdfc606374882d6feb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 5 Dec 2019 11:01:26 -0800 Subject: [PATCH 16/17] Fix fetching arguments on the wasm32-wasi target Fixes an error introduced in #66750 where wasi executables always think they have zero arguments because one of the vectors returned here accidentally thought it was length 0. --- src/libstd/sys/wasi/args.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/sys/wasi/args.rs b/src/libstd/sys/wasi/args.rs index 3db36f5e13251..02aa68d6f3ab7 100644 --- a/src/libstd/sys/wasi/args.rs +++ b/src/libstd/sys/wasi/args.rs @@ -26,6 +26,7 @@ fn maybe_args() -> Option> { 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()); From db7b0f88f18a9486dbb900503ce8191a1f48a2e1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 5 Dec 2019 11:36:35 -0800 Subject: [PATCH 17/17] Update the revision of wasi-libc used in wasm32-wasi This commit updates the `wasi-libc` repository used to build the wasm32-wasi target's libstd to ensure that both libstd and libc are using the same wasi snapshot version. --- src/ci/docker/dist-various-2/build-wasi-toolchain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh index 17aa78945cf21..925d5ca0223b1 100755 --- a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh @@ -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 ..