Skip to content

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

Merged
merged 1 commit into from Jul 3, 2014
Merged

Improve code reuse between trans/_match.rs and check_match.rs #15078

merged 1 commit into from Jul 3, 2014

Conversation

ghost
Copy link

@ghost ghost commented Jun 21, 2014

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.

@@ -111,3 +112,11 @@ pub fn simple_identifier<'a>(pat: &'a Pat) -> Option<&'a Path> {
}
}
}

pub fn wild() -> Gc<Pat> {
Copy link
Contributor

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.

Copy link
Author

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.

@brson
Copy link
Contributor

brson commented Jun 24, 2014

@pnkfelix Can you review?

@pnkfelix
Copy link
Member

@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>>>;
Copy link
Member

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).

@pnkfelix
Copy link
Member

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 enter_pat(s) callback to enter_match have been addressed.

@ghost
Copy link
Author

ghost commented Jun 25, 2014

@pnkfelix Thanks a lot for the review, I'll wait with this until #15186 is sorted.

@ghost
Copy link
Author

ghost commented Jul 3, 2014

@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. :-)

@ghost
Copy link
Author

ghost commented Jul 3, 2014

Oh, to be fair, I also scraped the uniq_str_eq_fn lang item.

@pnkfelix
Copy link
Member

pnkfelix commented Jul 3, 2014

@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.
@ghost
Copy link
Author

ghost commented Jul 3, 2014

@pnkfelix Yeah, I've gone a bit too far. It's green now.

bors added a commit that referenced this pull request Jul 3, 2014
…=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.
@bors bors closed this Jul 3, 2014
@bors bors merged commit 6b6edf4 into rust-lang:master Jul 3, 2014
@ghost ghost deleted the pattern-matching-refactor-vol-2 branch July 13, 2014 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants