Add missing multi variant cases
This commit is contained in:
parent
0fa3190394
commit
7d0afaec5a
3 changed files with 66 additions and 0 deletions
|
|
@ -265,6 +265,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
if def.variants.len() > 1 {
|
||||
needs_to_be_read = true;
|
||||
}
|
||||
} else {
|
||||
// If it is not ty::Adt, then it is a MultiVariant
|
||||
needs_to_be_read = true;
|
||||
}
|
||||
}
|
||||
PatKind::Lit(_) | PatKind::Range(..) => {
|
||||
|
|
|
|||
19
src/test/ui/closures/2229_closure_analysis/issue-87988.rs
Normal file
19
src/test/ui/closures/2229_closure_analysis/issue-87988.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// run-pass
|
||||
// edition:2021
|
||||
|
||||
const LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: i32 = 0x01;
|
||||
const LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: i32 = 0x02;
|
||||
|
||||
pub fn hotplug_callback(event: i32) {
|
||||
let _ = || {
|
||||
match event {
|
||||
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED => (),
|
||||
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT => (),
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
hotplug_callback(1);
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// run-pass
|
||||
// edition:2021
|
||||
|
||||
const PATTERN_REF: &str = "Hello World";
|
||||
const NUMBER: i32 = 30;
|
||||
const NUMBER_POINTER: *const i32 = &NUMBER;
|
||||
|
||||
pub fn multi_variant_ref(event: &str) {
|
||||
let _ = || {
|
||||
match event {
|
||||
PATTERN_REF => (),
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
pub fn multi_variant_str(event: String) {
|
||||
let _ = || {
|
||||
match event.as_str() {
|
||||
"hello" => (),
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
pub fn multi_variant_raw_ptr(event: *const i32) {
|
||||
let _ = || {
|
||||
match event {
|
||||
NUMBER_POINTER => (),
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
pub fn multi_variant_char(event: char) {
|
||||
let _ = || {
|
||||
match event {
|
||||
'a' => (),
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue