From 8cf8beff6be9d1996a545b81a7ca00f7f6047e58 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Mon, 17 Jan 2022 12:25:38 +0100 Subject: [PATCH 1/2] Move `return_self_not_must_use` to `pedantic` --- src/tools/clippy/clippy_lints/src/lib.register_all.rs | 1 - src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs | 1 + .../clippy/clippy_lints/src/lib.register_suspicious.rs | 1 - .../clippy/clippy_lints/src/return_self_not_must_use.rs | 2 +- src/tools/clippy/tests/ui/return_self_not_must_use.rs | 1 + src/tools/clippy/tests/ui/return_self_not_must_use.stderr | 6 +++--- 6 files changed, 6 insertions(+), 6 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 944411087e951..11ed97d3e1922 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_all.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_all.rs @@ -247,7 +247,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(reference::REF_IN_DEREF), LintId::of(regex::INVALID_REGEX), LintId::of(repeat_once::REPEAT_ONCE), - LintId::of(return_self_not_must_use::RETURN_SELF_NOT_MUST_USE), LintId::of(returns::LET_AND_RETURN), LintId::of(returns::NEEDLESS_RETURN), LintId::of(self_assignment::SELF_ASSIGNMENT), diff --git a/src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs b/src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs index 70a4a62437890..a82ec73935ff3 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs @@ -80,6 +80,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![ LintId::of(ranges::RANGE_PLUS_ONE), LintId::of(redundant_else::REDUNDANT_ELSE), LintId::of(ref_option_ref::REF_OPTION_REF), + LintId::of(return_self_not_must_use::RETURN_SELF_NOT_MUST_USE), LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED), LintId::of(strings::STRING_ADD_ASSIGN), LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS), 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 8594338ffa5ab..10f8ae4b7f7fc 100644 --- a/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs +++ b/src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs @@ -16,7 +16,6 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec! LintId::of(methods::SUSPICIOUS_MAP), LintId::of(mut_key::MUTABLE_KEY_TYPE), LintId::of(octal_escapes::OCTAL_ESCAPES), - LintId::of(return_self_not_must_use::RETURN_SELF_NOT_MUST_USE), LintId::of(suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL), LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL), ]) diff --git a/src/tools/clippy/clippy_lints/src/return_self_not_must_use.rs b/src/tools/clippy/clippy_lints/src/return_self_not_must_use.rs index b57ec96bc7e6d..2be71c7e9730d 100644 --- a/src/tools/clippy/clippy_lints/src/return_self_not_must_use.rs +++ b/src/tools/clippy/clippy_lints/src/return_self_not_must_use.rs @@ -38,7 +38,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.59.0"] pub RETURN_SELF_NOT_MUST_USE, - suspicious, + pedantic, "missing `#[must_use]` annotation on a method returning `Self`" } diff --git a/src/tools/clippy/tests/ui/return_self_not_must_use.rs b/src/tools/clippy/tests/ui/return_self_not_must_use.rs index 7dd5742dae9f2..9b33ad6d3f6b3 100644 --- a/src/tools/clippy/tests/ui/return_self_not_must_use.rs +++ b/src/tools/clippy/tests/ui/return_self_not_must_use.rs @@ -1,4 +1,5 @@ #![crate_type = "lib"] +#![warn(clippy::return_self_not_must_use)] #[derive(Clone)] pub struct Bar; diff --git a/src/tools/clippy/tests/ui/return_self_not_must_use.stderr b/src/tools/clippy/tests/ui/return_self_not_must_use.stderr index 3793a5559ba55..63a365fe080b6 100644 --- a/src/tools/clippy/tests/ui/return_self_not_must_use.stderr +++ b/src/tools/clippy/tests/ui/return_self_not_must_use.stderr @@ -1,5 +1,5 @@ error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:7:5 + --> $DIR/return_self_not_must_use.rs:8:5 | LL | fn what(&self) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn what(&self) -> Self; = note: `-D clippy::return-self-not-must-use` implied by `-D warnings` error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:17:5 + --> $DIR/return_self_not_must_use.rs:18:5 | LL | / pub fn foo(&self) -> Self { LL | | Self @@ -15,7 +15,7 @@ LL | | } | |_____^ error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:20:5 + --> $DIR/return_self_not_must_use.rs:21:5 | LL | / pub fn bar(self) -> Self { LL | | self From 6bd1b5f2f0d894a2f358701c6254dc459d507ef2 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 22 Feb 2022 15:35:22 -0500 Subject: [PATCH 2/2] Note unreachable behavior --- RELEASES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASES.md b/RELEASES.md index 2bf212123d43a..37b41d264229d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -101,6 +101,7 @@ Compatibility Notes - [Weaken guarantee around advancing underlying iterators in zip][83791] - [Make split_inclusive() on an empty slice yield an empty output][89825] - [Update std::env::temp_dir to use GetTempPath2 on Windows when available.][89999] +- [unreachable! was updated to match other formatting macro behavior on Rust 2021][92137] Internal Changes ----------------