Skip to content

Commit 0fed9ee

Browse files
committed
enum: Unconditionally generate a return statement in partialeq implementations.
This fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1628754#c7
1 parent a519f1b commit 0fed9ee

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/bindgen/ir/enumeration.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,13 @@ impl Source for Enum {
946946
}
947947
}
948948
if !exhaustive {
949-
write!(out, "default: return true;");
949+
write!(out, "default: break;");
950950
}
951951
out.close_brace(false);
952+
953+
out.new_line();
954+
write!(out, "return true;");
955+
952956
out.close_brace(false);
953957

954958
if config.structure.derive_neq(&self.annotations) {

tests/expectations/cfg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ union C {
124124
#if defined(PLATFORM_UNIX)
125125
case Tag::C5: return c5 == other.c5;
126126
#endif
127-
default: return true;
127+
default: break;
128128
}
129+
return true;
129130
}
130131

131132
bool operator!=(const C& other) const {

tests/expectations/derive-eq.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ union Bar {
8282
case Tag::Bazz: return bazz == aOther.bazz;
8383
case Tag::FooNamed: return foo_named == aOther.foo_named;
8484
case Tag::FooParen: return foo_paren == aOther.foo_paren;
85-
default: return true;
85+
default: break;
8686
}
87+
return true;
8788
}
8889

8990
bool operator!=(const Bar& aOther) const {

0 commit comments

Comments
 (0)