Add test for #[must_use] in tuples

This commit is contained in:
varkor 2019-05-23 22:56:31 +01:00
parent bbac81a0f1
commit fd36b5fd52
3 changed files with 22 additions and 2 deletions

View file

@ -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 {

View file

@ -0,0 +1,5 @@
#![deny(unused_must_use)]
fn main() {
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` that must be used
}

View file

@ -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