Ralf Jung [Mon, 25 May 2020 09:01:10 +0000 (11:01 +0200)]
Rollup merge of #72551 - alilleybrinker:document-debug-stability, r=KodrAus
First draft documenting Debug stability.
Debug implementations of std types aren't stable, and neither are derived Debug implementations for any types, including user-defined types. This commit adds a section to the Debug documentation noting this stability status.
Ralf Jung [Mon, 25 May 2020 09:01:03 +0000 (11:01 +0200)]
Rollup merge of #71940 - SimonSapin:nonnull-slice, r=kennytm
Add `len` and `slice_from_raw_parts` to `NonNull<[T]>`
This follows the precedent of the recently-added `<*const [T]>::len` (adding to its tracking issue https://github.com/rust-lang/rust/issues/71146) and `ptr::slice_from_raw_parts`.
Debug implementations of std types aren't stable, and neither are
derived Debug implementations for any types, including user-defined
types. This commit adds a section to the Debug documentatio noting this
stability status.
bors [Sun, 24 May 2020 22:11:12 +0000 (22:11 +0000)]
Auto merge of #72287 - Aaron1011:feature/min-token-collect, r=petrochenkov
Store tokens inside `ast::Expr`
This is a smaller version of #70091.
We now store captured tokens inside `ast::Expr`, which allows us to avoid some reparsing in `nt_to_tokenstream`. To try to mitigate the performance impact, we only collect tokens when we've seen an outer attribute.
This makes progress towards solving #43081. There are still many things left to do:
* Collect tokens for other AST items.
* Come up with a way to handle inner attributes (we need to be collecting tokens by the time we encounter them)
* Avoid re-parsing when a `#[cfg]` attr is used.
However, this is enough to fix spans for a simple example, which I've included as a test case.
bors [Sun, 24 May 2020 18:40:28 +0000 (18:40 +0000)]
Auto merge of #72539 - RalfJung:rollup-8yfidi8, r=RalfJung
Rollup of 5 pull requests
Successful merges:
- #72402 (Remove all uses of `NodeId` in `ResolverOutputs`)
- #72527 (bootstrap: propagate test-args to miri and clippy test suites)
- #72530 (Clean up E0602 explanation)
- #72532 (Use `dyn` trait syntax in more comments and docs)
- #72535 (Use sort_unstable_by in its own docs)
Ralf Jung [Sun, 24 May 2020 14:51:30 +0000 (16:51 +0200)]
Rollup merge of #72527 - RalfJung:miri-clippy-test-args, r=Mark-Simulacrum
bootstrap: propagate test-args to miri and clippy test suites
For Miri I verified this works. For clippy, unfortunately it doesn't seem to work as a stage 0 tool:
```
./x.py --stage 0 test src/tools/clippy --test-args init
```
gives
```
Compiling clippy-mini-macro-test v0.2.0 (/home/r/src/rust/rustc.3/src/tools/clippy/mini-macro)
error[E0658]: procedural macros cannot be expanded to expressions
--> src/tools/clippy/mini-macro/src/lib.rs:11:5
|
11 | / quote!(
12 | | #[allow(unused)]
13 | | fn needless_take_by_value(s: String) {
14 | | println!("{}", s.len());
... |
24 | | }
25 | | )
| |_____^
|
= note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
Compiling proc-macro2 v1.0.3
Compiling syn v1.0.11
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: could not compile `clippy-mini-macro-test`.
```
But propagating `--test-args` to the test suite seems to make sense regardless.
Cc @rust-lang/clippy
Ralf Jung [Sun, 24 May 2020 10:17:09 +0000 (12:17 +0200)]
Rollup merge of #72284 - Aaron1011:feature/inline-macro-did, r=petrochenkov
Remove `macro_defs` map
We now store the `DefId` directly in `ExpnKind::Macro`. This will allow
us to serialize `ExpnData` in PR #72121 without needing to manage a side
table.
Ralf Jung [Sun, 24 May 2020 07:30:31 +0000 (09:30 +0200)]
Rollup merge of #72388 - Aaron1011:fix/deep-tokenstream-equality, r=petrochenkov
Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro`
Fixes #68430
When comparing the captured and re-parsed `TokenStream` for a `TokenKind::Interpolated`, we currently treat any nested `TokenKind::Interpolated` tokens as unequal. If a `TokenKind::Interpolated` token shows up in the captured `TokenStream` due to a `macro_rules!` expansion, we will throw away the captured `TokenStream`, losing span information.
This PR recursively invokes `nt_to_tokenstream` on nested `TokenKind::Interpolated` tokens, effectively flattening the stream into a sequence of non-interpolated tokens. This allows it to compare equal with the re-parsed stream, allowing us to keep the original captured `TokenStream` (with span information).
This requires all of the `probably_equal_for_proc_macro` methods to be moved from `librustc_ast` to `librustc_parse` so that they can call `nt_to_tokenstream`.
bors [Sun, 24 May 2020 04:15:08 +0000 (04:15 +0000)]
Auto merge of #72362 - matthewjasper:remove-rescope, r=nikomatsakis
Remove ReScope
`ReScope` is unnecessary now that AST borrowck is gone and we're erasing the results of region inference in function bodies. This removes about as much of the old regionck code as possible without having to enable NLL fully.
bors [Sun, 24 May 2020 00:56:20 +0000 (00:56 +0000)]
Auto merge of #72516 - Dylan-DPC:rollup-cc4w96z, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #71618 (Preserve substitutions when making trait obligations for suggestions)
- #72092 (Unblock font loading in rustdoc.css)
- #72400 (Add missing ASM arena declarations to librustc_middle)
- #72489 (Fix ice-72487)
- #72502 (fix discriminant type in generator transform)
Dylan DPC [Sat, 23 May 2020 22:00:52 +0000 (00:00 +0200)]
Rollup merge of #72502 - RalfJung:generator-discr-ty, r=jonas-schievink
fix discriminant type in generator transform
The generator transform assumed that the discriminant type is always `isize`, which is not correct, leading to [ICEs in Miri](https://github.com/rust-lang/rust/pull/72419/files#r429543536) when some extra sanity checking got enabled.
Dylan DPC [Sat, 23 May 2020 22:00:48 +0000 (00:00 +0200)]
Rollup merge of #72400 - Aaron1011:fix/asm-incr-ice, r=Amanieu
Add missing ASM arena declarations to librustc_middle
Fixes #72386
These types also need to get allocated on the `librustc_middle` arena
when we deserialize MIR.
@Amanieu: If we end up using your approach in https://github.com/rust-lang/rust/pull/72392 instead, feel free to copy the test I added over to your PR.
Dylan DPC [Sat, 23 May 2020 22:00:45 +0000 (00:00 +0200)]
Rollup merge of #72092 - workingjubilee:patch-2, r=GuillaumeGomez
Unblock font loading in rustdoc.css
rustdoc's font loading defaults to "auto", so browsers may block render.
But rustdoc's case prefers a faster TTI for scrolling, this means the
strictest font-display in use should be "swap". rustdoc's fonts do provide
notable legibility improvements but first-time users will have little trouble
reading without. This means "optional" is preferred.
The one exception is Source Serif Pro: it's a big difference for body text, so
"fallback" is preferred over "optional" to cause a (tiny) block.
This follows up on (but does not resolve) #20962, taking PageSpeed Insight's rec fairly directly. Supporting reading material: https://drafts.csswg.org/css-fonts-4/#font-display-desc
Dylan DPC [Sat, 23 May 2020 22:00:42 +0000 (00:00 +0200)]
Rollup merge of #71618 - ecstatic-morse:issue-71394, r=nikomatsakis
Preserve substitutions when making trait obligations for suggestions
Resolves #71394.
I *think* `map_bound_ref` is correct here. In any case, I think a lot of the diagnostic code is using `skip_binder` more aggressively than it should be, so I doubt that this is worse than the status quo. The assertion that `new_self_ty` has no escaping bound vars should be enough.
r? @estebank
cc @nikomatsakis Is the call to `skip_binder` on line 551 (and elsewhere in this file) appropriate? https://github.com/rust-lang/rust/blob/46ec74e60f238f694b46c976d6217e7cf8d4cf1a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs#L537-L565
bors [Sat, 23 May 2020 21:21:40 +0000 (21:21 +0000)]
Auto merge of #72474 - mati865:ci-fix, r=pietroalbini
Revert MSYS2 CI workaround
MSYS2 has made workaround for critical packages so older installers like one used by chocolatey can work again.
Fixes https://github.com/rust-lang/rust/issues/72333
bors [Sat, 23 May 2020 17:53:54 +0000 (17:53 +0000)]
Auto merge of #72504 - Dylan-DPC:rollup-6wi1ifz, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #72292 (Replace obligation construction with deref_steps())
- #72431 (add warning sign to UB examples)
- #72446 (Impl Ord for proc_macro::LineColumn)
- #72492 (Add some regression tests)
- #72496 (Correct small typo: 'not' -> 'note')
Dylan DPC [Sat, 23 May 2020 17:10:00 +0000 (19:10 +0200)]
Rollup merge of #72446 - dtolnay:ord, r=petrochenkov
Impl Ord for proc_macro::LineColumn
```rust
impl Ord for LineColumn {...}
impl PartialOrd for LineColumn {...}
```
for https://doc.rust-lang.org/nightly/proc_macro/struct.LineColumn.html.
The ordering is the natural one you would get by writing one line after another, where we compare line first, then compare columns within the same line.
Dylan DPC [Sat, 23 May 2020 17:09:57 +0000 (19:09 +0200)]
Rollup merge of #72292 - ldm0:derefsteps, r=estebank
Replace obligation construction with deref_steps()
1. Use `probe()` to avoid unwanted binding committing during `deref_steps()`.
2. Fixes #59819 again by using `deref_steps()`, make the code cleaner. And if we want to suggest multiple dereferences (like: `consider dereferencing the borrow: "****a"`) in the future, this change will make it easier to achieve.
bors [Sat, 23 May 2020 07:18:17 +0000 (07:18 +0000)]
Auto merge of #72478 - Dylan-DPC:rollup-vval8du, r=Dylan-DPC
Rollup of 7 pull requests
Successful merges:
- #71289 (Allow using `Self::` in doc)
- #72375 (Improve E0599 explanation)
- #72385 (Add some teams to prioritization exclude_labels)
- #72395 (Allow rust-highfive to label issues it creates.)
- #72453 (Add flag to open docs: x.py doc --open)
- #72459 (Add core::future::IntoFuture)
- #72461 (Clean up E0600 explanation)
bors [Sat, 23 May 2020 03:30:07 +0000 (03:30 +0000)]
Auto merge of #72256 - ecstatic-morse:once-cell, r=Mark-Simulacrum
Use `once_cell` crate instead of custom data structure
Internally, we use the [`Once`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sync/struct.Once.html) type for shared data that is initialized exactly once and only read from afterwards. `Once` uses a `parking_lot::Mutex` when the parallel compiler is enabled and a `RefCell` when it is not. This PR switches to the [`once_cell`](https://crates.io/crates/once_cell) crate, which also uses a `parking_lot::Mutex` for its `sync` version (because we enable the `parking_lot` feature) but has zero overhead for its `unsync` one.
This PR adds `once_cell` to the list of whitelisted dependencies. I think this is acceptable because it is already used in `rustc_driver`, is owned by a well-known community member (cc @matklad), and has a stable release. cc @rust-lang/compiler
`once_cell` has a slightly more minimal API than `Once`, which allows for initialization to be either optimistic (evaluate the initializer and then synchronize) or pessimistic (synchronize and then evaluate the initializer). `once_cell`'s `get_or_init` is always pessimistic. The optimistic version is only used once in the current `master`.
Ensure that `new_self_ty` has no escaping bound vars
Otherwise inserting it to the `Binder` used by `trait_ref` would cause
problems. This is just to be extra carefult: we aren't going to
start recommending that the user start using HKTs anytime soon.
Preserve substitutions when trying to prove trait obligation
`mk_obligation_for_def_id` is only correct if the trait and self type do
not have any substitutions. Use a different method,
`mk_trait_obligation_with_new_self_ty` that is more clear about what is
happening.
Dylan DPC [Fri, 22 May 2020 19:45:01 +0000 (21:45 +0200)]
Rollup merge of #72459 - yoshuawuyts:into-future, r=nikomatsakis
Add core::future::IntoFuture
This patch reintroduces the `core::future::IntoFuture` trait. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering since that lead to performance regressions. By introducing the trait separately from the integration, the integration PR can be more narrowly scoped, and people can start trying out the `IntoFuture` trait today. Thanks heaps!
cc/ @rust-lang/wg-async-foundations
## References
- Original PR adding `IntoFuture` https://github.com/rust-lang/rust/pull/65244
- Open issue to re-land `IntoFuture` (assigned to me) https://github.com/rust-lang/rust/issues/67982
- Tracking issue for `IntoFuture` https://github.com/rust-lang/rust/issues/67644
David Tolnay [Fri, 22 May 2020 16:50:41 +0000 (09:50 -0700)]
Report error from opener in bootstrap
On my machine, an error looks like:
Finished release [optimized] target(s) in 0.29s
Opening doc /git/rust/build/x86_64-unknown-linux-gnu/doc/std/index.html
command 'xdg-open (internal)' did not execute successfully; exit code: 4
command stderr:
gio: file:///git/rust/build/x86_64-unknown-linux-gnu/doc/std/index.html: Error when getting information for file “/git/rust/build/x86_64-unknown-linux-gnu/doc/std/index.html”: No such file or directory
bors [Fri, 22 May 2020 15:33:32 +0000 (15:33 +0000)]
Auto merge of #72464 - RalfJung:rollup-xhm7w7u, r=RalfJung
Rollup of 7 pull requests
Successful merges:
- #71829 (Fix suggestion to borrow in struct)
- #72123 (Stabilize process_set_argv0 feature for Unix)
- #72235 (Clean up E0590 explanation)
- #72345 (Clean up E0593 explanation)
- #72376 ([self-profling] Record the cgu name when doing codegen for a module)
- #72399 (Add fast-path optimization for Ipv4Addr::fmt)
- #72435 (rustllvm: Fix warnings about unused function parameters)