Don't trigger unused_result on functions returning empty enums
This commit is contained in:
parent
0b2c9f03ef
commit
eeb748aa12
2 changed files with 14 additions and 1 deletions
|
|
@ -148,7 +148,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||
let ty_warned = match t.sty {
|
||||
ty::TyTuple(ref tys, _) if tys.is_empty() => return,
|
||||
ty::TyNever => return,
|
||||
ty::TyAdt(def, _) => check_must_use(cx, def.did, s.span, ""),
|
||||
ty::TyAdt(def, _) => {
|
||||
if def.variants.is_empty() {
|
||||
return;
|
||||
} else {
|
||||
check_must_use(cx, def.did, s.span, "")
|
||||
}
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,15 +12,22 @@
|
|||
|
||||
#![deny(unused_results)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
fn foo() {}
|
||||
|
||||
fn bar() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn baz() -> Void {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn qux() {
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue