Uh oh!
There was an error while loading. Please reload this page.
Fix incorrect pattern warning "unreachable pattern" - #70413
Conversation
rust-highfive
commented
Mar 25, 2020
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Looks good. :)
Please also add the test cases mentioned in the OP in src/test/ui/or-patterns/issue-70413-no-unreachable-pat-and-guard.rs, with #![deny(unreachable_patterns)] and write // check-pass at the top of the file. Also make sure to ./x.py test --stage 1 --bless --pass check src/test/ui to adjust the fallout in UI tests (see also https://rustc-dev-guide.rust-lang.org/tests/adding.html).
You'll also need to run ./x.py fmt to pacify the rustfmt checks in CI.
There was a problem hiding this comment.
Can you leave a note re. the false in this case?
Centril
commented
Mar 25, 2020
r? @varkor |
There was a problem hiding this comment.
Maybe add a comment here as well re. the purpose of this check.
rust-highfive
commented
Mar 26, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
varkor
commented
Mar 26, 2020
@AminArria: could you rebase the three implementation-related commits into one? It's fine to have a separate commit for the tests. This just helps to keep the git history a little cleaner. After that, this all looks good, thanks! |
- Added is_under_guard parameter to _match::is_useful and only add to the matrix if false - Added comments explaining behavior
e9539f0 to
ae7fa30CompareAminArria
commented
Mar 26, 2020
@varkor did the rebase |
varkor
commented
Mar 26, 2020
Thank you! @bors r=Centril,Nadrieril,varkor rollup |
bors
commented
Mar 26, 2020
📌 Commit ae7fa30 has been approved by |
…arning, r=Centril,Nadrieril,varkor Fix incorrect pattern warning "unreachable pattern" Fixesrust-lang#70372 Added `is_under_guard` parameter to `_match::is_useful` and only add it to the matrix if `false` Tested with: ```rust #![feature(or_patterns)] fn main() { match (3,42) { (a,_) | (_,a) if a > 10 => {println!("{}", a)} _ => () } match Some((3,42)) { Some((a, _)) | Some((_, a)) if a > 10 => {println!("{}", a)} _ => () } match Some((3,42)) { Some((a, _) | (_, a)) if a > 10 => {println!("{}", a)} _ => () } } ```
Rollup of 6 pull requests Successful merges: - rust-lang#70384 (Refactor object file handling) - rust-lang#70397 (add 'fn write_u16s' to Memory) - rust-lang#70413 (Fix incorrect pattern warning "unreachable pattern") - rust-lang#70428 (`error_bad_item_kind`: add help text) - rust-lang#70429 (Clean up E0459 explanation) - rust-lang#70437 (Miri float->int casts: be explicit that this is saturating) Failed merges: r? @ghost
Fixes#70372
Added
is_under_guardparameter to_match::is_usefuland only add it to the matrix iffalseTested with: