Skip to content

Commit

Permalink
Don't trigger unused_result on functions returning empty enums
Browse files Browse the repository at this point in the history
  • Loading branch information
pengowen123 committed Aug 12, 2017
1 parent 0b2c9f0 commit eeb748a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/issue-43806.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit eeb748a

Please sign in to comment.