-
Notifications
You must be signed in to change notification settings - Fork 13.5k
RFC2229 Add missing edge case #87996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering what cases might be missing here -- one silly example might be matching on a constant of type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not too sure either. I am going to import all the match test cases that are here https://github.com/rust-lang/rust/tree/master/src/test/ui/match and then convert them into closure test cases and see if I found anything new |
||
} | ||
} | ||
PatKind::Lit(_) | PatKind::Range(..) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
Uh oh!
There was an error while loading. Please reload this page.