Skip to content
Permalink
Browse files

Add test for #[must_use] in tuples

  • Loading branch information...
varkor committed May 23, 2019
1 parent bbac81a commit fd36b5fd52003d3c3b246c8fb9fb669c5f0f68b0
Showing with 22 additions and 2 deletions.
  1. +2 −2 src/librustc_lint/unused.rs
  2. +5 −0 src/test/ui/lint/must_use-tuple.rs
  3. +15 −0 src/test/ui/lint/must_use-tuple.stderr
@@ -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};
@@ -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 {
@@ -0,0 +1,5 @@
#![deny(unused_must_use)]

fn main() {
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` that must be used
}
@@ -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.
You can’t perform that action at this time.