about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2022-03-17 15:10:25 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2022-03-17 15:10:25 +0200
commitde53232ada5138d44563ee13fb0fc36289449caa (patch)
tree48f3e9fbd1604581324ce851cf49e155c643cd76
parent98143da79924fe2044acae749ffb01923f2f14c6 (diff)
downloadrust-de53232ada5138d44563ee13fb0fc36289449caa.tar.gz
rust-de53232ada5138d44563ee13fb0fc36289449caa.zip
Emit #[must_use] in Generate enum is_variant assist
-rw-r--r--crates/ide_assists/src/handlers/generate_enum_is_method.rs11
-rw-r--r--crates/ide_assists/src/tests/generated.rs1
2 files changed, 12 insertions, 0 deletions
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 c2a6e438b17..863ada79ba4 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 485b807d055..588ec1e114e 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)
     }