Skip to content

Commit

Permalink
Add test for #[must_use] in tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Jun 3, 2019
1 parent bbac81a commit fd36b5f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_lint/unused.rs
@@ -1,7 +1,7 @@
use rustc::hir::def::{Res, DefKind};
use rustc::hir::def_id::DefId;
use rustc::lint;
use rustc::ty;
use rustc::ty::{self, Ty};
use rustc::ty::adjustment;
use rustc_data_structures::fx::FxHashMap;
use lint::{LateContext, EarlyContext, LintContext, LintArray};
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
// Returns whether an error has been emitted (and thus another does not need to be later).
fn check_must_use_ty(
cx: &LateContext<'_, '_>,
ty: ty::Ty<'_>,
ty: Ty<'_>,
span: Span,
) -> bool {
match ty.sty {
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/lint/must_use-tuple.rs
@@ -0,0 +1,5 @@
#![deny(unused_must_use)]

fn main() {
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` that must be used
}
15 changes: 15 additions & 0 deletions src/test/ui/lint/must_use-tuple.stderr
@@ -0,0 +1,15 @@
error: unused `std::result::Result` that must be used
--> $DIR/must_use-tuple.rs:4:5
|
LL | (Ok::<(), ()>(()),);
| ^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/must_use-tuple.rs:1:9
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
= note: this `Result` may be an `Err` variant, which should be handled

error: aborting due to previous error

0 comments on commit fd36b5f

Please sign in to comment.