Skip to content

Commit 0f64106

Browse files
KarelPeetersemilio
authored andcommitted
Also implement must-use-type for enums.
1 parent 2c5840f commit 0f64106

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/codegen/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,8 @@ impl CodeGenerator for CompInfo {
20232023
attributes.push(attributes::derives(&derives))
20242024
}
20252025

2026-
if item.annotations().must_use_type() || ctx.must_use_type_by_name(item) {
2026+
if item.annotations().must_use_type() || ctx.must_use_type_by_name(item)
2027+
{
20272028
attributes.push(attributes::must_use());
20282029
}
20292030

@@ -3002,6 +3003,11 @@ impl CodeGenerator for Enum {
30023003
attrs.push(attributes::doc(comment));
30033004
}
30043005

3006+
if item.annotations().must_use_type() || ctx.must_use_type_by_name(item)
3007+
{
3008+
attrs.push(attributes::must_use());
3009+
}
3010+
30053011
if !variation.is_const() {
30063012
let mut derives = derives_of_item(item, ctx);
30073013
// For backwards compat, enums always derive Clone/Eq/PartialEq/Hash, even

src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ where
949949
builder = builder.no_hash(regex);
950950
}
951951
}
952-
952+
953953
if let Some(must_use_type) = matches.values_of("must-use-type") {
954954
for regex in must_use_type {
955955
builder = builder.must_use_type(regex);

0 commit comments

Comments
 (0)