Skip to content

Commit b8cedc0

Browse files
committed
Auto merge of #69854 - pietroalbini:stable-next, r=Centril
[stable] Release 1.42.0 This PR prepares the release artifacts of Rust 1.42.0, and cherry-picks the following PRs: * #69754: Update deprecation version to 1.42 for Error::description * #69753: Do not ICE when matching an uninhabited enum's field * #69522 / #69853: error_derive_forbidden_on_non_adt: be more graceful * #68598: Fix null synthetic_implementors error In addition, the release notes are updated to include the remaining compatibility notes. r? @Centril
2 parents b08d071 + 133f659 commit b8cedc0

File tree

9 files changed

+165
-21
lines changed

9 files changed

+165
-21
lines changed

RELEASES.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ Compatibility Notes
7171
-------------------
7272
- [`Error::description` has been deprecated, and its use will now produce a
7373
warning.][66919] It's recommended to use `Display`/`to_string` instead.
74-
74+
- [`use $crate;` inside macros is now a hard error.][37390] The compiler
75+
emitted forward compatibility warnings since Rust 1.14.0.
76+
- [As previously announced, this release reduces the level of support for
77+
32-bit Apple targets to tier 3.][apple-32bit-drop]. This means that the
78+
source code is still available to build, but the targets are no longer tested
79+
and no release binary is distributed by the Rust project. Please refer to the
80+
linked blog post for more information.
81+
82+
[37390]: https://github.com/rust-lang/rust/issues/37390/
7583
[68253]: https://github.com/rust-lang/rust/pull/68253/
7684
[68348]: https://github.com/rust-lang/rust/pull/68348/
7785
[67935]: https://github.com/rust-lang/rust/pull/67935/

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343
#
4444
# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
4545
# either automatically or manually.
46-
export RUST_RELEASE_CHANNEL=beta
46+
export RUST_RELEASE_CHANNEL=stable
4747

4848
# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
4949
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting

src/librustc_expand/expand.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
435435
_ => unreachable!(),
436436
};
437437
if !item.derive_allowed() {
438-
let attr = attr::find_by_name(item.attrs(), sym::derive)
439-
.expect("`derive` attribute should exist");
440-
let span = attr.span;
438+
let attr = attr::find_by_name(item.attrs(), sym::derive);
439+
let span = attr.map_or(item.span(), |attr| attr.span);
441440
let mut err = self.cx.struct_span_err(
442441
span,
443442
"`derive` may only be applied to structs, enums and unions",
444443
);
445-
if let ast::AttrStyle::Inner = attr.style {
444+
if let Some(ast::Attribute { style: ast::AttrStyle::Inner, .. }) = attr {
446445
let trait_list = derives
447446
.iter()
448447
.map(|t| pprust::path_to_string(t))

src/librustc_mir/interpret/place.rs

+8
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,14 @@ where
410410
stride * field
411411
}
412412
layout::FieldPlacement::Union(count) => {
413+
// This is a narrow bug-fix for rust-lang/rust#69191: if we are
414+
// trying to access absent field of uninhabited variant, then
415+
// signal UB (but don't ICE the compiler).
416+
// FIXME temporary hack to work around incoherence between
417+
// layout computation and MIR building
418+
if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited {
419+
throw_ub!(Unreachable);
420+
}
413421
assert!(
414422
field < count as u64,
415423
"Tried to access field {} of union {:#?} with {} fields",

src/librustdoc/html/static/main.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -1895,21 +1895,23 @@ function getSearchElement() {
18951895
var implementors = document.getElementById("implementors-list");
18961896
var synthetic_implementors = document.getElementById("synthetic-implementors-list");
18971897

1898-
// This `inlined_types` variable is used to avoid having the same implementation showing
1899-
// up twice. For example "String" in the "Sync" doc page.
1900-
//
1901-
// By the way, this is only used by and useful for traits implemented automatically (like
1902-
// "Send" and "Sync").
1903-
var inlined_types = new Set();
1904-
onEachLazy(synthetic_implementors.getElementsByClassName("impl"), function(el) {
1905-
var aliases = el.getAttribute("aliases");
1906-
if (!aliases) {
1907-
return;
1908-
}
1909-
aliases.split(",").forEach(function(alias) {
1910-
inlined_types.add(alias);
1898+
if (synthetic_implementors) {
1899+
// This `inlined_types` variable is used to avoid having the same implementation
1900+
// showing up twice. For example "String" in the "Sync" doc page.
1901+
//
1902+
// By the way, this is only used by and useful for traits implemented automatically
1903+
// (like "Send" and "Sync").
1904+
var inlined_types = new Set();
1905+
onEachLazy(synthetic_implementors.getElementsByClassName("impl"), function(el) {
1906+
var aliases = el.getAttribute("aliases");
1907+
if (!aliases) {
1908+
return;
1909+
}
1910+
aliases.split(",").forEach(function(alias) {
1911+
inlined_types.add(alias);
1912+
});
19111913
});
1912-
});
1914+
}
19131915

19141916
var libs = Object.getOwnPropertyNames(imp);
19151917
var llength = libs.length;

src/libstd/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub trait Error: Debug + Display {
135135
/// }
136136
/// ```
137137
#[stable(feature = "rust1", since = "1.0.0")]
138-
#[rustc_deprecated(since = "1.41.0", reason = "use the Display impl or to_string()")]
138+
#[rustc_deprecated(since = "1.42.0", reason = "use the Display impl or to_string()")]
139139
fn description(&self) -> &str {
140140
"description() is deprecated; use Display"
141141
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// build-pass
2+
//
3+
// (this is deliberately *not* check-pass; I have confirmed that the bug in
4+
// question does not replicate when one uses `cargo check` alone.)
5+
6+
pub enum Void {}
7+
8+
enum UninhabitedUnivariant {
9+
_Variant(Void),
10+
}
11+
12+
enum UninhabitedMultivariant2 {
13+
_Variant(Void),
14+
_Warriont(Void),
15+
}
16+
17+
enum UninhabitedMultivariant3 {
18+
_Variant(Void),
19+
_Warriont(Void),
20+
_Worrynot(Void),
21+
}
22+
23+
#[repr(C)]
24+
enum UninhabitedUnivariantC {
25+
_Variant(Void),
26+
}
27+
28+
#[repr(i32)]
29+
enum UninhabitedUnivariant32 {
30+
_Variant(Void),
31+
}
32+
33+
fn main() {
34+
let _seed: UninhabitedUnivariant = None.unwrap();
35+
match _seed {
36+
UninhabitedUnivariant::_Variant(_x) => {}
37+
}
38+
39+
let _seed: UninhabitedMultivariant2 = None.unwrap();
40+
match _seed {
41+
UninhabitedMultivariant2::_Variant(_x) => {}
42+
UninhabitedMultivariant2::_Warriont(_x) => {}
43+
}
44+
45+
let _seed: UninhabitedMultivariant2 = None.unwrap();
46+
match _seed {
47+
UninhabitedMultivariant2::_Variant(_x) => {}
48+
_ => {}
49+
}
50+
51+
let _seed: UninhabitedMultivariant2 = None.unwrap();
52+
match _seed {
53+
UninhabitedMultivariant2::_Warriont(_x) => {}
54+
_ => {}
55+
}
56+
57+
let _seed: UninhabitedMultivariant3 = None.unwrap();
58+
match _seed {
59+
UninhabitedMultivariant3::_Variant(_x) => {}
60+
UninhabitedMultivariant3::_Warriont(_x) => {}
61+
UninhabitedMultivariant3::_Worrynot(_x) => {}
62+
}
63+
64+
let _seed: UninhabitedMultivariant3 = None.unwrap();
65+
match _seed {
66+
UninhabitedMultivariant3::_Variant(_x) => {}
67+
_ => {}
68+
}
69+
70+
let _seed: UninhabitedMultivariant3 = None.unwrap();
71+
match _seed {
72+
UninhabitedMultivariant3::_Warriont(_x) => {}
73+
_ => {}
74+
}
75+
76+
let _seed: UninhabitedMultivariant3 = None.unwrap();
77+
match _seed {
78+
UninhabitedMultivariant3::_Worrynot(_x) => {}
79+
_ => {}
80+
}
81+
82+
let _seed: UninhabitedUnivariantC = None.unwrap();
83+
match _seed {
84+
UninhabitedUnivariantC::_Variant(_x) => {}
85+
}
86+
87+
let _seed: UninhabitedUnivariant32 = None.unwrap();
88+
match _seed {
89+
UninhabitedUnivariant32::_Variant(_x) => {}
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {}
2+
3+
struct CLI {
4+
#[derive(parse())]
5+
//~^ ERROR traits in `#[derive(...)]` don't accept arguments
6+
//~| ERROR cannot find derive macro `parse` in this scope
7+
//~| ERROR cannot find derive macro `parse` in this scope
8+
path: (),
9+
//~^ ERROR `derive` may only be applied to structs, enums and unions
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: traits in `#[derive(...)]` don't accept arguments
2+
--> $DIR/issue-69341-malformed-derive-inert.rs:4:19
3+
|
4+
LL | #[derive(parse())]
5+
| ^^ help: remove the arguments
6+
7+
error: `derive` may only be applied to structs, enums and unions
8+
--> $DIR/issue-69341-malformed-derive-inert.rs:8:5
9+
|
10+
LL | path: (),
11+
| ^^^^^^^^
12+
13+
error: cannot find derive macro `parse` in this scope
14+
--> $DIR/issue-69341-malformed-derive-inert.rs:4:14
15+
|
16+
LL | #[derive(parse())]
17+
| ^^^^^
18+
19+
error: cannot find derive macro `parse` in this scope
20+
--> $DIR/issue-69341-malformed-derive-inert.rs:4:14
21+
|
22+
LL | #[derive(parse())]
23+
| ^^^^^
24+
25+
error: aborting due to 4 previous errors
26+

0 commit comments

Comments
 (0)