mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Add test for #[must_use] in tuples
This commit is contained in:
@@ -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 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user