Skip to content

Commit

Permalink
Unused result warning: "X which must" ↦ "X that must"
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Oct 8, 2018
1 parent 423d810 commit dd0f5e5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ warning: functions generic over types must be mangled
1 | #[no_mangle]
| ------------ help: remove this attribute
2 | / fn foo<T>(t: T) {
3 | |
3 | |
4 | | }
| |_^
|
Expand Down Expand Up @@ -513,7 +513,7 @@ This will produce:
warning: borrow of packed field requires unsafe function or block (error E0133)
--> src/main.rs:11:13
|
11 | let y = &x.data.0;
11 | let y = &x.data.0;
| ^^^^^^^^^
|
= note: #[warn(safe_packed_borrows)] on by default
Expand Down Expand Up @@ -874,7 +874,7 @@ fn main() {
This will produce:

```text
warning: unused `std::result::Result` which must be used
warning: unused `std::result::Result` that must be used
--> src/main.rs:6:5
|
6 | returns_result();
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
//! using it. The compiler will warn us about this kind of behavior:
//!
//! ```text
//! warning: unused result which must be used: iterator adaptors are lazy and
//! warning: unused result that must be used: iterator adaptors are lazy and
//! do nothing unless consumed
//! ```
//!
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {

if let Some(must_use_op) = must_use_op {
cx.span_lint(UNUSED_MUST_USE, expr.span,
&format!("unused {} which must be used", must_use_op));
&format!("unused {} that must be used", must_use_op));
op_warned = true;
}

Expand All @@ -146,7 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool {
for attr in cx.tcx.get_attrs(def_id).iter() {
if attr.check_name("must_use") {
let msg = format!("unused {}`{}` which must be used",
let msg = format!("unused {}`{}` that must be used",
describe_path, cx.tcx.item_path_str(def_id));
let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg);
// check for #[must_use = "..."]
Expand Down Expand Up @@ -233,7 +233,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
.find(|&&(builtin, ty, _)| name == builtin && ty == AttributeType::CrateLevel)
.is_some();

// Has a plugin registered this attribute as one which must be used at
// Has a plugin registered this attribute as one that must be used at
// the crate level?
let plugin_crate = plugin_attributes.iter()
.find(|&&(ref x, t)| name == &**x && AttributeType::CrateLevel == t)
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/fn_must_use.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: unused return value of `need_to_use_this_value` which must be used
warning: unused return value of `need_to_use_this_value` that must be used
--> $DIR/fn_must_use.rs:60:5
|
LL | need_to_use_this_value(); //~ WARN unused return value
Expand All @@ -11,39 +11,39 @@ LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^
= note: it's important

warning: unused return value of `MyStruct::need_to_use_this_method_value` which must be used
warning: unused return value of `MyStruct::need_to_use_this_method_value` that must be used
--> $DIR/fn_must_use.rs:65:5
|
LL | m.need_to_use_this_method_value(); //~ WARN unused return value
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused return value of `EvenNature::is_even` which must be used
warning: unused return value of `EvenNature::is_even` that must be used
--> $DIR/fn_must_use.rs:66:5
|
LL | m.is_even(); // trait method!
| ^^^^^^^^^^^^
|
= note: no side effects

warning: unused return value of `std::cmp::PartialEq::eq` which must be used
warning: unused return value of `std::cmp::PartialEq::eq` that must be used
--> $DIR/fn_must_use.rs:72:5
|
LL | 2.eq(&3); //~ WARN unused return value
| ^^^^^^^^^

warning: unused return value of `std::cmp::PartialEq::eq` which must be used
warning: unused return value of `std::cmp::PartialEq::eq` that must be used
--> $DIR/fn_must_use.rs:73:5
|
LL | m.eq(&n); //~ WARN unused return value
| ^^^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/fn_must_use.rs:76:5
|
LL | 2 == 3; //~ WARN unused comparison
| ^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/fn_must_use.rs:77:5
|
LL | m == n; //~ WARN unused comparison
Expand Down
42 changes: 21 additions & 21 deletions src/test/ui/lint/must-use-ops.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:22:5
|
LL | val == 1;
Expand All @@ -10,121 +10,121 @@ note: lint level defined here
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:23:5
|
LL | val < 1;
| ^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:24:5
|
LL | val <= 1;
| ^^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:25:5
|
LL | val != 1;
| ^^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:26:5
|
LL | val >= 1;
| ^^^^^^^^

warning: unused comparison which must be used
warning: unused comparison that must be used
--> $DIR/must-use-ops.rs:27:5
|
LL | val > 1;
| ^^^^^^^

warning: unused arithmetic operation which must be used
warning: unused arithmetic operation that must be used
--> $DIR/must-use-ops.rs:30:5
|
LL | val + 2;
| ^^^^^^^

warning: unused arithmetic operation which must be used
warning: unused arithmetic operation that must be used
--> $DIR/must-use-ops.rs:31:5
|
LL | val - 2;
| ^^^^^^^

warning: unused arithmetic operation which must be used
warning: unused arithmetic operation that must be used
--> $DIR/must-use-ops.rs:32:5
|
LL | val / 2;
| ^^^^^^^

warning: unused arithmetic operation which must be used
warning: unused arithmetic operation that must be used
--> $DIR/must-use-ops.rs:33:5
|
LL | val * 2;
| ^^^^^^^

warning: unused arithmetic operation which must be used
warning: unused arithmetic operation that must be used
--> $DIR/must-use-ops.rs:34:5
|
LL | val % 2;
| ^^^^^^^

warning: unused logical operation which must be used
warning: unused logical operation that must be used
--> $DIR/must-use-ops.rs:37:5
|
LL | true && true;
| ^^^^^^^^^^^^

warning: unused logical operation which must be used
warning: unused logical operation that must be used
--> $DIR/must-use-ops.rs:38:5
|
LL | false || true;
| ^^^^^^^^^^^^^

warning: unused bitwise operation which must be used
warning: unused bitwise operation that must be used
--> $DIR/must-use-ops.rs:41:5
|
LL | 5 ^ val;
| ^^^^^^^

warning: unused bitwise operation which must be used
warning: unused bitwise operation that must be used
--> $DIR/must-use-ops.rs:42:5
|
LL | 5 & val;
| ^^^^^^^

warning: unused bitwise operation which must be used
warning: unused bitwise operation that must be used
--> $DIR/must-use-ops.rs:43:5
|
LL | 5 | val;
| ^^^^^^^

warning: unused bitwise operation which must be used
warning: unused bitwise operation that must be used
--> $DIR/must-use-ops.rs:44:5
|
LL | 5 << val;
| ^^^^^^^^

warning: unused bitwise operation which must be used
warning: unused bitwise operation that must be used
--> $DIR/must-use-ops.rs:45:5
|
LL | 5 >> val;
| ^^^^^^^^

warning: unused unary operation which must be used
warning: unused unary operation that must be used
--> $DIR/must-use-ops.rs:48:5
|
LL | !val;
| ^^^^

warning: unused unary operation which must be used
warning: unused unary operation that must be used
--> $DIR/must-use-ops.rs:49:5
|
LL | -val;
| ^^^^

warning: unused unary operation which must be used
warning: unused unary operation that must be used
--> $DIR/must-use-ops.rs:50:5
|
LL | *val_pointer;
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/unused/unused-result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fn qux() -> MustUseMsg { return foo::<MustUseMsg>(); }
#[allow(unused_results)]
fn test() {
foo::<isize>();
foo::<MustUse>(); //~ ERROR: unused `MustUse` which must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` which must be used
foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
//~^ NOTE: some message
}

Expand All @@ -42,8 +42,8 @@ fn test2() {

fn main() {
foo::<isize>(); //~ ERROR: unused result
foo::<MustUse>(); //~ ERROR: unused `MustUse` which must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` which must be used
foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
//~^ NOTE: some message

let _ = foo::<isize>();
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/unused/unused-result.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: unused `MustUse` which must be used
error: unused `MustUse` that must be used
--> $DIR/unused-result.rs:31:5
|
LL | foo::<MustUse>(); //~ ERROR: unused `MustUse` which must be used
LL | foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand All @@ -10,10 +10,10 @@ note: lint level defined here
LL | #![deny(unused_results, unused_must_use)]
| ^^^^^^^^^^^^^^^

error: unused `MustUseMsg` which must be used
error: unused `MustUseMsg` that must be used
--> $DIR/unused-result.rs:32:5
|
LL | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` which must be used
LL | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
| ^^^^^^^^^^^^^^^^^^^^
|
= note: some message
Expand All @@ -30,16 +30,16 @@ note: lint level defined here
LL | #![deny(unused_results, unused_must_use)]
| ^^^^^^^^^^^^^^

error: unused `MustUse` which must be used
error: unused `MustUse` that must be used
--> $DIR/unused-result.rs:45:5
|
LL | foo::<MustUse>(); //~ ERROR: unused `MustUse` which must be used
LL | foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
| ^^^^^^^^^^^^^^^^^

error: unused `MustUseMsg` which must be used
error: unused `MustUseMsg` that must be used
--> $DIR/unused-result.rs:46:5
|
LL | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` which must be used
LL | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
| ^^^^^^^^^^^^^^^^^^^^
|
= note: some message
Expand Down

0 comments on commit dd0f5e5

Please sign in to comment.