From 6590339c31ab934add15ec49bc474ba9d78435e2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 Jan 2020 13:33:48 +0100 Subject: [PATCH 01/12] Clean up E0205 explanation --- src/librustc_error_codes/error_codes/E0206.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0206.md b/src/librustc_error_codes/error_codes/E0206.md index fc4c0e07a16bf..da53b671ad0cc 100644 --- a/src/librustc_error_codes/error_codes/E0206.md +++ b/src/librustc_error_codes/error_codes/E0206.md @@ -1,12 +1,18 @@ -You can only implement `Copy` for a struct or enum. Both of the following -examples will fail, because neither `[u8; 256]` nor `&'static mut Bar` -(mutable reference to `Bar`) is a struct or enum: +The `Copy` trait was implemented on a type which is neither a struct nor an +enum. + +Erroneous code example: ```compile_fail,E0206 type Foo = [u8; 256]; -impl Copy for Foo { } // error +impl Copy for Foo { } // error! #[derive(Copy, Clone)] struct Bar; -impl Copy for &'static mut Bar { } // error + +impl Copy for &'static mut Bar { } // error! ``` + +You can only implement `Copy` for a struct or an enum. Both of the previous +examples will fail, because neither `[u8; 256]` nor `&'static mut Bar` +(mutable reference to `Bar`) is a struct or enum. From 94fcda0e1346f284c44a27c5c07c2b0999e5bc29 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Jan 2020 14:25:35 +0100 Subject: [PATCH 02/12] clean up E0214 explanation --- src/librustc_error_codes/error_codes/E0214.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0214.md b/src/librustc_error_codes/error_codes/E0214.md index f78c1c0cd0137..b64ee80e284d5 100644 --- a/src/librustc_error_codes/error_codes/E0214.md +++ b/src/librustc_error_codes/error_codes/E0214.md @@ -1,12 +1,17 @@ A generic type was described using parentheses rather than angle brackets. -For example: + +Erroneous code example: ```compile_fail,E0214 -fn main() { - let v: Vec(&str) = vec!["foo"]; -} +let v: Vec(&str) = vec!["foo"]; ``` This is not currently supported: `v` should be defined as `Vec<&str>`. Parentheses are currently only used with generic types when defining parameters for `Fn`-family traits. + +The previous code example fixed: + +``` +let v: Vec<&str> = vec!["foo"]; +``` From 3850d96379126087240b640470632362a5d32234 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Jan 2020 13:29:15 +0100 Subject: [PATCH 03/12] clean up error codes explanation --- src/librustc_error_codes/error_codes/E0220.md | 3 ++- src/librustc_error_codes/error_codes/E0221.md | 3 ++- src/librustc_error_codes/error_codes/E0222.md | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0220.md b/src/librustc_error_codes/error_codes/E0220.md index 43e075b522b4e..4ab52b642d500 100644 --- a/src/librustc_error_codes/error_codes/E0220.md +++ b/src/librustc_error_codes/error_codes/E0220.md @@ -1,4 +1,5 @@ -You used an associated type which isn't defined in the trait. +A used associated type wasn't defined in the trait. + Erroneous code example: ```compile_fail,E0220 diff --git a/src/librustc_error_codes/error_codes/E0221.md b/src/librustc_error_codes/error_codes/E0221.md index 53fabf490e2c3..26111ca429333 100644 --- a/src/librustc_error_codes/error_codes/E0221.md +++ b/src/librustc_error_codes/error_codes/E0221.md @@ -1,5 +1,6 @@ An attempt was made to retrieve an associated type, but the type was ambiguous. -For example: + +Erroneous code example: ```compile_fail,E0221 trait T1 {} diff --git a/src/librustc_error_codes/error_codes/E0222.md b/src/librustc_error_codes/error_codes/E0222.md index 66b6c4d712b70..fbf1b8d703314 100644 --- a/src/librustc_error_codes/error_codes/E0222.md +++ b/src/librustc_error_codes/error_codes/E0222.md @@ -1,5 +1,6 @@ An attempt was made to constrain an associated type. -For example: + +Erroneous code example: ```compile_fail,E0222 pub trait Vehicle { From 0f5ed4d2cdc3678cdd3a5c2dceb85a0ac8564f87 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 21 Jan 2020 13:53:39 +0100 Subject: [PATCH 04/12] Clean up E0207 explanation --- src/librustc_error_codes/error_codes/E0207.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0207.md b/src/librustc_error_codes/error_codes/E0207.md index 67b2063504c07..21e7e461c753b 100644 --- a/src/librustc_error_codes/error_codes/E0207.md +++ b/src/librustc_error_codes/error_codes/E0207.md @@ -1,3 +1,19 @@ +A type or lifetime parameter that is specified for `impl` is not constrained. + +Erroneous code example: + +```compile_fail,E0207 +struct Foo; + +impl Foo { + // error: the type parameter `T` is not constrained by the impl trait, self + // type, or predicates [E0207] + fn get(&self) -> T { + ::default() + } +} +``` + Any type parameter or lifetime parameter of an `impl` must meet at least one of the following criteria: @@ -10,19 +26,7 @@ the following criteria: ### Error example 1 Suppose we have a struct `Foo` and we would like to define some methods for it. -The following definition leads to a compiler error: - -```compile_fail,E0207 -struct Foo; - -impl Foo { -// error: the type parameter `T` is not constrained by the impl trait, self -// type, or predicates [E0207] - fn get(&self) -> T { - ::default() - } -} -``` +The previous code example has a definition which leads to a compiler error: The problem is that the parameter `T` does not appear in the implementing type (`Foo`) of the impl. In this case, we can fix the error by moving the type From 9ad1a8c97f8ee0c6af75bca7fae41f7c37d3e73c Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 27 Jan 2020 00:49:56 -0500 Subject: [PATCH 05/12] Don't call `tcx.fn_sig` on closures Fixes #68542 --- src/librustc_mir/const_eval/fn_queries.rs | 4 ++++ .../consts/issue-68542-closure-in-array-len.rs | 10 ++++++++++ .../issue-68542-closure-in-array-len.stderr | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/test/ui/consts/issue-68542-closure-in-array-len.rs create mode 100644 src/test/ui/consts/issue-68542-closure-in-array-len.stderr diff --git a/src/librustc_mir/const_eval/fn_queries.rs b/src/librustc_mir/const_eval/fn_queries.rs index 2443e1e91d378..5eeb92f583b98 100644 --- a/src/librustc_mir/const_eval/fn_queries.rs +++ b/src/librustc_mir/const_eval/fn_queries.rs @@ -86,6 +86,10 @@ pub fn provide(providers: &mut Providers<'_>) { /// Const evaluability whitelist is here to check evaluability at the /// top level beforehand. fn is_const_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> Option { + if tcx.is_closure(def_id) { + return None; + } + match tcx.fn_sig(def_id).abi() { Abi::RustIntrinsic | Abi::PlatformIntrinsic => { Some(tcx.lookup_const_stability(def_id).is_some()) diff --git a/src/test/ui/consts/issue-68542-closure-in-array-len.rs b/src/test/ui/consts/issue-68542-closure-in-array-len.rs new file mode 100644 index 0000000000000..2e721b8533413 --- /dev/null +++ b/src/test/ui/consts/issue-68542-closure-in-array-len.rs @@ -0,0 +1,10 @@ +// Regression test for issue #68542 +// Tests that we don't ICE when a closure appears +// in the length part of an array. + +struct Bug { + a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to + //~^ ERROR evaluation of constant value failed +} + +fn main() {} diff --git a/src/test/ui/consts/issue-68542-closure-in-array-len.stderr b/src/test/ui/consts/issue-68542-closure-in-array-len.stderr new file mode 100644 index 0000000000000..815cc9d836f92 --- /dev/null +++ b/src/test/ui/consts/issue-68542-closure-in-array-len.stderr @@ -0,0 +1,16 @@ +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-68542-closure-in-array-len.rs:6:13 + | +LL | a: [(); (|| { 0 })()] + | ^^^^^^^^^^^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/issue-68542-closure-in-array-len.rs:6:13 + | +LL | a: [(); (|| { 0 })()] + | ^^^^^^^^^^^^ calling non-const function `Bug::a::{{constant}}#0::{{closure}}#0` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0015, E0080. +For more information about an error, try `rustc --explain E0015`. From 833ffd7b839caa843f51bfa992baea89fe4fd2fb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Jan 2020 16:06:38 +0100 Subject: [PATCH 06/12] Update src/librustc_error_codes/error_codes/E0220.md Co-Authored-By: Dylan DPC --- src/librustc_error_codes/error_codes/E0220.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0220.md b/src/librustc_error_codes/error_codes/E0220.md index 4ab52b642d500..ddc54007c8c52 100644 --- a/src/librustc_error_codes/error_codes/E0220.md +++ b/src/librustc_error_codes/error_codes/E0220.md @@ -1,4 +1,4 @@ -A used associated type wasn't defined in the trait. +The associated type used was not defined in the trait. Erroneous code example: From b0174ecf346830cedc038daa596672376219086b Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Mon, 27 Jan 2020 09:05:31 -0500 Subject: [PATCH 07/12] Fix LLVM assertion failure in MSP430 interrupt generation. --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index a56b846ec7c96..d7cdb4359223b 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit a56b846ec7c96d8dc86418819baee40d70c92974 +Subproject commit d7cdb4359223be265da34ebeaa00b92b7c5419fd From de7f16d4313791a51b28822cbf08e8fbcaf78bde Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 23 Jan 2020 03:30:56 +0100 Subject: [PATCH 08/12] check_match: extract common logic --- src/librustc_mir_build/hair/pattern/_match.rs | 2 +- src/librustc_mir_build/hair/pattern/check_match.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index a2ce224904b29..08ed6b521b502 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -586,7 +586,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, module: DefId, - f: impl for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R, + f: impl FnOnce(MatchCheckCtxt<'_, 'tcx>) -> R, ) -> R { let pattern_arena = TypedArena::default(); diff --git a/src/librustc_mir_build/hair/pattern/check_match.rs b/src/librustc_mir_build/hair/pattern/check_match.rs index 49b7c2d41fcbb..82822f0c471a4 100644 --- a/src/librustc_mir_build/hair/pattern/check_match.rs +++ b/src/librustc_mir_build/hair/pattern/check_match.rs @@ -140,6 +140,11 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { (pattern, pattern_ty) } + fn check_in_cx(&self, hir_id: HirId, f: impl FnOnce(MatchCheckCtxt<'_, 'tcx>)) { + let module = self.tcx.hir().get_module_parent(hir_id); + MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |cx| f(cx)); + } + fn check_match( &mut self, scrut: &hir::Expr<'_>, @@ -151,8 +156,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { self.check_patterns(arm.guard.is_some(), &arm.pat); } - let module = self.tcx.hir().get_module_parent(scrut.hir_id); - MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { + self.check_in_cx(scrut.hir_id, |ref mut cx| { let mut have_errors = false; let inlined_arms: Vec<_> = arms @@ -180,8 +184,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { } fn check_irrefutable(&self, pat: &'tcx Pat<'tcx>, origin: &str, sp: Option) { - let module = self.tcx.hir().get_module_parent(pat.hir_id); - MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { + self.check_in_cx(pat.hir_id, |ref mut cx| { let (pattern, pattern_ty) = self.lower_pattern(cx, pat, &mut false); let pats: Matrix<'_, '_> = vec![PatStack::from_pattern(pattern)].into_iter().collect(); From 4b0fe2ac63b983425c82a45cdb930019f36409bf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Jan 2020 17:43:02 +0100 Subject: [PATCH 09/12] Clean up E0262 explanation --- src/librustc_error_codes/error_codes/E0262.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0262.md b/src/librustc_error_codes/error_codes/E0262.md index 2dca6b1bb0781..67419d53ef9d1 100644 --- a/src/librustc_error_codes/error_codes/E0262.md +++ b/src/librustc_error_codes/error_codes/E0262.md @@ -1,8 +1,12 @@ -Declaring certain lifetime names in parameters is disallowed. For example, -because the `'static` lifetime is a special built-in lifetime name denoting -the lifetime of the entire program, this is an error: +An invalid name was used for a lifetime parameter. + +Erroneous code example: ```compile_fail,E0262 // error, invalid lifetime parameter name `'static` fn foo<'static>(x: &'static str) { } ``` + +Declaring certain lifetime names in parameters is disallowed. For example, +because the `'static` lifetime is a special built-in lifetime name denoting +the lifetime of the entire program, this is an error: From 2a38eb3a86cd8f2679e046ca08c1102638ad316d Mon Sep 17 00:00:00 2001 From: Umesh Kalappa Date: Mon, 6 Jan 2020 00:53:23 -0800 Subject: [PATCH 10/12] Disable the testcase for Vxworks. --- src/test/ui/env-funky-keys.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/env-funky-keys.rs b/src/test/ui/env-funky-keys.rs index 4faceb53266c7..c5c824ac58d30 100644 --- a/src/test/ui/env-funky-keys.rs +++ b/src/test/ui/env-funky-keys.rs @@ -6,6 +6,7 @@ // ignore-cloudabi no execve // ignore-emscripten no execve // ignore-sgx no execve +// ignore-vxworks no execve // no-prefer-dynamic #![feature(rustc_private)] From 3124603f0948fd5e2a1dc88908436d508846b7c6 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 27 Jan 2020 15:58:27 -0300 Subject: [PATCH 11/12] Add support for icebreakers-cleanup-crew commands --- triagebot.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index f0e3a99037b02..7ece7f977ce2a 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -19,3 +19,14 @@ Thanks! <3 [instructions]: https://rust-lang.github.io/rustc-guide/ice-breaker/llvm.html """ label = "ICEBreaker-LLVM" + +[ping.icebreakers-cleanup-crew] +message = """\ +Hey Cleanup Crew ICE-breakers! This bug has been identified as a good +"Cleanup ICE-breaking candidate". In case it's useful, here are some +[instructions] for tackling these sorts of bugs. Maybe take a look? +Thanks! <3 + +[instructions]: https://rust-lang.github.io/rustc-guide/ice-breaker/cleanup-crew.html +""" +label = "ICEBreaker-Cleanup-Crew" From 2c07a621ef80e059d788f9846c8bdfd2e44b5c58 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 14 Jan 2020 14:43:05 +1000 Subject: [PATCH 12/12] stabilize the debug_map_key_value feature --- .../src/library-features/debug-map-key-value.md | 9 --------- src/libcore/fmt/builders.rs | 6 ++---- src/libcore/tests/lib.rs | 1 - 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 src/doc/unstable-book/src/library-features/debug-map-key-value.md diff --git a/src/doc/unstable-book/src/library-features/debug-map-key-value.md b/src/doc/unstable-book/src/library-features/debug-map-key-value.md deleted file mode 100644 index ae839bf2ac32b..0000000000000 --- a/src/doc/unstable-book/src/library-features/debug-map-key-value.md +++ /dev/null @@ -1,9 +0,0 @@ -# `debug_map_key_value` - -The tracking issue for this feature is: [#62482] - -[#62482]: https://github.com/rust-lang/rust/issues/62482 - ------------------------- - -Add the methods `key` and `value` to `DebugMap` so that an entry can be formatted across multiple calls without additional buffering. diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs index 8ba0e422e8f13..63866a5d110e3 100644 --- a/src/libcore/fmt/builders.rs +++ b/src/libcore/fmt/builders.rs @@ -778,7 +778,6 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// # Examples /// /// ``` - /// # #![feature(debug_map_key_value)] /// use std::fmt; /// /// struct Foo(Vec<(String, i32)>); @@ -796,7 +795,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// "{\"whole\": [(\"A\", 10), (\"B\", 11)]}", /// ); /// ``` - #[unstable(feature = "debug_map_key_value", reason = "recently added", issue = "62482")] + #[stable(feature = "debug_map_key_value", since = "1.42.0")] pub fn key(&mut self, key: &dyn fmt::Debug) -> &mut Self { self.result = self.result.and_then(|_| { assert!( @@ -843,7 +842,6 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// # Examples /// /// ``` - /// # #![feature(debug_map_key_value)] /// use std::fmt; /// /// struct Foo(Vec<(String, i32)>); @@ -861,7 +859,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// "{\"whole\": [(\"A\", 10), (\"B\", 11)]}", /// ); /// ``` - #[unstable(feature = "debug_map_key_value", reason = "recently added", issue = "62482")] + #[stable(feature = "debug_map_key_value", since = "1.42.0")] pub fn value(&mut self, value: &dyn fmt::Debug) -> &mut Self { self.result = self.result.and_then(|_| { assert!(self.has_key, "attempted to format a map value before its key"); diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 21e279066e739..197536158bec1 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -4,7 +4,6 @@ #![feature(cell_update)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] -#![feature(debug_map_key_value)] #![feature(debug_non_exhaustive)] #![feature(dec2flt)] #![feature(exact_size_is_empty)]