Skip to content

Commit eeb748a

Browse files
committed
Don't trigger unused_result on functions returning empty enums
1 parent 0b2c9f0 commit eeb748a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/librustc_lint/unused.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
148148
let ty_warned = match t.sty {
149149
ty::TyTuple(ref tys, _) if tys.is_empty() => return,
150150
ty::TyNever => return,
151-
ty::TyAdt(def, _) => check_must_use(cx, def.did, s.span, ""),
151+
ty::TyAdt(def, _) => {
152+
if def.variants.is_empty() {
153+
return;
154+
} else {
155+
check_must_use(cx, def.did, s.span, "")
156+
}
157+
},
152158
_ => false,
153159
};
154160

src/test/ui/issue-43806.rs

+7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@
1212

1313
#![deny(unused_results)]
1414

15+
enum Void {}
16+
1517
fn foo() {}
1618

1719
fn bar() -> ! {
1820
loop {}
1921
}
2022

23+
fn baz() -> Void {
24+
loop {}
25+
}
26+
2127
fn qux() {
2228
foo();
2329
bar();
30+
baz();
2431
}
2532

2633
fn main() {}

0 commit comments

Comments
 (0)