Skip to content

Commit 68c0ced

Browse files
committed
Add test for #[must_use] in tuples
1 parent a430846 commit 68c0ced

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/librustc_lint/unused.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::hir::def::{Res, DefKind};
22
use rustc::hir::def_id::DefId;
33
use rustc::lint;
4-
use rustc::ty;
4+
use rustc::ty::{self, Ty};
55
use rustc::ty::adjustment;
66
use rustc_data_structures::fx::FxHashMap;
77
use lint::{LateContext, EarlyContext, LintContext, LintArray};
@@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
137137
// Returns whether an error has been emitted (and thus another does not need to be later).
138138
fn check_must_use_ty(
139139
cx: &LateContext<'_, '_>,
140-
ty: ty::Ty<'_>,
140+
ty: Ty<'_>,
141141
span: Span,
142142
) -> bool {
143143
match ty.sty {

src/test/ui/lint/must_use-tuple.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![deny(unused_must_use)]
2+
3+
fn main() {
4+
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` that must be used
5+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: unused `std::result::Result` that must be used
2+
--> $DIR/must_use-tuple.rs:4:5
3+
|
4+
LL | (Ok::<(), ()>(()),);
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/must_use-tuple.rs:1:9
9+
|
10+
LL | #![deny(unused_must_use)]
11+
| ^^^^^^^^^^^^^^^
12+
= note: this `Result` may be an `Err` variant, which should be handled
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)