Skip to content
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

Pass edition flags to compiler from rustdoc as expected #52385

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

GuillaumeGomez
Copy link
Member

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 14, 2018
@QuietMisdreavus
Copy link
Member

I'm surprised that setting the edition in the session options didn't work:

rust/src/librustdoc/test.rs

Lines 214 to 233 in 3d5753f

let sessopts = config::Options {
maybe_sysroot: maybe_sysroot.or_else(
|| Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
search_paths: libs,
crate_types: vec![config::CrateTypeExecutable],
output_types: outputs,
externs,
cg: config::CodegenOptions {
prefer_dynamic: true,
linker,
..cg
},
test: as_test_harness,
unstable_features: UnstableFeatures::from_environment(),
debugging_opts: config::DebuggingOptions {
..config::basic_debugging_options()
},
edition,
..config::basic_options().clone()
};

What does this extra call do that that doesn't? Do we need to add this to our compilation runs for building docs?

@GuillaumeGomez
Copy link
Member Author

It sets the syntax parser edition. The important here being that it's done inside rustc_driver::in_rustc_thread.

@QuietMisdreavus
Copy link
Member

Right, but those session options are created before any parsing or compilation work is done. run_test is called (well, a closure created that calls it) inside that same in_rustc_thread. If the test runner is taking that closure and running it inside a different context, then there may be another problem at hand.

Either way, if it didn't work before and this makes it work, then i won't fight it. I'm just concerned that there seems to be more than one way to set the edition, and the most obvious of them doesn't work.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 16, 2018

📌 Commit 65e6b2b has been approved by QuietMisdreavus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 16, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Jul 17, 2018
…er, r=QuietMisdreavus

Pass edition flags to compiler from rustdoc as expected

Fixes rust-lang#52357.
bors added a commit that referenced this pull request Jul 17, 2018
Rollup of 9 pull requests

Successful merges:

 - #52286 (Deny bare trait objects in src/librustc_errors)
 - #52306 (Reduce the number of clone()s needed in obligation_forest)
 - #52338 (update miri)
 - #52385 (Pass edition flags to compiler from rustdoc as expected)
 - #52392 (AsRef doc wording tweaks)
 - #52430 (update nomicon)
 - #52434 (Enable incremental independent of stage)
 - #52435 (Calculate the exact capacity for 2 HashMaps)
 - #52446 (Block beta if clippy breaks.)

r? @ghost
@bors bors merged commit 65e6b2b into rust-lang:master Jul 17, 2018
@GuillaumeGomez GuillaumeGomez deleted the pass-edition-to-parser branch July 17, 2018 22:13
kennytm added a commit to kennytm/rust that referenced this pull request Aug 14, 2018
…=estebank

driver: set the syntax edition in phase 1

Fixes rust-lang#53203

It seems the way libsyntax handles the desired edition is to use a global, set via `syntax_pos::hygiene::set_default_edition`. Right now, this is set in the driver in `run_compiler`, which is the entry point for running the compiler all the way through to emitting files. Since rustdoc doesn't use this function, it wasn't properly setting this global. (When initially setting up editions in rustdoc, i'd assumed that setting `sessopts.edition` would have done this... `>_>`) This was "fixed" for doctests in rust-lang#52385, but rather than patching in a call to `set_default_edition` in all the places rustdoc sets up the compiler, i've instead moved the call in the driver to be farther in the process. This means that any use of `phase_1_parse_input` with the right session options will have the edition properly set without having to also remember to set libsyntax up separately.

r? @rust-lang/compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants