forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#100031 - GoldsteinE:try-removing-the-field,…
… r=michaelwoerister improve "try ignoring the field" diagnostic Closes rust-lang#95795
- Loading branch information
Showing
6 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// run-pass | ||
|
||
#![allow(dead_code)] | ||
|
||
struct Foo { | ||
foo: i32, | ||
bar: i32, | ||
baz: (), | ||
} | ||
|
||
fn use_foo(x: Foo) -> (i32, i32) { | ||
let Foo { foo, bar, baz } = x; //~ WARNING unused variable: `baz` | ||
//~| help: try ignoring the field | ||
return (foo, bar); | ||
} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/suggestions/dont-try-removing-the-field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
warning: unused variable: `baz` | ||
--> $DIR/dont-try-removing-the-field.rs:12:25 | ||
| | ||
LL | let Foo { foo, bar, baz } = x; | ||
| ^^^ help: try ignoring the field: `baz: _` | ||
| | ||
= note: `#[warn(unused_variables)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// run-pass | ||
|
||
#![allow(dead_code)] | ||
|
||
struct Foo { | ||
foo: i32, | ||
bar: (), | ||
baz: (), | ||
} | ||
|
||
fn use_foo(x: Foo) -> i32 { | ||
let Foo { foo, bar, .. } = x; //~ WARNING unused variable: `bar` | ||
//~| help: try removing the field | ||
return foo; | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
warning: unused variable: `bar` | ||
--> $DIR/try-removing-the-field.rs:12:20 | ||
| | ||
LL | let Foo { foo, bar, .. } = x; | ||
| ^^^- | ||
| | | ||
| help: try removing the field | ||
| | ||
= note: `#[warn(unused_variables)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|