Commit Graph

139836 Commits

Author SHA1 Message Date
Vadim Petrochenkov
5d27728141 rustc_builtin_macros: Share some more logic between derive and cfg_eval 2021-03-07 01:12:18 +03:00
Vadim Petrochenkov
10ed08f5b6 cfg_eval: Configure everything through mutable visitor methods
This is simpler and mirrors what invocation collector does
2021-03-07 00:23:02 +03:00
Vadim Petrochenkov
f9019b7086 Move full configuration logic from rustc_expand to rustc_builtin_macros
This logic is applicable to two specific macros and not to the expansion infrastructure in general.
2021-03-07 00:17:31 +03:00
bors
dfe519b344 Auto merge of #82738 - estebank:tail-expr-check-is-too-slow, r=oli-obk
Move check only relevant in error case out of critical path

Move the check for potentially forgotten `return` in a tail expression
of arbitrary expressions into the coercion error branch to avoid
computing unncessary coercion checks on successful code.

Follow up to #81458.
2021-03-06 21:02:53 +00:00
Rune Tynan
18841ec342
Revert fmt version, add rustdoc-json-types to bootstrap tests 2021-03-06 15:50:30 -05:00
Rune Tynan
70c9b370e8
x.py fmt 2021-03-06 15:50:29 -05:00
Rune Tynan
83cece468e
Move tests to own file 2021-03-06 15:50:29 -05:00
Rune Tynan
ca48d1566e
Add roundtrip testing and bump format version 2021-03-06 15:50:28 -05:00
Rune Tynan
cf5246915b
Remove Item::kind, use tagged enum. Rename variants to match 2021-03-06 15:50:20 -05:00
Vadim Petrochenkov
5dad6c2575 Implement built-in attribute macro #[cfg_eval] 2021-03-06 23:03:19 +03:00
Jacob Pratt
79c2b75e88
Make some Option, Result methods unstably const
The following functions are now unstably const:

- Option::transpose
- Option::flatten
- Result::transpose
2021-03-06 14:17:49 -05:00
Vadim Petrochenkov
069e612e73 rustc_ast: Replace AstLike::finalize_tokens with a getter tokens_mut 2021-03-06 21:19:31 +03:00
Harald van Dijk
95e096d623
Change x64 size checks to not apply to x32.
Rust contains various size checks conditional on target_arch = "x86_64",
but these checks were never intended to apply to
x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the
conditions.
2021-03-06 16:02:48 +00:00
Ralf Jung
b75154897b tweak MaybeUninit docs 2021-03-06 16:59:39 +01:00
Lonami
fbc17410b2 Improve transmute docs with further clarifications
Closes #82493.
2021-03-06 16:01:01 +01:00
Yuki Okushi
eb9abea295 Move some tests to more suitable subdirs 2021-03-06 18:24:53 +09:00
Yuki Okushi
6e4dcea0d9 Handle negative literals in cast overflow warning 2021-03-06 17:33:21 +09:00
Camelid
5b74097975 Undo addition of boxes
I don't think the boxing helped performance, in fact I think it
potentially made it worse. The data was still being copied, but now it
was through a pointer. Thinking about it more, I think boxing might only
help when you're passing a big object around by value all the time,
rather than the slowdown being that you're cloning it.
2021-03-05 20:01:52 -08:00
Henry Boisdequin
0ca63ec1f7 Fix typo
we need to actually -> we actually need to

@rustbot label +C-cleanup
2021-03-06 09:16:29 +05:30
Camelid
c09d9d34f0 Don't unnecessarily clone some fields in Context
There was no need to clone `id_map` because it was reset before each
item was rendered. `deref_id_map` was not reset, but it was keyed by
`DefId` and thus was unlikely to have collisions (at least for now).

Now we just clone the fields that need to be cloned, and instead create
fresh versions of the others.
2021-03-05 19:41:37 -08:00
Camelid
ff39c46959 Box some fields to reduce Context size
Reduced from 152 bytes to 88 bytes.
2021-03-05 19:41:27 -08:00
Camelid
4c51a66d67 Don't share id_map and deref_id_map
All the tests passed, so it doesn't seem they need to be shared.
Plus they should be item/page-specific.

I'm not sure why they were shared before. I think the reason `id_map`
worked as a shared value before is that it is cleared before rendering
each item (in `render_item`). And then I'm guessing `deref_id_map`
worked because it's a hashmap keyed by `DefId`, so there was no overlap
(though I'm guessing we could have had issues in the future).

Note that `id_map` currently still has to be cleared because otherwise
child items would inherit the `id_map` of their parent. I'm hoping to
figure out a way to stop cloning `Context`, but until then we have to
reset `id_map`.
2021-03-05 19:40:54 -08:00
Camelid
3bc879e76b rustdoc: Add static size assertion for Context
It's cloned a lot, so we don't want it to grow in size unexpectedly.

Only run the assert on x86-64 since the size is architecture-dependent.
2021-03-05 19:39:17 -08:00
Camelid
b3d2a371bb rustdoc: Make a bunch of fields private
Also create issue for removing shared mutable state.
2021-03-05 19:39:08 -08:00
Henry Boisdequin
7d3a6f1655 address comments 2021-03-06 08:21:08 +05:30
Camelid
c4bb66c284 rustdoc: Replace Arc around SharedContext with Rc
It doesn't look like it's shared across threads, so it doesn't need to
be thread-safe. Of course, since we're using Rust, we'll get an error if
we try to share it across threads, so this should be safe :)
2021-03-05 18:08:01 -08:00
Camelid
9763eb87a3 rustdoc: Move most shared fields to SharedContext
...and remove `Rc`s for the moved fields.

The only shared one that I didn't move was `cache`; see the doc-comment
I added to `cache` for details.
2021-03-05 17:57:58 -08:00
Tomasz Miąsko
6f49aadabb Disable destination propagation on all mir-opt-levels 2021-03-06 00:00:00 +00:00
bors
51748a8fc7 Auto merge of #82816 - GuillaumeGomez:rollup-hxohu2e, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #80845 (Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make transition over hir::ItemKind simpler)
 - #82708 (Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint)
 - #82714 (Detect match arm body without braces)
 - #82736 (Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default)
 - #82782 (Make rustc shim's verbose output include crate_name being compiled.)
 - #82797 (Update tests names to start with `issue-`)
 - #82809 (rustdoc: Use substrings instead of split to grab enum variant paths)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-03-05 23:16:04 +00:00
Guillaume Gomez
8dfbc00d27
Rollup merge of #82809 - notriddle:microoptimize-main-js, r=GuillaumeGomez
rustdoc: Use substrings instead of split to grab enum variant paths

Both versions are about equally readable, but this version avoids scanning the entire path and building an intermediate array (`split()` in Rust is a lazy iterator, but not in JavaScript).
2021-03-05 21:44:44 +01:00
Guillaume Gomez
1a08cb6a36
Rollup merge of #82797 - henryboisdequin:name-issue-num, r=Xanewok
Update tests names to start with `issue-`

See ``@JohnTitor's`` [comment](https://github.com/rust-lang/rust/pull/82720#discussion_r586488083)

``@rustbot`` label +C-cleanup
2021-03-05 21:44:42 +01:00
Guillaume Gomez
ef17859e35
Rollup merge of #82782 - pnkfelix:include-crate-being-compiled-in-bootstrap-verbose-output, r=Mark-Simulacrum
Make rustc shim's verbose output include crate_name being compiled.

This change is mainly motivated by an issue with the environment printing I added in PR 82403: multiple rustc invocations progress in parallel, and the environment output, spanning multiple lines, gets interleaved in ways make it difficult to extra the enviroment settings.

(This aforementioned difficulty is more of a hiccup than an outright show-stopper, because the environment variables tend to be the same for all of the rustc invocations, so it doesn't matter too much if one mixes up which lines one is looking at. But still: Better to fix it.)
2021-03-05 21:44:41 +01:00
Guillaume Gomez
15c148b4f2
Rollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obk
Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default

r? `@oli-obk`
2021-03-05 21:44:40 +01:00
Guillaume Gomez
34b2caa79f
Rollup merge of #82714 - estebank:missing-braces, r=oli-obk
Detect match arm body without braces

Fix #82524.
2021-03-05 21:44:39 +01:00
Guillaume Gomez
8867f7f650
Rollup merge of #82708 - GuillaumeGomez:doc-test-attr-check, r=Manishearth
Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint

Part of #82672.

This PR does multiple things:
 * Create a new `INVALID_DOC_ATTRIBUTE` lint which is also "future incompatible", allowing us to use it as a warning for the moment until it turns (eventually) into a hard error.
 * Use this link when `#![doc(test(...))]` isn't used at the crate level.
 * Make #82702 use this new lint as well.

r? ``@jyn514``
2021-03-05 21:44:38 +01:00
Guillaume Gomez
92861c7927
Rollup merge of #80845 - GuillaumeGomez:item-kind-transition, r=jyn514
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make transition over hir::ItemKind simpler

It was surprisingly difficult to make this change, mostly because of two issues:

* We now store the `ExternCrate` name in the parent struct (`clean::Item`), which forced me to modify the json conversion code a bit more than expected.
* The second problem was that, since we now have a `Some(name)`, it was trying to render it, ending up in a panic because we ended up in a `unreachable` statement. The solution was simply to add `!item.is_extern_crate()` in `formats::renderer` before calling `cx.item(item, &cache)?;`.

I'll continue to replace all the `clean::ItemKind` variants one by one until it looks exactly like `hir::ItemKind`. Then we'll simply discard the rustdoc type. Once this done, we'll be able to discard `clean::Item` too to use `hir::Item`.

r? ``@jyn514``
2021-03-05 21:44:37 +01:00
Santiago Pastorino
11d9390c93
bless mir-inlining warning message 2021-03-05 17:40:34 -03:00
Joshua Nelson
173d2aaa00 Add an unstable option to print all unversioned files
This allows sharing those files between different doc invocations
without having to know their names ahead of time.
2021-03-05 15:31:30 -05:00
Guillaume Gomez
6052211982 Update minifier dependency version 2021-03-05 21:17:48 +01:00
Santiago Pastorino
663d4c8605
Fix MIR optimization level description 2021-03-05 17:13:58 -03:00
Santiago Pastorino
004465c620
Bump one missing mir_opt_level 2021-03-05 17:13:58 -03:00
Santiago Pastorino
261048f099
Fix rustc_driver self text and bump the mir_opt_level 2021-03-05 17:13:58 -03:00
Santiago Pastorino
af63afc09a
Bump mir-opt-level from 2 to 3 in tests 2021-03-05 17:13:57 -03:00
Santiago Pastorino
705813c84b
Bump mir-opt-level from 3 to 4 in tests 2021-03-05 17:13:57 -03:00
Santiago Pastorino
03c1f1762c
Make clippy set mir_opt_level using Option 2021-03-05 17:13:57 -03:00
Santiago Pastorino
421fd8ebbc
Make mir_opt_level default to 2 for optimized levels 2021-03-05 17:13:57 -03:00
Santiago Pastorino
782c7b04cf
Bump all mir_opt_level 2 to 3 2021-03-05 17:13:57 -03:00
Santiago Pastorino
f3b8920d4b
Bump all mir_opt_level 3 to 4 2021-03-05 17:13:56 -03:00
Santiago Pastorino
fde8d6ee81
For better consistency change mir_opt_level <= 1 to < 2 2021-03-05 17:13:56 -03:00
Santiago Pastorino
8152da22a1
Extract mir_opt_level to a method and use Option to be able to know if the value is provided or not 2021-03-05 17:13:56 -03:00