From 21e4fa6b6dd5653aea6bde03760b4a521e604893 Mon Sep 17 00:00:00 2001 From: Dylan Nugent Date: Thu, 5 Mar 2020 21:55:36 -0500 Subject: [PATCH 1/8] Update deprecation version to 1.42 for Error::description Error::description is deprecated as of version 1.42, as the commit was not in the release for 1.41. --- src/libstd/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index b480581e21ba9..3f6501bc7b4f6 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -135,7 +135,7 @@ pub trait Error: Debug + Display { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_deprecated(since = "1.41.0", reason = "use the Display impl or to_string()")] + #[rustc_deprecated(since = "1.42.0", reason = "use the Display impl or to_string()")] fn description(&self) -> &str { "description() is deprecated; use Display" } From 158e4214d4fd24089dc25cf1212e83105736d2f5 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 5 Mar 2020 21:53:26 -0500 Subject: [PATCH 2/8] Fix #69191 --- src/librustc_mir/interpret/place.rs | 6 ++++ ...sue-69191-ice-on-uninhabited-enum-field.rs | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 4f96cb698915d..33161dfa52c7b 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -410,6 +410,12 @@ where stride * field } layout::FieldPlacement::Union(count) => { + // This is a narrow bug-fix for rust-lang/rust#69191: if we are + // trying to access absent field of uninhabited variant, then + // signal UB (but don't ICE the compiler). + if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited { + throw_ub!(Unreachable); + } assert!( field < count as u64, "Tried to access field {} of union {:#?} with {} fields", diff --git a/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs b/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs new file mode 100644 index 0000000000000..e22ddb0f5ae0c --- /dev/null +++ b/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs @@ -0,0 +1,31 @@ +// build-pass +// +// (this is deliberately *not* check-pass; I have confirmed that the bug in +// question does not replicate when one uses `cargo check` alone.) + +pub enum Void {} + +enum UninhabitedUnivariant { _Variant(Void), } + +#[repr(C)] +enum UninhabitedUnivariantC { _Variant(Void), } + +#[repr(i32)] +enum UninhabitedUnivariant32 { _Variant(Void), } + +fn main() { + let _seed: UninhabitedUnivariant = None.unwrap(); + match _seed { + UninhabitedUnivariant::_Variant(_x) => {} + } + + let _seed: UninhabitedUnivariantC = None.unwrap(); + match _seed { + UninhabitedUnivariantC::_Variant(_x) => {} + } + + let _seed: UninhabitedUnivariant32 = None.unwrap(); + match _seed { + UninhabitedUnivariant32::_Variant(_x) => {} + } +} From ffaa73f93b68784e7d21b859d4f3c40a3d6a5b5b Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 6 Mar 2020 08:48:58 +0100 Subject: [PATCH 3/8] Add FIXME --- src/librustc_mir/interpret/place.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 33161dfa52c7b..721766cc932d3 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -413,6 +413,8 @@ where // This is a narrow bug-fix for rust-lang/rust#69191: if we are // trying to access absent field of uninhabited variant, then // signal UB (but don't ICE the compiler). + // FIXME temporary hack to work around incoherence between + // layout computation and MIR building if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited { throw_ub!(Unreachable); } From c7118d49e3434ec89b5640da606aae21255427cb Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 6 Mar 2020 06:43:11 -0500 Subject: [PATCH 4/8] Added oli's multivariant test case (alpha renaming the enum name itself). (And added Ralf's suggested test.) Added my own three-variant multi-variant as well. --- ...sue-69191-ice-on-uninhabited-enum-field.rs | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs b/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs index e22ddb0f5ae0c..5b7c7be42cf06 100644 --- a/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs +++ b/src/test/ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs @@ -5,13 +5,30 @@ pub enum Void {} -enum UninhabitedUnivariant { _Variant(Void), } +enum UninhabitedUnivariant { + _Variant(Void), +} + +enum UninhabitedMultivariant2 { + _Variant(Void), + _Warriont(Void), +} + +enum UninhabitedMultivariant3 { + _Variant(Void), + _Warriont(Void), + _Worrynot(Void), +} #[repr(C)] -enum UninhabitedUnivariantC { _Variant(Void), } +enum UninhabitedUnivariantC { + _Variant(Void), +} #[repr(i32)] -enum UninhabitedUnivariant32 { _Variant(Void), } +enum UninhabitedUnivariant32 { + _Variant(Void), +} fn main() { let _seed: UninhabitedUnivariant = None.unwrap(); @@ -19,6 +36,49 @@ fn main() { UninhabitedUnivariant::_Variant(_x) => {} } + let _seed: UninhabitedMultivariant2 = None.unwrap(); + match _seed { + UninhabitedMultivariant2::_Variant(_x) => {} + UninhabitedMultivariant2::_Warriont(_x) => {} + } + + let _seed: UninhabitedMultivariant2 = None.unwrap(); + match _seed { + UninhabitedMultivariant2::_Variant(_x) => {} + _ => {} + } + + let _seed: UninhabitedMultivariant2 = None.unwrap(); + match _seed { + UninhabitedMultivariant2::_Warriont(_x) => {} + _ => {} + } + + let _seed: UninhabitedMultivariant3 = None.unwrap(); + match _seed { + UninhabitedMultivariant3::_Variant(_x) => {} + UninhabitedMultivariant3::_Warriont(_x) => {} + UninhabitedMultivariant3::_Worrynot(_x) => {} + } + + let _seed: UninhabitedMultivariant3 = None.unwrap(); + match _seed { + UninhabitedMultivariant3::_Variant(_x) => {} + _ => {} + } + + let _seed: UninhabitedMultivariant3 = None.unwrap(); + match _seed { + UninhabitedMultivariant3::_Warriont(_x) => {} + _ => {} + } + + let _seed: UninhabitedMultivariant3 = None.unwrap(); + match _seed { + UninhabitedMultivariant3::_Worrynot(_x) => {} + _ => {} + } + let _seed: UninhabitedUnivariantC = None.unwrap(); match _seed { UninhabitedUnivariantC::_Variant(_x) => {} From 153e0029f519616ff9c7fb5c0ef92b5c48a56f66 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Jan 2020 13:48:08 +0100 Subject: [PATCH 5/8] Fix null synthetic_implementors error --- src/librustdoc/html/static/main.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ec881d25dd2bf..44fd8b929f3a3 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1895,21 +1895,23 @@ function getSearchElement() { var implementors = document.getElementById("implementors-list"); var synthetic_implementors = document.getElementById("synthetic-implementors-list"); - // This `inlined_types` variable is used to avoid having the same implementation showing - // up twice. For example "String" in the "Sync" doc page. - // - // By the way, this is only used by and useful for traits implemented automatically (like - // "Send" and "Sync"). - var inlined_types = new Set(); - onEachLazy(synthetic_implementors.getElementsByClassName("impl"), function(el) { - var aliases = el.getAttribute("aliases"); - if (!aliases) { - return; - } - aliases.split(",").forEach(function(alias) { - inlined_types.add(alias); + if (synthetic_implementors) { + // This `inlined_types` variable is used to avoid having the same implementation + // showing up twice. For example "String" in the "Sync" doc page. + // + // By the way, this is only used by and useful for traits implemented automatically + // (like "Send" and "Sync"). + var inlined_types = new Set(); + onEachLazy(synthetic_implementors.getElementsByClassName("impl"), function(el) { + var aliases = el.getAttribute("aliases"); + if (!aliases) { + return; + } + aliases.split(",").forEach(function(alias) { + inlined_types.add(alias); + }); }); - }); + } var libs = Object.getOwnPropertyNames(imp); var llength = libs.length; From c12687b1a12b893ec8352861ec9fed773b8027a6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 9 Mar 2020 13:20:00 +0100 Subject: [PATCH 6/8] error_derive_forbidden_on_non_adt: be more graceful --- src/librustc_expand/expand.rs | 7 +++-- .../issue-69341-malformed-derive-inert.rs | 10 +++++++ .../issue-69341-malformed-derive-inert.stderr | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/malformed/issue-69341-malformed-derive-inert.rs create mode 100644 src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index f915f44c17ab9..a65ba8903be70 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -435,14 +435,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> { _ => unreachable!(), }; if !item.derive_allowed() { - let attr = attr::find_by_name(item.attrs(), sym::derive) - .expect("`derive` attribute should exist"); - let span = attr.span; + let attr = attr::find_by_name(item.attrs(), sym::derive); + let span = attr.map_or(item.span(), |attr| attr.span); let mut err = self.cx.struct_span_err( span, "`derive` may only be applied to structs, enums and unions", ); - if let ast::AttrStyle::Inner = attr.style { + if let Some(ast::Attribute { style: ast::AttrStyle::Inner, .. }) = attr { let trait_list = derives .iter() .map(|t| pprust::path_to_string(t)) diff --git a/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs b/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs new file mode 100644 index 0000000000000..24692f7cf52e1 --- /dev/null +++ b/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs @@ -0,0 +1,10 @@ +fn main() {} + +struct CLI { + #[derive(parse())] + //~^ ERROR traits in `#[derive(...)]` don't accept arguments + //~| ERROR cannot find derive macro `parse` in this scope + //~| ERROR cannot find derive macro `parse` in this scope + path: (), + //~^ ERROR `derive` may only be applied to structs, enums and unions +} diff --git a/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr b/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr new file mode 100644 index 0000000000000..e8f96178d10bf --- /dev/null +++ b/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr @@ -0,0 +1,26 @@ +error: traits in `#[derive(...)]` don't accept arguments + --> $DIR/issue-69341-malformed-derive-inert.rs:4:19 + | +LL | #[derive(parse())] + | ^^ help: remove the arguments + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-69341-malformed-derive-inert.rs:8:5 + | +LL | path: (), + | ^^^^^^^^ + +error: cannot find derive macro `parse` in this scope + --> $DIR/issue-69341-malformed-derive-inert.rs:4:14 + | +LL | #[derive(parse())] + | ^^^^^ + +error: cannot find derive macro `parse` in this scope + --> $DIR/issue-69341-malformed-derive-inert.rs:4:14 + | +LL | #[derive(parse())] + | ^^^^^ + +error: aborting due to 4 previous errors + From 182b777b587ff706a5277223fed9b2d26c00e34d Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 9 Mar 2020 15:27:32 +0100 Subject: [PATCH 7/8] include compatibility notes for 1.42.0 --- RELEASES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 7e18f1befddec..77d0bbe57912b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -71,7 +71,15 @@ Compatibility Notes ------------------- - [`Error::description` has been deprecated, and its use will now produce a warning.][66919] It's recommended to use `Display`/`to_string` instead. - +- [`use $crate;` inside macros is now a hard error.][37390] The compiler + emitted forward compatibility warnings since Rust 1.14.0. +- [As previously announced, this release reduces the level of support for + 32-bit Apple targets to tier 3.][apple-32bit-drop]. This means that the + source code is still available to build, but the targets are no longer tested + and no release binary is distributed by the Rust project. Please refer to the + linked blog post for more information. + +[37390]: https://github.com/rust-lang/rust/issues/37390/ [68253]: https://github.com/rust-lang/rust/pull/68253/ [68348]: https://github.com/rust-lang/rust/pull/68348/ [67935]: https://github.com/rust-lang/rust/pull/67935/ From 133f659766c60ff7a33288ae6f33b0c272792f57 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 9 Mar 2020 15:28:32 +0100 Subject: [PATCH 8/8] 1.42.0 stable release --- 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 29c11cceb15a4..67f51d0e8662d 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -43,7 +43,7 @@ fi # # FIXME: need a scheme for changing this `nightly` value to `beta` and `stable` # either automatically or manually. -export RUST_RELEASE_CHANNEL=beta +export RUST_RELEASE_CHANNEL=stable # Always set the release channel for bootstrap; this is normally not important (i.e., only dist # builds would seem to matter) but in practice bootstrap wants to know whether we're targeting