-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// run-pass | ||
// edition:2021 | ||
|
||
enum Variant { | ||
A, | ||
B, //~ WARNING: variant is never constructed: `B` | ||
} | ||
|
||
struct A { | ||
field: Variant, | ||
} | ||
|
||
fn discriminant_is_a_ref() { | ||
let here = A { field: Variant::A }; | ||
let out_ref = &here.field; | ||
|
||
|| match out_ref { //~ WARNING: unused closure that must be used | ||
Variant::A => (), | ||
Variant::B => (), | ||
}; | ||
} | ||
|
||
fn discriminant_is_a_field() { | ||
let here = A { field: Variant::A }; | ||
|
||
|| match here.field { //~ WARNING: unused closure that must be used | ||
Variant::A => (), | ||
Variant::B => (), | ||
}; | ||
} | ||
|
||
fn main() { | ||
discriminant_is_a_ref(); | ||
discriminant_is_a_field(); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/ui/closures/2229_closure_analysis/issue-87097.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,33 @@ | ||
warning: variant is never constructed: `B` | ||
--> $DIR/issue-87097.rs:6:5 | ||
| | ||
LL | B, | ||
| ^ | ||
| | ||
= note: `#[warn(dead_code)]` on by default | ||
|
||
warning: unused closure that must be used | ||
--> $DIR/issue-87097.rs:17:5 | ||
| | ||
LL | / || match out_ref { | ||
LL | | Variant::A => (), | ||
LL | | Variant::B => (), | ||
LL | | }; | ||
| |______^ | ||
| | ||
= note: `#[warn(unused_must_use)]` on by default | ||
= note: closures are lazy and do nothing unless called | ||
|
||
warning: unused closure that must be used | ||
--> $DIR/issue-87097.rs:26:5 | ||
| | ||
LL | / || match here.field { | ||
LL | | Variant::A => (), | ||
LL | | Variant::B => (), | ||
LL | | }; | ||
| |______^ | ||
| | ||
= note: closures are lazy and do nothing unless called | ||
|
||
warning: 3 warnings emitted | ||
|