mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Add test for #[must_use] in tuples
This commit is contained in:
parent
bbac81a0f1
commit
fd36b5fd52
@ -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 {
|
||||
|
5
src/test/ui/lint/must_use-tuple.rs
Normal file
5
src/test/ui/lint/must_use-tuple.rs
Normal file
@ -0,0 +1,5 @@
|
||||
#![deny(unused_must_use)]
|
||||
|
||||
fn main() {
|
||||
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` that must be used
|
||||
}
|
15
src/test/ui/lint/must_use-tuple.stderr
Normal file
15
src/test/ui/lint/must_use-tuple.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user