-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve code reuse between trans/_match.rs and check_match.rs #15078
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
Conversation
@@ -111,3 +112,11 @@ pub fn simple_identifier<'a>(pat: &'a Pat) -> Option<&'a Path> { | |||
} | |||
} | |||
} | |||
|
|||
pub fn wild() -> Gc<Pat> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's a fn wild()
in middle/check_match.rs
, which is not public and can be consolidated into this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edwardw Thanks, I merged them.
@pnkfelix Can you review? |
@brson I can review, but probably not until tomorrow morning (Eastern TZ). |
} | ||
|
||
type enter_pat<'a> = |Gc<ast::Pat>|: 'a -> Option<Vec<Gc<ast::Pat>>>; | ||
type enter_pat<'a> = |&[Gc<ast::Pat>]|: 'a -> Option<Vec<Gc<ast::Pat>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alpha-rename this type item to enter_pats
(plural).
Okay it looks good to me, or at least does appear to be a plausible refactoring of the code, assuming that there is a good reason that I could not find code analogous to the original reorder-to-struct-def. r=me after the nits regarding the |
@pnkfelix This should be green now. I added a note below that dialogue comment. I think most of it is outdated now but I'll wait with removing it until I've finished the summer cleaning here. :-) |
Oh, to be fair, I also scraped the uniq_str_eq_fn lang item. |
@jakub- hmm that travis failure looks relevant and troubling: "task ' ' failed at 'internal error: entered unreachable code', /home/travis/build/rust-lang/rust/src/test/run-pass/vec-matching-fixed.rs:14" |
The specialization logic for patterns is really the same in both exhaustiveness/reachability checking and codegen.
@pnkfelix Yeah, I've gone a bit too far. It's green now. |
…=pnkfelix I believe there's more commonality to be found there but maybe small steps are better. I'm also in the process of documenting what I can, I will see if I can add it to this PR. It also seems to me that ideally some of this stuff (especially the pattern sanity check) could live as a separate compiler-agnostic module but I understand this may not be the right time (if not the worst) to start the process of modularising rustc.
I believe there's more commonality to be found there but maybe small steps are better. I'm also in the process of documenting what I can, I will see if I can add it to this PR.
It also seems to me that ideally some of this stuff (especially the pattern sanity check) could live as a separate compiler-agnostic module but I understand this may not be the right time (if not the worst) to start the process of modularising rustc.