From de53232ada5138d44563ee13fb0fc36289449caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 17 Mar 2022 15:10:25 +0200 Subject: [PATCH] Emit #[must_use] in Generate enum is_variant assist --- .../src/handlers/generate_enum_is_method.rs | 11 +++++++++++ crates/ide_assists/src/tests/generated.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/crates/ide_assists/src/handlers/generate_enum_is_method.rs b/crates/ide_assists/src/handlers/generate_enum_is_method.rs index c2a6e438b1..863ada79ba 100644 --- a/crates/ide_assists/src/handlers/generate_enum_is_method.rs +++ b/crates/ide_assists/src/handlers/generate_enum_is_method.rs @@ -30,6 +30,7 @@ use crate::{ // /// Returns `true` if the version is [`Minor`]. // /// // /// [`Minor`]: Version::Minor +// #[must_use] // fn is_minor(&self) -> bool { // matches!(self, Self::Minor) // } @@ -63,6 +64,7 @@ pub(crate) fn generate_enum_is_method(acc: &mut Assists, ctx: &AssistContext) -> " /// Returns `true` if the {} is [`{variant}`]. /// /// [`{variant}`]: {}::{variant} + #[must_use] {}fn {}(&self) -> bool {{ matches!(self, Self::{variant}{}) }}", @@ -105,6 +107,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor) } @@ -151,6 +154,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor(..)) } @@ -178,6 +182,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor { .. }) } @@ -197,6 +202,7 @@ impl Variant { /// Returns `true` if the variant is [`Undefined`]. /// /// [`Undefined`]: Variant::Undefined + #[must_use] fn is_undefined(&self) -> bool { matches!(self, Self::Undefined) } @@ -224,6 +230,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] pub(crate) fn is_minor(&self) -> bool { matches!(self, Self::Minor) } @@ -246,6 +253,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor) } @@ -260,6 +268,7 @@ impl Variant { /// Returns `true` if the variant is [`Minor`]. /// /// [`Minor`]: Variant::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor) } @@ -267,6 +276,7 @@ impl Variant { /// Returns `true` if the variant is [`Major`]. /// /// [`Major`]: Variant::Major + #[must_use] fn is_major(&self) -> bool { matches!(self, Self::Major) } @@ -294,6 +304,7 @@ impl GeneratorState { /// Returns `true` if the generator state is [`Complete`]. /// /// [`Complete`]: GeneratorState::Complete + #[must_use] fn is_complete(&self) -> bool { matches!(self, Self::Complete) } diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 485b807d05..588ec1e114 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -922,6 +922,7 @@ impl Version { /// Returns `true` if the version is [`Minor`]. /// /// [`Minor`]: Version::Minor + #[must_use] fn is_minor(&self) -> bool { matches!(self, Self::Minor) }