Skip to content

Refactor compilation to make it easier to use for tools #21876

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 2 commits into from
Feb 9, 2015

Conversation

nrc
Copy link
Member

@nrc nrc commented Feb 2, 2015

This allows people to write tools which are drop-in replacements for rustc by implementing CompilerCalls and three lines of code, rather than having to copy+paste a bunch of args parsing code.

r? @alexcrichton

// It is somewhat unfortunate that this is hardwired in - this is forced by
// the fact that pretty_print_input requires the session by value.
let pretty = callbacks.parse_pretty(&sess, &matches);
match pretty.into_iter().next() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is strange.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this can just be match pretty { can't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, didn't try.

@huonw
Copy link
Member

huonw commented Feb 2, 2015

If I'm calling into the compiler externally to use the analysis passes, will I have to duplicate the RustcDefaultCalls handling after this patch even if I just want to override a single field of the controller? E.g. https://github.com/huonw/unsafe_ls/blob/f894e0cedfe2e872a8d4169adca0eb0091b2bf27/src/unsafe_ls.rs#L183-L187

@nrc
Copy link
Member Author

nrc commented Feb 3, 2015

I envisioned that you would embed a RustcDefaultCalls instance in your own implementation of CompilerCalls and delegate the methods you wanted to. That is why RustcDefaultCalls is public. I couldn't come up with a better idea than that for doing this easily.

@nrc nrc force-pushed the driver-args branch 2 times, most recently from a3010d6 to fc83535 Compare February 3, 2015 01:20
@nrc nrc assigned huonw and unassigned alexcrichton Feb 3, 2015
@nrc
Copy link
Member Author

nrc commented Feb 3, 2015

@huon points addressed, ready for re-review

@nrc nrc force-pushed the driver-args branch 2 times, most recently from a19a9ca to 909ae05 Compare February 5, 2015 20:45
@nrc
Copy link
Member Author

nrc commented Feb 5, 2015

Rebased again.

@huonw ping for re-review

fn build_controller<'a>(sess: &Session) -> CompileController<'a> {
let mut control = CompileController::basic();
impl Compilation {
pub fn and_then<F: Fn() -> Compilation>(self, next: F) -> Compilation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be FnOnce.

@huonw
Copy link
Member

huonw commented Feb 8, 2015

r=me with a rebase and the FnOnce comment.

@nrc
Copy link
Member Author

nrc commented Feb 8, 2015

@bors r=huonw 8cc78b74fe0053cd42e840b4b39db3ffef5bd764

@bors
Copy link
Collaborator

bors commented Feb 8, 2015

⌛ Testing commit 8cc78b7 with merge 310dfd1...

@bors
Copy link
Collaborator

bors commented Feb 8, 2015

💔 Test failed - auto-linux-64-x-android-t

@nrc
Copy link
Member Author

nrc commented Feb 9, 2015

@bors r=huonw f0e1e09

@bors
Copy link
Collaborator

bors commented Feb 9, 2015

⌛ Testing commit f0e1e09 with merge 5cbf822...

@bors
Copy link
Collaborator

bors commented Feb 9, 2015

💔 Test failed - auto-win-64-nopt-t

@alexcrichton
Copy link
Member

@bors: retry

@bors
Copy link
Collaborator

bors commented Feb 9, 2015

⌛ Testing commit f0e1e09 with merge 134e00b...

bors added a commit that referenced this pull request Feb 9, 2015
This allows people to write tools which are drop-in replacements for rustc by implementing `CompilerCalls` and three lines of code, rather than having to copy+paste a bunch of args parsing code.

r? @alexcrichton
@bors
Copy link
Collaborator

bors commented Feb 9, 2015

@bors bors merged commit f0e1e09 into rust-lang:master Feb 9, 2015
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