Skip to content

Commit 67fae22

Browse files
committed
Auto merge of #68587 - JohnTitor:rollup-fz45xwc, r=JohnTitor
Rollup of 11 pull requests Successful merges: - #68200 (Stabilize the debug_map_key_value feature) - #68383 (Clean up E0205 explanation) - #68412 (Clean up E0207 explanation) - #68454 (clean up E0214 explanation) - #68482 (clean up error codes explanation) - #68563 (Don't call `tcx.fn_sig` on closures) - #68570 (Bump LLVM submodule to fix LLVM assertion failure in MSP430 interrupt generation.) - #68571 (check_match: extract common logic) - #68573 (Clean up E0262 explanation) - #68575 (Disable the testcase for Vxworks.) - #68581 (Add support for icebreakers-cleanup-crew commands) Failed merges: r? @ghost
2 parents 0859451 + aac5788 commit 67fae22

File tree

18 files changed

+103
-48
lines changed

18 files changed

+103
-48
lines changed

src/doc/unstable-book/src/library-features/debug-map-key-value.md

-9
This file was deleted.

src/libcore/fmt/builders.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
778778
/// # Examples
779779
///
780780
/// ```
781-
/// # #![feature(debug_map_key_value)]
782781
/// use std::fmt;
783782
///
784783
/// struct Foo(Vec<(String, i32)>);
@@ -796,7 +795,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
796795
/// "{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
797796
/// );
798797
/// ```
799-
#[unstable(feature = "debug_map_key_value", reason = "recently added", issue = "62482")]
798+
#[stable(feature = "debug_map_key_value", since = "1.42.0")]
800799
pub fn key(&mut self, key: &dyn fmt::Debug) -> &mut Self {
801800
self.result = self.result.and_then(|_| {
802801
assert!(
@@ -843,7 +842,6 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
843842
/// # Examples
844843
///
845844
/// ```
846-
/// # #![feature(debug_map_key_value)]
847845
/// use std::fmt;
848846
///
849847
/// struct Foo(Vec<(String, i32)>);
@@ -861,7 +859,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
861859
/// "{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
862860
/// );
863861
/// ```
864-
#[unstable(feature = "debug_map_key_value", reason = "recently added", issue = "62482")]
862+
#[stable(feature = "debug_map_key_value", since = "1.42.0")]
865863
pub fn value(&mut self, value: &dyn fmt::Debug) -> &mut Self {
866864
self.result = self.result.and_then(|_| {
867865
assert!(self.has_key, "attempted to format a map value before its key");

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![feature(cell_update)]
55
#![feature(core_private_bignum)]
66
#![feature(core_private_diy_float)]
7-
#![feature(debug_map_key_value)]
87
#![feature(debug_non_exhaustive)]
98
#![feature(dec2flt)]
109
#![feature(exact_size_is_empty)]
+11-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
You can only implement `Copy` for a struct or enum. Both of the following
2-
examples will fail, because neither `[u8; 256]` nor `&'static mut Bar`
3-
(mutable reference to `Bar`) is a struct or enum:
1+
The `Copy` trait was implemented on a type which is neither a struct nor an
2+
enum.
3+
4+
Erroneous code example:
45

56
```compile_fail,E0206
67
type Foo = [u8; 256];
7-
impl Copy for Foo { } // error
8+
impl Copy for Foo { } // error!
89
910
#[derive(Copy, Clone)]
1011
struct Bar;
11-
impl Copy for &'static mut Bar { } // error
12+
13+
impl Copy for &'static mut Bar { } // error!
1214
```
15+
16+
You can only implement `Copy` for a struct or an enum. Both of the previous
17+
examples will fail, because neither `[u8; 256]` nor `&'static mut Bar`
18+
(mutable reference to `Bar`) is a struct or enum.

src/librustc_error_codes/error_codes/E0207.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
A type or lifetime parameter that is specified for `impl` is not constrained.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0207
6+
struct Foo;
7+
8+
impl<T: Default> Foo {
9+
// error: the type parameter `T` is not constrained by the impl trait, self
10+
// type, or predicates [E0207]
11+
fn get(&self) -> T {
12+
<T as Default>::default()
13+
}
14+
}
15+
```
16+
117
Any type parameter or lifetime parameter of an `impl` must meet at least one of
218
the following criteria:
319

@@ -10,19 +26,7 @@ the following criteria:
1026
### Error example 1
1127

1228
Suppose we have a struct `Foo` and we would like to define some methods for it.
13-
The following definition leads to a compiler error:
14-
15-
```compile_fail,E0207
16-
struct Foo;
17-
18-
impl<T: Default> Foo {
19-
// error: the type parameter `T` is not constrained by the impl trait, self
20-
// type, or predicates [E0207]
21-
fn get(&self) -> T {
22-
<T as Default>::default()
23-
}
24-
}
25-
```
29+
The previous code example has a definition which leads to a compiler error:
2630

2731
The problem is that the parameter `T` does not appear in the implementing type
2832
(`Foo`) of the impl. In this case, we can fix the error by moving the type
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
A generic type was described using parentheses rather than angle brackets.
2-
For example:
2+
3+
Erroneous code example:
34

45
```compile_fail,E0214
5-
fn main() {
6-
let v: Vec(&str) = vec!["foo"];
7-
}
6+
let v: Vec(&str) = vec!["foo"];
87
```
98

109
This is not currently supported: `v` should be defined as `Vec<&str>`.
1110
Parentheses are currently only used with generic types when defining parameters
1211
for `Fn`-family traits.
12+
13+
The previous code example fixed:
14+
15+
```
16+
let v: Vec<&str> = vec!["foo"];
17+
```

src/librustc_error_codes/error_codes/E0220.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
You used an associated type which isn't defined in the trait.
1+
The associated type used was not defined in the trait.
2+
23
Erroneous code example:
34

45
```compile_fail,E0220

src/librustc_error_codes/error_codes/E0221.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
An attempt was made to retrieve an associated type, but the type was ambiguous.
2-
For example:
2+
3+
Erroneous code example:
34

45
```compile_fail,E0221
56
trait T1 {}

src/librustc_error_codes/error_codes/E0222.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
An attempt was made to constrain an associated type.
2-
For example:
2+
3+
Erroneous code example:
34

45
```compile_fail,E0222
56
pub trait Vehicle {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
Declaring certain lifetime names in parameters is disallowed. For example,
2-
because the `'static` lifetime is a special built-in lifetime name denoting
3-
the lifetime of the entire program, this is an error:
1+
An invalid name was used for a lifetime parameter.
2+
3+
Erroneous code example:
44

55
```compile_fail,E0262
66
// error, invalid lifetime parameter name `'static`
77
fn foo<'static>(x: &'static str) { }
88
```
9+
10+
Declaring certain lifetime names in parameters is disallowed. For example,
11+
because the `'static` lifetime is a special built-in lifetime name denoting
12+
the lifetime of the entire program, this is an error:

src/librustc_mir/const_eval/fn_queries.rs

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ pub fn provide(providers: &mut Providers<'_>) {
8686
/// Const evaluability whitelist is here to check evaluability at the
8787
/// top level beforehand.
8888
fn is_const_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> Option<bool> {
89+
if tcx.is_closure(def_id) {
90+
return None;
91+
}
92+
8993
match tcx.fn_sig(def_id).abi() {
9094
Abi::RustIntrinsic | Abi::PlatformIntrinsic => {
9195
Some(tcx.lookup_const_stability(def_id).is_some())

src/librustc_mir_build/hair/pattern/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
586586
tcx: TyCtxt<'tcx>,
587587
param_env: ty::ParamEnv<'tcx>,
588588
module: DefId,
589-
f: impl for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R,
589+
f: impl FnOnce(MatchCheckCtxt<'_, 'tcx>) -> R,
590590
) -> R {
591591
let pattern_arena = TypedArena::default();
592592

src/librustc_mir_build/hair/pattern/check_match.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
140140
(pattern, pattern_ty)
141141
}
142142

143+
fn check_in_cx(&self, hir_id: HirId, f: impl FnOnce(MatchCheckCtxt<'_, 'tcx>)) {
144+
let module = self.tcx.hir().get_module_parent(hir_id);
145+
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |cx| f(cx));
146+
}
147+
143148
fn check_match(
144149
&mut self,
145150
scrut: &hir::Expr<'_>,
@@ -151,8 +156,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
151156
self.check_patterns(arm.guard.is_some(), &arm.pat);
152157
}
153158

154-
let module = self.tcx.hir().get_module_parent(scrut.hir_id);
155-
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
159+
self.check_in_cx(scrut.hir_id, |ref mut cx| {
156160
let mut have_errors = false;
157161

158162
let inlined_arms: Vec<_> = arms
@@ -180,8 +184,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
180184
}
181185

182186
fn check_irrefutable(&self, pat: &'tcx Pat<'tcx>, origin: &str, sp: Option<Span>) {
183-
let module = self.tcx.hir().get_module_parent(pat.hir_id);
184-
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
187+
self.check_in_cx(pat.hir_id, |ref mut cx| {
185188
let (pattern, pattern_ty) = self.lower_pattern(cx, pat, &mut false);
186189
let pats: Matrix<'_, '_> = vec![PatStack::from_pattern(pattern)].into_iter().collect();
187190

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Regression test for issue #68542
2+
// Tests that we don't ICE when a closure appears
3+
// in the length part of an array.
4+
5+
struct Bug {
6+
a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to
7+
//~^ ERROR evaluation of constant value failed
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
2+
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
3+
|
4+
LL | a: [(); (|| { 0 })()]
5+
| ^^^^^^^^^^^^
6+
7+
error[E0080]: evaluation of constant value failed
8+
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
9+
|
10+
LL | a: [(); (|| { 0 })()]
11+
| ^^^^^^^^^^^^ calling non-const function `Bug::a::{{constant}}#0::{{closure}}#0`
12+
13+
error: aborting due to 2 previous errors
14+
15+
Some errors have detailed explanations: E0015, E0080.
16+
For more information about an error, try `rustc --explain E0015`.

src/test/ui/env-funky-keys.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// ignore-cloudabi no execve
77
// ignore-emscripten no execve
88
// ignore-sgx no execve
9+
// ignore-vxworks no execve
910
// no-prefer-dynamic
1011

1112
#![feature(rustc_private)]

triagebot.toml

+11
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ Thanks! <3
1919
[instructions]: https://rust-lang.github.io/rustc-guide/ice-breaker/llvm.html
2020
"""
2121
label = "ICEBreaker-LLVM"
22+
23+
[ping.icebreakers-cleanup-crew]
24+
message = """\
25+
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
26+
"Cleanup ICE-breaking candidate". In case it's useful, here are some
27+
[instructions] for tackling these sorts of bugs. Maybe take a look?
28+
Thanks! <3
29+
30+
[instructions]: https://rust-lang.github.io/rustc-guide/ice-breaker/cleanup-crew.html
31+
"""
32+
label = "ICEBreaker-Cleanup-Crew"

0 commit comments

Comments
 (0)