bors [Sun, 5 Dec 2021 03:41:18 +0000 (03:41 +0000)]
Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obk
Add a MIR pass manager (Taylor's Version)
The final draft of #91386 and #77665.
While the compile-time constraints in #91386 are cool, I decided on a more minimal approach for now. I want to explore phase constraints and maybe relative-ordering constraints in the future, though. This should preserve existing behavior **exactly** (please let me know if it doesn't) while making the following changes to the way we organize things today:
- Each `MirPhase` now corresponds to a single MIR pass. `run_passes` is not responsible for listing the correct MIR phase.
- `run_passes` no longer silently skips passes if the declared MIR phase is greater than or equal to the body's. This has bitten me multiple times. If you want this behavior, you can always branch on `body.phase` yourself.
- If your pass is solely to emit errors, you can use the `MirLint` interface instead, which gets a shared reference to `Body` instead of a mutable one. By differentiating the two, I hope to make it clearer in the short term where lints belong in the pipeline. In the long term perhaps we could enforce this at compile-time?
- MIR is no longer dumped for passes that aren't enabled, or for lints.
I tried to check that `-Zvalidate` still works correctly, since the MIR phase is now updated as soon as the associated pass is done, instead of at the end of all the passes in `run_passes`. However, it looks like `-Zvalidate` is broken with current nightlies anyways :cry: (it spits out a bunch of errors).
bors [Sun, 5 Dec 2021 00:38:01 +0000 (00:38 +0000)]
Auto merge of #91539 - matthiaskrgr:rollup-rnl10yb, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #89642 (environ on macos uses directly libc which has the correct signature.)
- #90022 (Explain why `Self` is invalid in generic parameters)
- #90023 (Postpone the evaluation of constant expressions that depend on inference variables)
- #91215 (Implement VecDeque::retain_mut)
- #91355 (std: Stabilize the `thread_local_const_init` feature)
- #91528 (LLVM support .insn directive)
Matthias Krüger [Sat, 4 Dec 2021 23:38:00 +0000 (00:38 +0100)]
Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se
std: Stabilize the `thread_local_const_init` feature
This commit is intended to follow the stabilization disposition of the
FCP that has now finished in #84223. This stabilizes the ability to flag
thread local initializers as `const` expressions which enables the macro
to generate more efficient code for accessing it, notably removing
runtime checks for initialization.
More information can also be found in #84223 as well as the tests where
the feature usage was removed in this PR.
Matthias Krüger [Sat, 4 Dec 2021 23:37:59 +0000 (00:37 +0100)]
Rollup merge of #91215 - GuillaumeGomez:vec-deque-retain-mut, r=m-ou-se
Implement VecDeque::retain_mut
Part of https://github.com/rust-lang/rust/issues/90829.
In https://github.com/rust-lang/rust/pull/90772, someone suggested that `retain_mut` should also be implemented on `VecDeque`. I think that it follows the same logic (coherency). So first: is it ok? Second: should I create a new feature for it or can we put it into the same one?
Matthias Krüger [Sat, 4 Dec 2021 23:37:58 +0000 (00:37 +0100)]
Rollup merge of #90023 - b-naber:postpone_const_eval_infer_vars, r=nikomatsakis
Postpone the evaluation of constant expressions that depend on inference variables
Previously `delay_span_bug` calls were triggered once an inference variable was included in the substs of a constant that was to be evaluated. Some of these would merely have resulted in trait candidates being rejected, hence no real error was ever encountered, but the triggering of the `delay_span_bug` then caused an ICE in later stages of the compiler due to no error ever occurring.
We now postpone the evaluation of these constants, so any trait obligation fulfillment will simply stall on this constant and the existing type inference machinery of the compiler handles any type errors if present.
bors [Sat, 4 Dec 2021 13:23:50 +0000 (13:23 +0000)]
Auto merge of #91517 - matthiaskrgr:rollup-3fmp4go, r=matthiaskrgr
Rollup of 3 pull requests
Successful merges:
- #87054 (Add a `try_reduce` method to the Iterator trait)
- #89701 (Updated error message for accidental uses of derive attribute as a crate attribute)
- #90519 (Keep spans for generics in `#[derive(_)]` desugaring)
Matthias Krüger [Sat, 4 Dec 2021 09:42:19 +0000 (10:42 +0100)]
Rollup merge of #89701 - tom7980:issue-89566-fix, r=petrochenkov
Updated error message for accidental uses of derive attribute as a crate attribute
This partially fixes the original issue #89566 by adding derive to the list of invalid crate attributes and then providing an updated error message however I'm not sure how to prevent the resolution error message from emitting without causing the compiler to just abort when it finds an invalid crate attribute (which I'd prefer not to do so we can find and emit other errors).
`@petrochenkov` I have been told you may have some insight on why it's emitting the resolution error though honestly I'm not sure if we need to worry about fixing it as long as we can provide the invalid crate attribute error also (which happens first anyway)
bors [Sat, 4 Dec 2021 02:53:54 +0000 (02:53 +0000)]
Auto merge of #91505 - matthiaskrgr:rollup-orxgsxo, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #90538 (Document how recursion is handled for `ty::Ty`)
- #90851 (Add unchecked downcast methods)
- #91209 (Implement ``@snapshot`` check for htmldocck)
- #91385 (Suggest the `pat_param` specifier before `|` on 2021 edition )
- #91478 (Remove incorrect newline from float cast suggestion)
- #91481 (Use let_else in some more places in rustc_lint)
- #91488 (Fix ICE when `yield`ing in function returning `impl Trait`)
bors [Fri, 3 Dec 2021 23:46:53 +0000 (23:46 +0000)]
Auto merge of #91501 - camelid:rm-tuple-impls-2, r=GuillaumeGomez
rustdoc: Remove Clean impls for tuples
This PR removes all nine Clean impls on tuples, converting them to
functions instead.
The fact that these are impls causes several problems:
1. They are nameless, so it's unclear what they do.
2. It's hard to find where they're used apart from removing them and
seeing what errors occur (this applies to all Clean impls, not just
the tuple ones).
3. Rustc doesn't currently warn when impls are unused, so dead code
can accumulate easily (all Clean impls).
4. Their bodies often use tuple field indexing syntax (e.g., `self.1`)
to refer to their "arguments", which makes reading the code more
difficult.
As I noted, some of these problems apply to all Clean impls, but even
those problems are exacerbated by the tuple impls since they make
general understanding of the code harder.
Converting the impls to functions solves all four of these problems.
Noah Lev [Fri, 3 Dec 2021 21:23:18 +0000 (13:23 -0800)]
Remove a Clean impl for a tuple (1)
This commit removes the first of nine Clean impls on tuples, converting
it to a function instead.
The fact that these are impls causes several problems:
1. They are nameless, so it's unclear what they do.
2. It's hard to find where they're used apart from removing them and
seeing what errors occur (this applies to all Clean impls, not just
the tuple ones).
3. Rustc doesn't currently warn when impls are unused, so dead code
can accumulate easily (all Clean impls).
4. Their bodies often use tuple field indexing syntax (e.g., `self.1`)
to refer to their "arguments", which makes reading the code more
difficult.
As I noted, some of these problems apply to all Clean impls, but even
those problems are exacerbated by the tuple impls since they make
general understanding of the code harder.
Converting the impls to functions solves all four of these problems.
bors [Fri, 3 Dec 2021 19:29:21 +0000 (19:29 +0000)]
Auto merge of #90737 - eholk:intofuture, r=tmandry
Reintroduce `into_future` in `.await` desugaring
This is a reintroduction of the remaining parts from https://github.com/rust-lang/rust/pull/65244 that have not been relanded yet.
This isn't quite ready to merge yet. The last attempt was reverting due to performance regressions, so we need to make sure this does not introduce those issues again.
Esteban Kuber [Sat, 20 Nov 2021 18:46:36 +0000 (18:46 +0000)]
Annotate `derive`d spans and move span suggestion code
* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
at the users' code
Reverts #91354 in order to address #91489. We would need to place this changes in a more granular way and would also be nice to address the small perf regression that was also introduced.
bors [Fri, 3 Dec 2021 13:20:14 +0000 (13:20 +0000)]
Auto merge of #91393 - Julian-Wollersberger:lexer_optimization, r=petrochenkov
Optimize `rustc_lexer`
The `cursor.first()` method in `rustc_lexer` now calls the `chars.next()` method instead of `chars.nth_char(0)`.
This allows LLVM to optimize the code better. The biggest win is that `eat_while()` is now fully inlined and generates better assembly. This improves the lexer's performance by 35% in a micro-benchmark I made (Lexing all 18MB of code in the compiler directory). But lexing is only a small part of the overall compilation time, so I don't know how significant it is.
bors [Fri, 3 Dec 2021 07:12:36 +0000 (07:12 +0000)]
Auto merge of #91486 - matthiaskrgr:rollup-699fo18, r=matthiaskrgr
Rollup of 10 pull requests
Successful merges:
- #88906 (Implement write() method for Box<MaybeUninit<T>>)
- #90269 (Make `Option::expect` unstably const)
- #90854 (Type can be unsized and uninhabited)
- #91170 (rustdoc: preload fonts)
- #91273 (Fix ICE #91268 by checking that the snippet ends with a `)`)
- #91381 (Android: -ldl must appear after -lgcc when linking)
- #91453 (Document Windows TLS drop behaviour)
- #91462 (Use try_normalize_erasing_regions in needs_drop)
- #91474 (suppress warning about set_errno being unused on DragonFly)
- #91483 (Sync rustfmt subtree)
Matthias Krüger [Fri, 3 Dec 2021 05:24:15 +0000 (06:24 +0100)]
Rollup merge of #91381 - Amanieu:android_libdl, r=petrochenkov
Android: -ldl must appear after -lgcc when linking
#90846 accidentally broke Android builds because it causes the standard library to no longer use `dlsym` on Android. This results in `libdl` being ignored by the linker since no symbols are needed from it. However, we later import `libgcc` for unwinding which *does* depend on `libdl` for `dl_iterate_phdr`. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference to `dl_iterate_phdr`.
This is resolved by adding a second `-ldl` after `-lgcc` in the linker command-line.
Matthias Krüger [Fri, 3 Dec 2021 05:24:14 +0000 (06:24 +0100)]
Rollup merge of #91273 - Badel2:ice-index-str, r=estebank
Fix ICE #91268 by checking that the snippet ends with a `)`
Fix #91268
Previously it was assumed that the last character of `snippet` will be a `)`, so using `snippet.len() - 1` as an index should be safe. However as we see in the test, it is possible to enter that branch without a closing `)`, and it will trigger the panic if the last character happens to be multibyte.
The fix is to ensure that the snippet ends with `)`, and skip the suggestion otherwise.
Matthias Krüger [Fri, 3 Dec 2021 05:24:13 +0000 (06:24 +0100)]
Rollup merge of #91170 - jsha:preload-fonts, r=GuillaumeGomez
rustdoc: preload fonts
Follow-up from #82315.
I noticed that font loading was so slow that even when loading from local disk, we get a flash of unstyled text (FOUT) followed by a reflow when the fonts load. With this change, we reliably get the appropriate fonts in the first render pass when loading locally, and we get it some of the time when loading from a website.
This only preloads woff2 versions. According to https://caniuse.com/?search=preload and https://caniuse.com/?search=woff2, all browsers that support preload also support woff2, so this is fine; we will never load two copies of a font.
Don't preload italic font faces because they aren't used on all pages.
Matthias Krüger [Fri, 3 Dec 2021 05:24:11 +0000 (06:24 +0100)]
Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnay
Implement write() method for Box<MaybeUninit<T>>
This adds method similar to `MaybeUninit::write` main difference being
it returns owned `Box`. This can be used to elide copy from stack
safely, however it's not currently tested that the optimization actually
occurs.
Analogous methods are not provided for `Rc` and `Arc` as those need to
handle the possibility of sharing. Some version of them may be added in
the future.
This was discussed in #63291 which this change extends.
bors [Fri, 3 Dec 2021 04:14:07 +0000 (04:14 +0000)]
Auto merge of #91339 - cbarrete:vecdeque-remove-grow-check, r=Mark-Simulacrum
Remove unnecessary check in VecDeque::grow
All callers already check that the buffer is full before calling
`grow()`. This is where it makes the most sense, since `grow()` is
`inline(never)` and we don't want to pay for a function call just for
that check.
It could also be argued that it would be correct to call `grow()` even
if the buffer wasn't full yet.
This change breaks no code since `grow()` is not `pub`.
Dylan MacKenzie [Thu, 2 Dec 2021 22:14:38 +0000 (14:14 -0800)]
Skip shim passes if they've already been run
Looks like Generator drop shims already have `post_borrowck_cleanup` run
on them. That's a bit surprising, since it means they're getting const-
and maybe borrow-checked? This merits further investigation, but for now
just preserve the status quo.