From c94d0bc188a11951da80c15f5add6be7ef22079c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 8 Aug 2022 08:21:18 -0400 Subject: [PATCH 1/6] Bump to stable --- RELEASES.md | 213 ++++++++++++++++++++++++++++++++++++++++++++++++- src/ci/channel | 2 +- 2 files changed, 211 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 3d88891ad215c..e66bf60b7f781 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,207 @@ +Version 1.63.0 (2022-08-11) +========================== + +Language +-------- +- [Remove migrate borrowck mode for pre-NLL errors.][95565] +- [Modify MIR building to drop repeat expressions with length zero.][95953] +- [Remove label/lifetime shadowing warnings.][96296] +- [Allow explicit generic arguments in the presence of `impl Trait` args.][96868] +- [Make `cenum_impl_drop_cast` warnings deny-by-default.][97652] +- [Prevent unwinding when `-C panic=abort` is used regardless of declared ABI.][96959] +- [lub: don't bail out due to empty binders.][97867] + +Compiler +-------- +- [Stabilize the `bundle` native library modifier,][95818] also removing the + deprecated `static-nobundle` linking kind. +- [Add Apple WatchOS compile targets\*.][95243] +- [Add a Windows application manifest to rustc-main.][96737] + +\* Refer to Rust's [platform support page][platform-support-doc] for more + information on Rust's tiered platform support. + +Libraries +--------- +- [Implement `Copy`, `Clone`, `PartialEq` and `Eq` for `core::fmt::Alignment`.][94530] +- [Extend `ptr::null` and `null_mut` to all thin (including extern) types.][94954] +- [`impl Read and Write for VecDeque`.][95632] +- [STD support for the Nintendo 3DS.][95897] +- [Make write/print macros eagerly drop temporaries.][96455] +- [Implement internal traits that enable `[OsStr]::join`.][96881] +- [Implement `Hash` for `core::alloc::Layout`.][97034] +- [Add capacity documentation for `OsString`.][97202] +- [Put a bound on collection misbehavior.][97316] +- [Make `std::mem::needs_drop` accept `?Sized`.][97675] +- [`impl Termination for Infallible` and then make the `Result` impls of `Termination` more generic.][97803] +- [Document Rust's stance on `/proc/self/mem`.][97837] + +Stabilized APIs +--------------- + +- [`array::from_fn`] +- [`Box::into_pin`] +- [`BinaryHeap::try_reserve`] +- [`BinaryHeap::try_reserve_exact`] +- [`OsString::try_reserve`] +- [`OsString::try_reserve_exact`] +- [`PathBuf::try_reserve`] +- [`PathBuf::try_reserve_exact`] +- [`Path::try_exists`] +- [`Ref::filter_map`] +- [`RefMut::filter_map`] +- [`NonNull::<[T]>::len`][`NonNull::::len`] +- [`ToOwned::clone_into`] +- [`Ipv6Addr::to_ipv4_mapped`] +- [`unix::io::AsFd`] +- [`unix::io::BorrowedFd<'fd>`] +- [`unix::io::OwnedFd`] +- [`windows::io::AsHandle`] +- [`windows::io::BorrowedHandle<'handle>`] +- [`windows::io::OwnedHandle`] +- [`windows::io::HandleOrInvalid`] +- [`windows::io::HandleOrNull`] +- [`windows::io::InvalidHandleError`] +- [`windows::io::NullHandleError`] +- [`windows::io::AsSocket`] +- [`windows::io::BorrowedSocket<'handle>`] +- [`windows::io::OwnedSocket`] +- [`thread::scope`] +- [`thread::Scope`] +- [`thread::ScopedJoinHandle`] + +These APIs are now usable in const contexts: + +- [`array::from_ref`] +- [`slice::from_ref`] +- [`intrinsics::copy`] +- [`intrinsics::copy_nonoverlapping`] +- [`<*const T>::copy_to`] +- [`<*const T>::copy_to_nonoverlapping`] +- [`<*mut T>::copy_to`] +- [`<*mut T>::copy_to_nonoverlapping`] +- [`<*mut T>::copy_from`] +- [`<*mut T>::copy_from_nonoverlapping`] +- [`str::from_utf8`] +- [`Utf8Error::error_len`] +- [`Utf8Error::valid_up_to`] +- [`Condvar::new`] +- [`Mutex::new`] +- [`RwLock::new`] + +Cargo +----- +- [Stabilize the `--config path` command-line argument.][cargo/10755] +- [Expose rust-version in the environment as `CARGO_PKG_RUST_VERSION`.][cargo/10713] + +Compatibility Notes +------------------- + +- [`#[link]` attributes are now checked more strictly,][96885] which may introduce + errors for invalid attribute arguments that were previously ignored. + +Internal Changes +---------------- + +These changes provide no direct user facing benefits, but represent significant +improvements to the internals and overall performance of rustc +and related tools. + +- [Prepare Rust for LLVM opaque pointers.][94214] + +[94214]: https://github.com/rust-lang/rust/pull/94214/ +[94530]: https://github.com/rust-lang/rust/pull/94530/ +[94954]: https://github.com/rust-lang/rust/pull/94954/ +[95243]: https://github.com/rust-lang/rust/pull/95243/ +[95565]: https://github.com/rust-lang/rust/pull/95565/ +[95632]: https://github.com/rust-lang/rust/pull/95632/ +[95818]: https://github.com/rust-lang/rust/pull/95818/ +[95897]: https://github.com/rust-lang/rust/pull/95897/ +[95953]: https://github.com/rust-lang/rust/pull/95953/ +[96296]: https://github.com/rust-lang/rust/pull/96296/ +[96455]: https://github.com/rust-lang/rust/pull/96455/ +[96737]: https://github.com/rust-lang/rust/pull/96737/ +[96868]: https://github.com/rust-lang/rust/pull/96868/ +[96881]: https://github.com/rust-lang/rust/pull/96881/ +[96885]: https://github.com/rust-lang/rust/pull/96885/ +[96959]: https://github.com/rust-lang/rust/pull/96959/ +[97034]: https://github.com/rust-lang/rust/pull/97034/ +[97202]: https://github.com/rust-lang/rust/pull/97202/ +[97316]: https://github.com/rust-lang/rust/pull/97316/ +[97652]: https://github.com/rust-lang/rust/pull/97652/ +[97675]: https://github.com/rust-lang/rust/pull/97675/ +[97803]: https://github.com/rust-lang/rust/pull/97803/ +[97837]: https://github.com/rust-lang/rust/pull/97837/ +[97867]: https://github.com/rust-lang/rust/pull/97867/ +[cargo/10713]: https://github.com/rust-lang/cargo/pull/10713/ +[cargo/10755]: https://github.com/rust-lang/cargo/pull/10755/ + +[`array::from_fn`]: https://doc.rust-lang.org/stable/std/array/fn.from_fn.html +[`Box::into_pin`]: https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.into_pin +[`BinaryHeap::try_reserve_exact`]: https://doc.rust-lang.org/stable/alloc/collections/binary_heap/struct.BinaryHeap.html#method.try_reserve_exact +[`BinaryHeap::try_reserve`]: https://doc.rust-lang.org/stable/std/collections/struct.BinaryHeap.html#method.try_reserve +[`OsString::try_reserve`]: https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.try_reserve +[`OsString::try_reserve_exact`]: https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.try_reserve_exact +[`PathBuf::try_reserve`]: https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#method.try_reserve +[`PathBuf::try_reserve_exact`]: https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#method.try_reserve_exact +[`Path::try_exists`]: https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.try_exists +[`Ref::filter_map`]: https://doc.rust-lang.org/stable/std/cell/struct.Ref.html#method.filter_map +[`RefMut::filter_map`]: https://doc.rust-lang.org/stable/std/cell/struct.RefMut.html#method.filter_map +[`NonNull::::len`]: https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.len +[`ToOwned::clone_into`]: https://doc.rust-lang.org/stable/std/borrow/trait.ToOwned.html#method.clone_into +[`Ipv6Addr::to_ipv4_mapped`]: https://doc.rust-lang.org/stable/std/net/struct.Ipv6Addr.html#method.to_ipv4_mapped +[`unix::io::AsFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsFd.html +[`unix::io::BorrowedFd<'fd>`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html +[`unix::io::OwnedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.OwnedFd.html +[`windows::io::AsHandle`]: https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsHandle.html +[`windows::io::BorrowedHandle<'handle>`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.BorrowedHandle.html +[`windows::io::OwnedHandle`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedHandle.html +[`windows::io::HandleOrInvalid`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.HandleOrInvalid.html +[`windows::io::HandleOrNull`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.HandleOrNull.html +[`windows::io::InvalidHandleError`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.InvalidHandleError.html +[`windows::io::NullHandleError`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.NullHandleError.html +[`windows::io::AsSocket`]: https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsSocket.html +[`windows::io::BorrowedSocket<'handle>`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.BorrowedSocket.html +[`windows::io::OwnedSocket`]: https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedSocket.html +[`thread::scope`]: https://doc.rust-lang.org/stable/std/thread/fn.scope.html +[`thread::Scope`]: https://doc.rust-lang.org/stable/std/thread/struct.Scope.html +[`thread::ScopedJoinHandle`]: https://doc.rust-lang.org/stable/std/thread/struct.ScopedJoinHandle.html + +[`array::from_ref`]: https://doc.rust-lang.org/stable/std/array/fn.from_ref.html +[`slice::from_ref`]: https://doc.rust-lang.org/stable/std/slice/fn.from_ref.html +[`intrinsics::copy`]: https://doc.rust-lang.org/stable/std/intrinsics/fn.copy.html +[`intrinsics::copy_nonoverlapping`]: https://doc.rust-lang.org/stable/std/intrinsics/fn.copy_nonoverlapping.html +[`<*const T>::copy_to`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_to +[`<*const T>::copy_to_nonoverlapping`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_to_nonoverlapping +[`<*mut T>::copy_to`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_to-1 +[`<*mut T>::copy_to_nonoverlapping`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_to_nonoverlapping-1 +[`<*mut T>::copy_from`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_from +[`<*mut T>::copy_from_nonoverlapping`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.copy_from_nonoverlapping +[`str::from_utf8`]: https://doc.rust-lang.org/stable/std/str/fn.from_utf8.html +[`Utf8Error::error_len`]: https://doc.rust-lang.org/stable/std/str/struct.Utf8Error.html#method.error_len +[`Utf8Error::valid_up_to`]: https://doc.rust-lang.org/stable/std/str/struct.Utf8Error.html#method.valid_up_to +[`Condvar::new`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.new +[`Mutex::new`]: https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.new +[`RwLock::new`]: https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html#method.new + +Version 1.62.1 (2022-07-19) +========================== + +Rust 1.62.1 addresses a few recent regressions in the compiler and standard +library, and also mitigates a CPU vulnerability on Intel SGX. + +* [The compiler fixed unsound function coercions involving `impl Trait` return types.][98608] +* [The compiler fixed an incremental compilation bug with `async fn` lifetimes.][98890] +* [Windows added a fallback for overlapped I/O in synchronous reads and writes.][98950] +* [The `x86_64-fortanix-unknown-sgx` target added a mitigation for the + MMIO stale data vulnerability][98126], advisory [INTEL-SA-00615]. + +[98608]: https://github.com/rust-lang/rust/issues/98608 +[98890]: https://github.com/rust-lang/rust/issues/98890 +[98950]: https://github.com/rust-lang/rust/pull/98950 +[98126]: https://github.com/rust-lang/rust/pull/98126 +[INTEL-SA-00615]: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00615.html + Version 1.62.0 (2022-06-30) ========================== @@ -5,7 +209,7 @@ Language -------- - [Stabilize `#[derive(Default)]` on enums with a `#[default]` variant][94457] -- [Stop validating some checks in dead code after functions with uninhabited return types][93313] +- [Teach flow sensitive checks that visibly uninhabited call expressions never return][93313] - [Fix constants not getting dropped if part of a diverging expression][94775] - [Support unit struct/enum variant in destructuring assignment][95380] - [Remove mutable_borrow_reservation_conflict lint and allow the code pattern][96268] @@ -29,7 +233,6 @@ Compiler Libraries --------- -- [Move `CStr` to libcore, and `CString` to liballoc][94079] - [Windows: Use a pipe relay for chaining pipes][95841] - [Replace Linux Mutex and Condvar with futex based ones.][95035] - [Replace RwLock by a futex based one on Linux][95801] @@ -76,8 +279,11 @@ Compatibility Notes - `cargo test` now passes `--target` to `rustdoc` if the specified target is the same as the host target. [#10594](https://github.com/rust-lang/cargo/pull/10594) +- [rustdoc: doctests are now run on unexported `macro_rules!` macros, matching other private items][96630] - [rustdoc: Remove .woff font files][96279] - [Enforce Copy bounds for repeat elements while considering lifetimes][95819] +- [Windows: Fix potentinal unsoundness by aborting if `File` reads or writes cannot + complete synchronously][95469]. Internal Changes ---------------- @@ -90,7 +296,6 @@ and related tools. [93313]: https://github.com/rust-lang/rust/pull/93313/ [93969]: https://github.com/rust-lang/rust/pull/93969/ -[94079]: https://github.com/rust-lang/rust/pull/94079/ [94206]: https://github.com/rust-lang/rust/pull/94206/ [94457]: https://github.com/rust-lang/rust/pull/94457/ [94775]: https://github.com/rust-lang/rust/pull/94775/ @@ -100,6 +305,7 @@ and related tools. [95372]: https://github.com/rust-lang/rust/pull/95372/ [95380]: https://github.com/rust-lang/rust/pull/95380/ [95431]: https://github.com/rust-lang/rust/pull/95431/ +[95469]: https://github.com/rust-lang/rust/pull/95469/ [95705]: https://github.com/rust-lang/rust/pull/95705/ [95801]: https://github.com/rust-lang/rust/pull/95801/ [95819]: https://github.com/rust-lang/rust/pull/95819/ @@ -111,6 +317,7 @@ and related tools. [96393]: https://github.com/rust-lang/rust/pull/96393/ [96436]: https://github.com/rust-lang/rust/pull/96436/ [96557]: https://github.com/rust-lang/rust/pull/96557/ +[96630]: https://github.com/rust-lang/rust/pull/96630/ [`bool::then_some`]: https://doc.rust-lang.org/stable/std/primitive.bool.html#method.then_some [`f32::total_cmp`]: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.total_cmp diff --git a/src/ci/channel b/src/ci/channel index 65b2df87f7df3..2bf5ad0447d33 100644 --- a/src/ci/channel +++ b/src/ci/channel @@ -1 +1 @@ -beta +stable From e8cf27d5be468505336fc478cff9d5e7eace2f39 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 6 Aug 2022 13:17:40 -0700 Subject: [PATCH 2/6] rustdoc: do not mark the contents of a skipped module as inlined --- src/librustdoc/clean/inline.rs | 37 ++++++++++++++++--- src/librustdoc/clean/mod.rs | 27 ++++++-------- .../rustdoc/auxiliary/issue-100204-aux.rs | 13 +++++++ ...-100204-inline-impl-through-glob-import.rs | 14 +++++++ 4 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 src/test/rustdoc/auxiliary/issue-100204-aux.rs create mode 100644 src/test/rustdoc/issue-100204-inline-impl-through-glob-import.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index d4c38f34b5b11..5a3a8086f125e 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -138,6 +138,7 @@ pub(crate) fn try_inline_glob( cx: &mut DocContext<'_>, res: Res, visited: &mut FxHashSet, + inlined_names: &mut FxHashSet<(ItemType, Symbol)>, ) -> Option> { let did = res.opt_def_id()?; if did.is_local() { @@ -146,8 +147,17 @@ pub(crate) fn try_inline_glob( match res { Res::Def(DefKind::Mod, did) => { - let m = build_module(cx, did, visited); - Some(m.items) + let mut items = build_module_items(cx, did, visited, inlined_names); + items.drain_filter(|item| { + if let Some(name) = item.name { + // If an item with the same type and name already exists, + // it takes priority over the inlined stuff. + !inlined_names.insert((item.type_(), name)) + } else { + false + } + }); + Some(items) } // glob imports on things like enums aren't inlined even for local exports, so just bail _ => None, @@ -517,6 +527,18 @@ fn build_module( did: DefId, visited: &mut FxHashSet, ) -> clean::Module { + let items = build_module_items(cx, did, visited, &mut FxHashSet::default()); + + let span = clean::Span::new(cx.tcx.def_span(did)); + clean::Module { items, span } +} + +fn build_module_items( + cx: &mut DocContext<'_>, + did: DefId, + visited: &mut FxHashSet, + inlined_names: &mut FxHashSet<(ItemType, Symbol)>, +) -> Vec { let mut items = Vec::new(); // If we're re-exporting a re-export it may actually re-export something in @@ -526,7 +548,13 @@ fn build_module( if item.vis.is_public() { let res = item.res.expect_non_local(); if let Some(def_id) = res.mod_def_id() { - if did == def_id || !visited.insert(def_id) { + // If we're inlining a glob import, it's possible to have + // two distinct modules with the same name. We don't want to + // inline it, or mark any of its contents as visited. + if did == def_id + || inlined_names.contains(&(ItemType::Module, item.ident.name)) + || !visited.insert(def_id) + { continue; } } @@ -563,8 +591,7 @@ fn build_module( } } - let span = clean::Span::new(cx.tcx.def_span(did)); - clean::Module { items, span } + items } pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index af9ea315ac3cd..4fd05c7babdf3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -71,7 +71,7 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> { // priority to the not-imported one, so we should, too. items.extend(self.items.iter().flat_map(|(item, renamed)| { // First, lower everything other than imports. - if matches!(item.kind, hir::ItemKind::Use(..)) { + if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { return Vec::new(); } let v = clean_maybe_renamed_item(cx, item, *renamed); @@ -84,20 +84,13 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> { })); items.extend(self.items.iter().flat_map(|(item, renamed)| { // Now we actually lower the imports, skipping everything else. - if !matches!(item.kind, hir::ItemKind::Use(..)) { - return Vec::new(); + if let hir::ItemKind::Use(path, hir::UseKind::Glob) = item.kind { + let name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id())); + clean_use_statement(item, name, path, hir::UseKind::Glob, cx, &mut inserted) + } else { + // skip everything else + Vec::new() } - let mut v = clean_maybe_renamed_item(cx, item, *renamed); - v.drain_filter(|item| { - if let Some(name) = item.name { - // If an item with the same type and name already exists, - // it takes priority over the inlined stuff. - !inserted.insert((item.type_(), name)) - } else { - false - } - }); - v })); // determine if we should display the inner contents or @@ -1992,7 +1985,7 @@ fn clean_maybe_renamed_item<'tcx>( return clean_extern_crate(item, name, orig_name, cx); } ItemKind::Use(path, kind) => { - return clean_use_statement(item, name, path, kind, cx); + return clean_use_statement(item, name, path, kind, cx, &mut FxHashSet::default()); } _ => unreachable!("not yet converted"), }; @@ -2113,6 +2106,7 @@ fn clean_use_statement<'tcx>( path: &hir::Path<'tcx>, kind: hir::UseKind, cx: &mut DocContext<'tcx>, + inlined_names: &mut FxHashSet<(ItemType, Symbol)>, ) -> Vec { // We need this comparison because some imports (for std types for example) // are "inserted" as well but directly by the compiler and they should not be @@ -2177,7 +2171,8 @@ fn clean_use_statement<'tcx>( let inner = if kind == hir::UseKind::Glob { if !denied { let mut visited = FxHashSet::default(); - if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited) { + if let Some(items) = inline::try_inline_glob(cx, path.res, &mut visited, inlined_names) + { return items; } } diff --git a/src/test/rustdoc/auxiliary/issue-100204-aux.rs b/src/test/rustdoc/auxiliary/issue-100204-aux.rs new file mode 100644 index 0000000000000..df1b59069be99 --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-100204-aux.rs @@ -0,0 +1,13 @@ +#![crate_name="first"] + +pub mod prelude { + pub use crate::Bot; +} + +pub struct Bot; + +impl Bot { + pub fn new() -> Bot { + Bot + } +} diff --git a/src/test/rustdoc/issue-100204-inline-impl-through-glob-import.rs b/src/test/rustdoc/issue-100204-inline-impl-through-glob-import.rs new file mode 100644 index 0000000000000..3e20c5c0741ef --- /dev/null +++ b/src/test/rustdoc/issue-100204-inline-impl-through-glob-import.rs @@ -0,0 +1,14 @@ +// aux-build:issue-100204-aux.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name="second"] + +extern crate first; + +pub mod prelude {} + +// @has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +// @has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +#[doc(inline)] +pub use first::*; From 5643d53ae16a1e62c228edc6ed9408e2ec9350f6 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sun, 7 Aug 2022 21:01:27 -0400 Subject: [PATCH 3/6] Move `significant_drop_in_scrutinee` into `nursey` --- src/tools/clippy/clippy_lints/src/lib.register_all.rs | 1 - src/tools/clippy/clippy_lints/src/lib.register_nursery.rs | 1 + src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs | 1 - src/tools/clippy/clippy_lints/src/matches/mod.rs | 2 +- 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/lib.register_all.rs b/src/tools/clippy/clippy_lints/src/lib.register_all.rs index 8a2cfbff953ec..a69f77f220f6c 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_all.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_all.rs @@ -151,7 +151,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(matches::MATCH_STR_CASE_MISMATCH), LintId::of(matches::NEEDLESS_MATCH), LintId::of(matches::REDUNDANT_PATTERN_MATCHING), - LintId::of(matches::SIGNIFICANT_DROP_IN_SCRUTINEE), LintId::of(matches::SINGLE_MATCH), LintId::of(matches::WILDCARD_IN_OR_PATTERNS), LintId::of(mem_replace::MEM_REPLACE_OPTION_WITH_NONE), diff --git a/src/tools/clippy/clippy_lints/src/lib.register_nursery.rs b/src/tools/clippy/clippy_lints/src/lib.register_nursery.rs index 642d629971d90..91210b23afe30 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_nursery.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_nursery.rs @@ -13,6 +13,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![ LintId::of(future_not_send::FUTURE_NOT_SEND), LintId::of(index_refutable_slice::INDEX_REFUTABLE_SLICE), LintId::of(let_if_seq::USELESS_LET_IF_SEQ), + LintId::of(matches::SIGNIFICANT_DROP_IN_SCRUTINEE), LintId::of(methods::ITER_WITH_DRAIN), LintId::of(missing_const_for_fn::MISSING_CONST_FOR_FN), LintId::of(mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL), diff --git a/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs b/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs index 7b13713c36e59..6dc7ad334881e 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs @@ -24,7 +24,6 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec! LintId::of(loops::EMPTY_LOOP), LintId::of(loops::FOR_LOOPS_OVER_FALLIBLES), LintId::of(loops::MUT_RANGE_BOUND), - LintId::of(matches::SIGNIFICANT_DROP_IN_SCRUTINEE), LintId::of(methods::NO_EFFECT_REPLACE), LintId::of(methods::SUSPICIOUS_MAP), LintId::of(mut_key::MUTABLE_KEY_TYPE), diff --git a/src/tools/clippy/clippy_lints/src/matches/mod.rs b/src/tools/clippy/clippy_lints/src/matches/mod.rs index 3e765173fb9f3..03cb1dc36b1c0 100644 --- a/src/tools/clippy/clippy_lints/src/matches/mod.rs +++ b/src/tools/clippy/clippy_lints/src/matches/mod.rs @@ -845,7 +845,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.60.0"] pub SIGNIFICANT_DROP_IN_SCRUTINEE, - suspicious, + nursery, "warns when a temporary of a type with a drop with a significant side-effect might have a surprising lifetime" } From 9d1fd978c25cb11a9b2a7d75c425ca56b34f32aa Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 6 Aug 2022 19:42:52 +0200 Subject: [PATCH 4/6] Avoid ICE in rustdoc. --- src/librustdoc/clean/auto_trait.rs | 12 +++++++----- src/test/rustdoc/fn-bound.rs | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/fn-bound.rs diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index fb178cbd95e7b..7af05191b832c 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -351,9 +351,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { - if let Some(data) = ty_to_fn.get(&ty) { - let (poly_trait, output) = - (data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new)); + if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) { let mut new_path = poly_trait.trait_.clone(); let last_segment = new_path.segments.pop().expect("segments were empty"); @@ -371,8 +369,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { GenericArgs::Parenthesized { inputs, output } => (inputs, output), }; + let output = output.as_ref().cloned().map(Box::new); if old_output.is_some() && old_output != output { - panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, data.1); + panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, output); } let new_params = GenericArgs::Parenthesized { inputs: old_input, output }; @@ -382,7 +381,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .push(PathSegment { name: last_segment.name, args: new_params }); bounds.insert(GenericBound::TraitBound( - PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params }, + PolyTrait { + trait_: new_path, + generic_params: poly_trait.generic_params.clone(), + }, hir::TraitBoundModifier::None, )); } diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs new file mode 100644 index 0000000000000..7b44ee7b4b5bf --- /dev/null +++ b/src/test/rustdoc/fn-bound.rs @@ -0,0 +1,17 @@ +use std::iter::Peekable; + +pub struct Span { + inner: Peekable>, +} + +struct ConditionalIterator { + f: F, +} + +impl Iterator for ConditionalIterator { + type Item = (); + + fn next(&mut self) -> Option { + todo!() + } +} From ca387339e33af5ce1bac78d687e8668dffdfed97 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 8 Aug 2022 21:09:09 +0200 Subject: [PATCH 5/6] Synthetize a trait ref when none is available. --- src/librustdoc/clean/auto_trait.rs | 18 ++++++++++++------ src/test/rustdoc/fn-bound.rs | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 7af05191b832c..5e9f3346af979 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -345,13 +345,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { fn make_final_bounds( &self, ty_to_bounds: FxHashMap>, - ty_to_fn: FxHashMap, Option)>, + ty_to_fn: FxHashMap)>, lifetime_to_bounds: FxHashMap>, ) -> Vec { ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { - if let Some((Some(ref poly_trait), ref output)) = ty_to_fn.get(&ty) { + if let Some((ref poly_trait, ref output)) = ty_to_fn.get(&ty) { let mut new_path = poly_trait.trait_.clone(); let last_segment = new_path.segments.pop().expect("segments were empty"); @@ -470,7 +470,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); let mut ty_to_traits: FxHashMap> = Default::default(); - let mut ty_to_fn: FxHashMap, Option)> = Default::default(); + let mut ty_to_fn: FxHashMap)> = Default::default(); for p in clean_where_predicates { let (orig_p, p) = (p, p.clean(self.cx)); @@ -534,8 +534,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { if is_fn { ty_to_fn .entry(ty.clone()) - .and_modify(|e| *e = (Some(poly_trait.clone()), e.1.clone())) - .or_insert(((Some(poly_trait.clone())), None)); + .and_modify(|e| *e = (poly_trait.clone(), e.1.clone())) + .or_insert(((poly_trait.clone()), None)); ty_to_bounds.entry(ty.clone()).or_default(); } else { @@ -558,7 +558,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .and_modify(|e| { *e = (e.0.clone(), Some(rhs.ty().unwrap().clone())) }) - .or_insert((None, Some(rhs.ty().unwrap().clone()))); + .or_insert(( + PolyTrait { + trait_: trait_.clone(), + generic_params: Vec::new(), + }, + Some(rhs.ty().unwrap().clone()), + )); continue; } diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs index 7b44ee7b4b5bf..d5d5838d37580 100644 --- a/src/test/rustdoc/fn-bound.rs +++ b/src/test/rustdoc/fn-bound.rs @@ -4,10 +4,12 @@ pub struct Span { inner: Peekable>, } -struct ConditionalIterator { +pub struct ConditionalIterator { f: F, } + +// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header in-band"]' 'impl Iterator for ConditionalIterator' impl Iterator for ConditionalIterator { type Item = (); From 7ddc9b7026115a89a59c0e27d2002f828ee1056c Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Mon, 8 Aug 2022 14:09:55 -0700 Subject: [PATCH 6/6] Add regression test comment --- src/test/rustdoc/fn-bound.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/rustdoc/fn-bound.rs b/src/test/rustdoc/fn-bound.rs index d5d5838d37580..4c4ffddc8a648 100644 --- a/src/test/rustdoc/fn-bound.rs +++ b/src/test/rustdoc/fn-bound.rs @@ -1,3 +1,5 @@ +// Regression test for #100143 + use std::iter::Peekable; pub struct Span {