[RFC 2011] Optimize non-consuming operators
Tracking issue: https://github.com/rust-lang/rust/issues/44838
Fifth step of https://github.com/rust-lang/rust/pull/96496
The most non-invasive approach that will probably have very little to no performance impact.
## Current behaviour
Captures are handled "on-the-fly", i.e., they are performed in the same place expressions are located.
```rust
// `let a = 1; let b = 2; assert!(a > 1 && b < 100);`
if !(
{ ***try capture `a` and then return `a`*** } > 1 && { ***try capture `b` and then return `b`*** } < 100
) {
panic!( ... );
}
```
As such, some overhead is likely to occur (Specially with very large chains of conditions).
## New behaviour for non-consuming operators
When an operator is known to not take `self`, then it is possible to capture variables **AFTER** the condition.
```rust
// `let a = 1; let b = 2; assert!(a > 1 && b < 100);`
if !( a > 1 && b < 100 ) {
{ ***try capture `a`*** }
{ ***try capture `b`*** }
panic!( ... );
}
```
So the possible impact on the runtime execution time will be diminished.
r? ````@oli-obk````
Remove `MAX_SUGGESTION_HIGHLIGHT_LINES`
After #97798 the `MAX_SUGGESTION_HIGHLIGHT_LINES` constant doesn't really make sense since we always show full suggestions. This PR removes last usages of the constant and the constant itself.
r? ``@flip1995`` (this mostly does changes in clippy)
attempt to optimise vectored write
benchmarked:
old:
```
test io::cursor::tests::bench_write_vec ... bench: 68 ns/iter (+/- 2)
test io::cursor::tests::bench_write_vec_vectored ... bench: 913 ns/iter (+/- 31)
```
new:
```
test io::cursor::tests::bench_write_vec ... bench: 64 ns/iter (+/- 0)
test io::cursor::tests::bench_write_vec_vectored ... bench: 747 ns/iter (+/- 27)
```
More unsafe than I wanted (and less gains) in the end, but it still does the job
Only keep a single query for well-formed checking
There are currently 3 queries to perform wf checks on different item-likes. This complexity is not required.
This PR replaces the query by:
- one query per item;
- one query to invoke it for a whole module.
This allows to remove HIR `ParItemLikeVisitor`.
libcore tests: avoid int2ptr casts
We don't need any of these pointers to actually be dereferenceable so using `ptr::invalid` should be fine. And then we can run Miri with strict provenance enforcement on the tests.
Add triagebot mentions.
This migrates the configuration of mentions from highfive to triagebot.
I also fixed a few broken paths (error_codes.rs src/librustdoc/html/static/themes src/librustdoc/html/static/themes/ayu.css).
liballoc tests: avoid int2ptr cast
I think we don't need `ptr::from_exposed_addr` here; `ptr::invalid` should be enough for this test. (And this makes Miri less unhappy when running these tests.)
Fix "kind" for associated types in trait implementations in rustdoc JSON
Fixes https://github.com/rust-lang/rust/issues/81340.
Contrary to what is suggested in the issue, I really think we should distinguish between associated items and "normal" constants and types.
cc `@CraftSpider` `@SimonSapin`
r? `@notriddle`
interpret: refactor allocation info query
We now have an infallible function that also tells us which kind of allocation we are talking about.
Also we do longer have to distinguish between data and function allocations for liveness.
This will help us to avoid "catching" `InterpError`s in Miri.
r? `@oli-obk`
Fix rustdoc argument error
Fixes#88756.
It's a take over of #88831. I cherry-picked the commits, fixed the merge conflict and the failing test.
cc `@inashivb` `@jyn514`
r? `@notriddle`
catch unwind in parallel mode during wfcheck
Update #75760
When performing wfcheck, from the test results, the parallel mode will stop all checks when an `item`'s check failed, (e.g. the first ui test failure raised from [here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs#L249))while the serial mode will output each `item`'s check result via `catch_unwind`. This leads to inconsistencies in the final output of the two mode.
In my local environment, this modification prevents the following ui tests from failing when set `parallel-compiler = true` in `config.toml`:
```
[ui] src/test\ui\associated-types\defaults-cyclic-fail-1.rs
[ui] src/test\ui\associated-types\defaults-cyclic-fail-2.rs
[ui] src/test\ui\associated-types\hr-associated-type-bound-2.rs
[ui] src/test\ui\associated-types\impl-wf-cycle-1.rs
[ui] src/test\ui\associated-types\impl-wf-cycle-2.rs
[ui] src/test\ui\issues\issue-20413.rs
[ui] src/test\ui\parallel_test\defaults-cyclic-fail-para.rs
```
Check ADT field is well-formed before checking it is sized
Fixes#96810.
There is one diagnostics regression, in [`src/test/ui/generic-associated-types/bugs/issue-80626.stderr`](https://github.com/rust-lang/rust/pull/97780/files#diff-53795946378e78a0af23a10277c628ff79091c18090fdc385801ee70c1ba6963). I am not super concerned about it, since it's GAT related.
We _could_ fix it, possibly by using the `FieldSized` obligation cause code instead of `BuiltinDerivedObligation`. But that would require changing `Sized` trait confirmation and the `adt_sized_constraint` query.
Rebase LLVM submodule
This is a rebase of our LLVM fork onto LLVM 14.0.5, which is intended to be the last release of the 14.x series. Additionally:
* I've dropped three patches that were needed to build on FreeBSD 11, which is no longer necessary after #97944.
* I've dropped some cherry-picks that were later reverted.
* I've cherry-picked caa2a829cd for https://github.com/rust-lang/rust/issues/96797 (fyi `@Amanieu)`
We now have an infallible function that also tells us which kind of allocation we are talking about.
Also we do longer have to distinguish between data and function allocations for liveness.
rustc_target: Add convenience functions for adding linker arguments
They ensure that lld and non-lld linker flavors get the same set of arguments.
The second commit also adds some tests checking for linker argument inconsistencies, and tweaks some arguments to fix those inconsistencies.
proc_macro/bridge: cache static spans in proc_macro's client thread-local state
This is the second part of https://github.com/rust-lang/rust/pull/86822, split off as requested in https://github.com/rust-lang/rust/pull/86822#pullrequestreview-1008655452. This patch removes the RPC calls required for the very common operations of `Span::call_site()`, `Span::def_site()` and `Span::mixed_site()`.
Some notes:
This part is one of the ones I don't love as a final solution from a design standpoint, because I don't like how the spans are serialized immediately at macro invocation. I think a more elegant solution might've been to reserve special IDs for `call_site`, `def_site`, and `mixed_site` at compile time (either starting at 1 or from `u32::MAX`) and making reading a Span handle automatically map these IDs to the relevant values, rather than doing extra serialization.
This would also have an advantage for potential future work to allow `proc_macro` to operate more independently from the compiler (e.g. to reduce the necessity of `proc-macro2`), as methods like `Span::call_site()` could be made to function without access to the compiler backend.
That was unfortunately tricky to do at the time, as this was the first part I wrote of the patches. After the later part (#98188, #98189), the other uses of `InternedStore` are removed meaning that a custom serialization strategy for `Span` is easier to implement.
If we want to go that path, we'll still need the majority of the work to split the bridge object and introduce the `Context` trait for free methods, and it will be easier to do after `Span` is the only user of `InternedStore` (after #98189).
Rollup of 11 pull requests
Successful merges:
- #97140 (std: use an event-flag-based thread parker on SOLID)
- #97295 ([rustc_parse] Forbid `let`s in certain places)
- #97743 (make const_err show up in future breakage reports)
- #97908 (Stabilize NonZero* checked operations constness.)
- #98297 (Transform help popup into a pocket menu)
- #98428 (macros: use typed identifiers in diag and subdiag derive)
- #98528 (Respect --color when building rustbuild itself)
- #98535 (Add regression test for generic const in rustdoc)
- #98538 (Add a ui test for issue #91883)
- #98540 (Add regression test for #87558)
- #98541 (Update `std::alloc::System` doc example code style)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Update `std::alloc::System` doc example code style
`return` on the last line of a block is unidiomatic so I don't think the example should be using that here