Commit Graph

368 Commits

Author SHA1 Message Date
Bastien Orivel c863049225 Fix tidy 2018-06-20 19:28:27 +02:00
Bastien Orivel ae9a27185e Replace tempdir by tempfile in librustdoc 2018-06-20 19:28:27 +02:00
Vadim Petrochenkov 189c0a1297 Use `Ident`s for fields in HIR 2018-05-26 14:41:58 +03:00
Irina Popa b63d7e2b1c Rename trans to codegen everywhere. 2018-05-17 15:08:30 +03:00
John Kåre Alsaker 022dff47e3 Add a Rayon thread pool 2018-05-13 01:28:20 +02:00
bors 9af69fe232 Auto merge of #50080 - klnusbaum:edition_49591, r=Manishearth
add --edition option

This adds an official `edition` flag to the rust compiler
2018-04-21 05:28:21 +00:00
Kurtis Nusbaum c1d8aa829c fix some small compile errors 2018-04-20 14:47:23 -07:00
Alex Crichton ca79ba300a Tweak some stabilizations in libstd
This commit tweaks a few stable APIs in the `beta` branch before they hit
stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were
deleted (added in #49381, issue at #49657). The `and_modify` APIs added
in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure.

Closes #49581
Closes #49657
2018-04-19 16:53:12 -07:00
QuietMisdreavus 1a0d7a8207 add -C parameter to rustdoc 2018-04-13 16:07:12 -05:00
QuietMisdreavus 43301e55a1 add target features when extracting and running doctests 2018-04-10 19:22:11 -05:00
QuietMisdreavus 8145a77a28 suppress the default allow(unused) under --display-warnings 2018-04-02 14:37:16 -05:00
Mark Simulacrum 5d3916d566
Rollup merge of #49451 - QuietMisdreavus:epoch-doctests, r=GuillaumeGomez
rustdoc: add an --edition flag to compile docs/doctests with a certain edition

To correspond with the 2018 edition, this adds a (currently unstable) `--edition` flag to rustdoc that makes it compile crates and doctests with the given edition. Once this lands, Cargo should be updated to pass this flag when the edition configuration option is given.
2018-04-01 18:04:54 +02:00
QuietMisdreavus d9bf37a5ae use --edition for doctests, rather than just the crate 2018-03-28 13:54:05 +02:00
QuietMisdreavus 7f548bc8c6 add --edition flag to rustdoc 2018-03-27 16:31:19 +02:00
boats 5fc7e0a2ba
Remove unnecessary trait import. 2018-03-26 07:41:45 -07:00
kennytm 95967c7c72
Rollup merge of #49188 - memoryleak47:macro_use_doctest, r=QuietMisdreavus
Put `#[macro_use] extern crate <crate>` before fn main() in doctests

Closes #49174.
2018-03-22 22:43:41 +08:00
memoryleak47 25c8210c01 Put `#[macro_use] extern crate <crate>` before fn main() in doctests 2018-03-19 23:48:02 +01:00
Guillaume Gomez 7786f70437 Add warning for invalid start of code blocks in rustdoc 2018-03-18 20:34:49 +01:00
John Kåre Alsaker cbdf4ec03e Remove syntax and syntax_pos thread locals 2018-03-14 11:56:01 +01:00
Michael Woerister 542bc75dea Turn features() into a query. 2018-03-05 11:05:01 +01:00
John Kåre Alsaker b74e97cf42 Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00
Guillaume Gomez f0343cbd1f
Rollup merge of #48106 - QuietMisdreavus:teleporting-crates, r=GuillaumeGomez
rustdoc: move manual "extern crate" statements outside automatic "fn main"s in doctests

Gated on https://github.com/rust-lang/rust/pull/48095 - I based the branch atop that so i could show off the change in one of its tests, the actual change in this PR is just the last commit

There are a handful of unfortunate assumptions in the way rustdoc processes `extern crate` statements in doctests:

1. In the absence of an `extern crate` statement in the test, if the test also uses the local crate name, it will automatically insert an `extern crate cratename;` statement into the test.
2. If the doctest *does* include an `extern crate` statement, rustdoc will not automatically insert one, on the assumption that doing so would introduce a duplicate import.
3. If a doctest does not have the substring `fn main` outside a comment, rustdoc will wrap the whole doctest in a generated `fn main` so it can be compiled.

In short, whenever you write a doctest like this...

```rust
//! extern crate my_crate;
//! my_crate::some_cool_thing();
```

...rustdoc will turn it into (something like) this:

```rust
fn main() {
extern crate my_crate;
my_crate::some_cool_thing();
}
```

This creates issues when compiled, because now `my_crate` isn't even properly in scope! This forces people who want to have multiple crates in their doctests (or an explicit `extern crate` statement) to also manually include their own `fn main`, so rustdoc doesn't put their imports in the wrong place.

This PR just taps into another processing step rustdoc does to doctests: Whenever you add an `#![inner_attribute]` to the beginning of a doctest, rustdoc will actually splice those out and put it before the generated `fn main`. Now, we can just do the same with `extern crate`s at the beginning, too, and get a much nicer experience.

Now, the above example will be converted into this:

```rust
extern crate my_crate;
fn main() {
my_crate::some_cool_thing();
}
```
2018-02-21 16:29:47 +01:00
Guillaume Gomez b7791b0c7e
Rollup merge of #48274 - GuillaumeGomez:remove-hoedown, r=QuietMisdreavus
Remove hoedown from rustdoc

Finally the time has come!

r? @QuietMisdreavus
2018-02-18 13:20:59 +01:00
QuietMisdreavus b3d6597855 move manual "extern crate" statements outside auto "fn main" in doctests 2018-02-17 16:51:39 -06:00
Guillaume Gomez 5bd5bc3f21 Remove hoedown from rustdoc
Is it really time? Have our months, no, *years* of suffering come to an end? Are we finally able to cast off the pall of Hoedown? The weight which has dragged us down for so long?

-----

So, timeline for those who need to catch up:

* Way back in December 2016, [we decided we wanted to switch out the markdown renderer](https://github.com/rust-lang/rust/issues/38400). However, this was put on hold because the build system at the time made it difficult to pull in dependencies from crates.io.
* A few months later, in March 2017, [the first PR was done, to switch out the renderers entirely](https://github.com/rust-lang/rust/pull/40338). The PR itself was fraught with CI and build system issues, but eventually landed.
* However, not all was well in the Rustdoc world. During the PR and shortly after, we noticed [some differences in the way the two parsers handled some things](https://github.com/rust-lang/rust/issues/40912), and some of these differences were major enough to break the docs for some crates.
* A couple weeks afterward, [Hoedown was put back in](https://github.com/rust-lang/rust/pull/41290), at this point just to catch tests that Pulldown was "spuriously" running. This would at least provide some warning about spurious tests, rather than just breaking spontaneously.
* However, the problems had created enough noise by this point that just a few days after that, [Hoedown was switched back to the default](https://github.com/rust-lang/rust/pull/41431) while we came up with a solution for properly warning about the differences.
* That solution came a few weeks later, [as a series of warnings when the HTML emitted by the two parsers was semantically different](https://github.com/rust-lang/rust/pull/41991). But that came at a cost, as now rustdoc needed proc-macro support (the new crate needed some custom derives farther down its dependency tree), and the build system was not equipped to handle it at the time. It was worked on for three months as the issue stumped more and more people.
  * In that time, [bootstrap was completely reworked](https://github.com/rust-lang/rust/pull/43059) to change how it ordered compilation, and [the method by which it built rustdoc would change](https://github.com/rust-lang/rust/pull/43482), as well. This allowed it to only be built after stage1, when proc-macros would be available, allowing the "rendering differences" PR to finally land.
  * The warnings were not perfect, and revealed a few [spurious](https://github.com/rust-lang/rust/pull/44368) [differences](https://github.com/rust-lang/rust/pull/45421) between how we handled the renderers.
  * Once these were handled, [we flipped the switch to turn on the "rendering difference" warnings all the time](https://github.com/rust-lang/rust/pull/45324), in October 2017. This began the "warning cycle" for this change, and landed in stable in 1.23, on 2018-01-04.
  * Once those warnings hit stable, and after a couple weeks of seeing whether we would get any more reports than what we got from sitting on nightly/beta, [we switched the renderers](https://github.com/rust-lang/rust/pull/47398), making Pulldown the default but still offering the option to use Hoedown.

And that brings us to the present. We haven't received more new issues from this in the meantime, and the "switch by default" is now on beta. Our reasoning is that, at this point, anyone who would have been affected by this has run into it already.
2018-02-16 23:17:15 +01:00
QuietMisdreavus 70b5c458e6 add tests for the doctest construction functionality 2018-02-09 10:40:27 -06:00
QuietMisdreavus a58d1b5346 trim the body of doctests after partitioning 2018-02-09 09:24:23 -06:00
bors 560a2f4faf Auto merge of #45752 - estebank:highlight-primary, r=nikomatsakis
Highlight code on diagnostics when underlined

Highlight the label's span with the respective color:

<img width="692" alt="" src="https://user-images.githubusercontent.com/1606434/32411026-a1842482-c18d-11e7-9933-6510eefbad19.png">

Fix #42112.
2018-01-31 07:53:57 +00:00
Esteban Küber 08287c1e26 Toggle span highlighting on `-Zteach` 2018-01-29 08:59:15 -08:00
Alex Crichton 884715c654 rustc: Load the `rustc_trans` crate at runtime
Building on the work of # 45684 this commit updates the compiler to
unconditionally load the `rustc_trans` crate at runtime instead of linking to it
at compile time. The end goal of this work is to implement # 46819 where rustc
will have multiple backends available to it to load.

This commit starts off by removing the `extern crate rustc_trans` from the
driver. This involved moving some miscellaneous functionality into the
`TransCrate` trait and also required an implementation of how to locate and load
the trans backend. This ended up being a little tricky because the sysroot isn't
always the right location (for example `--sysroot` arguments) so some extra code
was added as well to probe a directory relative to the current dll (the
rustc_driver dll).

Rustbuild has been updated accordingly as well to have a separate compilation
invocation for the `rustc_trans` crate and assembly it accordingly into the
sysroot. Finally, the distribution logic for the `rustc` package was also
updated to slurp up the trans backends folder.

A number of assorted fallout changes were included here as well to ensure tests
pass and such, and they should all be commented inline.
2018-01-27 19:16:21 -08:00
bjorn3 74c92c5562 Allow runtime switching between trans backends 2018-01-19 20:27:10 +01:00
Manish Goregaokar 730679685e Use correct line offsets for doctests (fixes #45868) 2018-01-10 10:10:34 +05:30
kennytm 0ee069c70a Rollup merge of #46814 - varkor:contrib-7, r=alexcrichton
Prevent rustc overwriting input files

If rustc is invoked on a file that would be overwritten by the
compilation, the compilation now fails, to avoid accidental loss. This
resolves #13019. Kudos to @estebank, whose patch I finished off.
2017-12-22 02:50:49 +08:00
kennytm 71c6d23612 Rollup merge of #46636 - frewsxcv:frewsxcv-fn-box, r=estebank
Replace libtest/lib.rs:FnBox with std::boxed::FnBox.

Fixes https://github.com/rust-lang/rust/issues/41810.
2017-12-22 02:50:45 +08:00
varkor b59fbfdbe1 Move source-output conflict checking into `compile_input` 2017-12-19 01:54:00 +00:00
Corey Farwell 4f04f975ae Replace libtest/lib.rs:FnBox with std::boxed::FnBox.
Fixes https://github.com/rust-lang/rust/issues/41810.
2017-12-15 09:11:14 -05:00
Oliver Schneider d732da813b
Use PathBuf instead of String where applicable 2017-12-14 11:22:08 +01:00
Irina-Gabriela Popa 2c175df013 rustc_back: replace tempdir with crates.io version. 2017-12-04 18:25:31 +02:00
Irina-Gabriela Popa dda924ab6a rustc_back: move dynamic_lib to rustc_metadata. 2017-12-04 18:25:29 +02:00
Alex Crichton 48996f9e75 rustbuild: Enable WebAssembly backend by default
This commit alters how we compile LLVM by default enabling the WebAssembly
backend. This then also adds the wasm32-unknown-unknown target to get compiled
on the `cross` builder and distributed through rustup. Tests are not yet enabled
for this target but that should hopefully be coming soon!
2017-11-25 06:44:35 -08:00
QuietMisdreavus f9f3611f5c allow loading external files in documentation
Partial implementation of https://github.com/rust-lang/rfcs/pull/1990
(needs error reporting work)

cc #44732
2017-11-21 15:46:49 -06:00
Alex Burka b34a7ffb25 address review comments 2017-11-20 18:03:20 +00:00
Alex Burka 30a661409c tidy 😡 2017-11-20 01:23:44 +00:00
Alex Burka 7a5a1f9857 use -Z flag instead of env var 2017-11-19 22:30:14 +00:00
QuietMisdreavus 5abc524073 rustdoc: add #[allow(unused)] to every doctest
also modify the order crate attributes are applied, to have a better
order of how things can override lints, either per-crate or per-test
2017-11-05 09:30:00 -06:00
Guillaume Gomez 83bca40350 Add short message-format 2017-10-20 16:04:32 +02:00
Vadim Petrochenkov 9e0fc5ccd0 rustbuild: Support specifying archiver and linker explicitly 2017-10-15 22:10:07 +03:00
bors a457e29811 Auto merge of #44867 - kennytm:rustdoc-md-test-title, r=alexcrichton
doc-test: In Markdown tests, Use all of `<h1>` to `<h6>` as the test name

This mainly simplifies debugging error index tests, as the error codes are `<h2>`s in the huge document containing all codes.
2017-10-14 23:07:35 +00:00
bors 13ae187043 Auto merge of #44822 - frewsxcv:frewsxcv-eprintln, r=Kimundi
Migrate to eprint/eprintln macros where appropriate.

None
2017-10-10 02:54:14 +00:00
kennytm 0cdf587ab3
doc-test: In Markdown tests, Use all of `<h1>` to `<h6>` as the test name.
This mainly simplifies debugging error index tests, as the error codes are
`<h2>`s in the huge document containing all codes.
2017-10-08 00:49:33 +08:00