Yuki Okushi [Tue, 3 May 2022 05:58:59 +0000 (14:58 +0900)]
Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebank
Update `RValue::Discriminant` documentation
`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.
Yuki Okushi [Tue, 3 May 2022 05:58:58 +0000 (14:58 +0900)]
Rollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister
Use source callsite in check_argument_types suggestion
This makes the "remove extra arguement" suggestion valid when the function argument is a macro.
Additionally, this may fix #96225, but the only way I can reproduce that issue is using the playground, so we will need to wait until after this is merged to ensure it's fixed.
Yuki Okushi [Tue, 3 May 2022 05:58:56 +0000 (14:58 +0900)]
Rollup merge of #93097 - GuillaumeGomez:settings-js, r=jsha
Switch settings menu to full js
Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before.
bors [Mon, 2 May 2022 21:45:20 +0000 (21:45 +0000)]
Auto merge of #92566 - the8472:inline-tra, r=m-ou-se
Inline `__iterator_get_unchecked` for some iterator adapters.
This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both.
It improves the performance of iterators using unchecked access when building in incremental mode (due to the larger CGU count?). It might negatively affect incremental compile times for better runtime results, but considering that the equivalent `next()` implementations also are `#[inline]` and usually are more complex this should be ok.
bors [Mon, 2 May 2022 18:57:32 +0000 (18:57 +0000)]
Auto merge of #96578 - tmiasko:chunked-bit-set-fmt, r=nnethercote
Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSet
`DebugWithContext` is used to format changes to dataflow state along with MIR
in graphviz dot files. In the case of `ChunkedBitSet` it was left unimplemented,
so attempts to use `-Zdump-mir-dataflow -Zdump-mir=all` resulted in an ICE:
> thread 'rustc' panicked at 'not implemented: implement when/if needed',
The 8472 [Wed, 5 Jan 2022 01:22:39 +0000 (02:22 +0100)]
This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both.
It improves the performance of iterators using unchecked access when building in incremental mode
(due to the larger CGU count?). It might negatively affect incremental compile times for better runtime results,
but considering that the equivalent `next()` implementations also are `#[inline]` and usually are more complex this
should be ok.
bors [Mon, 2 May 2022 14:03:20 +0000 (14:03 +0000)]
Auto merge of #96431 - petrochenkov:parent, r=cjgillot
rustc: Panic by default in `DefIdTree::parent`
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.
Same applies to `local_parent`/`opt_local_parent`.
bors [Mon, 2 May 2022 09:05:22 +0000 (09:05 +0000)]
Auto merge of #96596 - scottmcm:limited-calloc, r=Mark-Simulacrum
Tweak the vec-calloc runtime check to only apply to shortish-arrays
r? `@Mark-Simulacrum`
`@nbdd0121` pointed out in https://github.com/rust-lang/rust/pull/95362#issuecomment-1114085395 that LLVM currently doesn't constant-fold the `IsZero` check for long arrays, so that seems like a reasonable justification for limiting it.
It appears that it's based on length, not byte size, (https://godbolt.org/z/4s48Y81dP), so that's what I used in the PR. Maybe it's a ["the number of inlining shall be three"](https://youtu.be/s4wnuiCwTGU?t=320) sort of situation.
Certainly there's more that could be done here -- that generated code that checks long arrays byte-by-byte is highly suboptimal, for example -- but this is an easy, low-risk tweak.
bors [Mon, 2 May 2022 03:28:14 +0000 (03:28 +0000)]
Auto merge of #96622 - JohnTitor:rollup-8hckgaj, r=JohnTitor
Rollup of 7 pull requests
Successful merges:
- #94126 (Classify BinaryHeap & LinkedList unit tests as such)
- #96222 (Clarify docs for `from_raw_parts` on `Vec` and `String`)
- #96499 (Make it possible to write doctests for bootstrap)
- #96567 (Fix docs for u32 and i32 logs func)
- #96568 (std::fmt: Various fixes and improvements to documentation)
- #96571 (Add a bathroom stall to weird expressions test)
- #96610 (Update browser-ui-test version to 0.9.0)
Yuki Okushi [Mon, 2 May 2022 01:41:58 +0000 (10:41 +0900)]
Rollup merge of #96568 - EliasHolzmann:fmt_doc_fixes, r=joshtriplett
std::fmt: Various fixes and improvements to documentation
This PR contains the following changes:
- **Added argument index comments to examples for specifying precision**
The examples for specifying the precision have comments explaining which
argument the specifier is referring to. However, for implicit positional
arguments, the examples simply refer to "next arg". To simplify following the
comments, "next arg" was supplemented with the actual resulting argument index.
- **Fixed documentation for specifying precision via `.*`**
The documentation stated that in case of the syntax `{<arg>:<spec>.*}`, "the
`<arg>` part refers to the value to print, and the precision must come in the
input preceding `<arg>`". This is not correct: the <arg> part does indeed refer
to the value to print, but the precision does not come in the input preciding
arg, but in the next implicit input (as if specified with {}).
Fixes #96413.
- **Fix the grammar documentation**
According to the grammar documented, the format specifier `{: }` should not be
legal because of the whitespace it contains. However, in reality, this is
perfectly fine because the actual implementation allows spaces before the
closing brace. Fixes #71088.
Also, the exact meaning of most of the terminal symbols was not specified, for
example the meaning of `identifier`.
- **Removed reference to Formatter::buf and other private fields**
Formatter::buf is not a public field and therefore isn't very helpful in user-
facing documentation. Also, the other public fields of Formatter were removed
during stabilization of std::fmt (4af3494bb0) and can only be accessed via
getters.
- **Improved list of formatting macros**
Two improvements:
1. write! can not only receive a `io::Write`, but also a `fmt::Write` as first argument.
2. The description texts now contain links to the actual macros for easier
navigation.
Yuki Okushi [Mon, 2 May 2022 01:41:56 +0000 (10:41 +0900)]
Rollup merge of #96499 - jyn514:bootstrap-doctests, r=Mark-Simulacrum
Make it possible to write doctests for bootstrap
This probably isn't super useful in practice, but it was easy to fix
and avoids confusing errors about mismatched versions between beta and the default toolchain.
Yuki Okushi [Mon, 2 May 2022 01:41:54 +0000 (10:41 +0900)]
Rollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum
Classify BinaryHeap & LinkedList unit tests as such
All but one of these so-called integration test case are unit tests, just like btree's were (#75531). In addition, reunite the unit tests of linked_list that were split off during #23104 because they needed to remain unit tests (they were later moved to the separate file they are in during #63207). The two sets could remain separate files, but I opted to merge them back together, more or less in the order they used to be, apart from one duplicate name `test_split_off` and one duplicate tiny function `list_from`.
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.
Same applies to `local_parent`/`opt_local_parent`.
bors [Sun, 1 May 2022 22:56:11 +0000 (22:56 +0000)]
Auto merge of #96517 - ferrocene:pa-files-related-to-test, r=Mark-Simulacrum
[compiletest] Extract code to detect files related to a test into a different function
In the code that checks whether a test needs to be re-executed, compiletest checks the modification date of all the files related to the test. I need the list of files related to the test for other purposes inside compiletest, and while I could copy/paste the code `is_up_to_date` runs, that would produce incomplete results if more related files are added in the future.
This PR extracts the code to detect related files into a separate function, allowing the rest of compiletest to access the same data.
bors [Sun, 1 May 2022 20:28:10 +0000 (20:28 +0000)]
Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez
rustdoc: Resolve doc links referring to `macro_rules` items
cc https://github.com/rust-lang/rust/issues/81633
UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
Guillaume Gomez [Sun, 1 May 2022 19:22:38 +0000 (21:22 +0200)]
* Add documentation for settings page rendering functions.
* Improve code.
* Fix some documentation argument types.
* Make settings order the same as before this PR.
* Change timeout to 0 so that browser will render it as fast as possible.
Elias Holzmann [Sat, 30 Apr 2022 00:41:32 +0000 (02:41 +0200)]
std::fmt: Improved list of formatting macros
Two improvements:
1. write! can not only receive a `io::Write`, but also a `fmt::Write` as first argument.
2. The description texts now contain links to the actual macros for easier
navigation.
Elias Holzmann [Sat, 30 Apr 2022 00:40:39 +0000 (02:40 +0200)]
std::fmt: Removed reference to Formatter::buf and other private fields
Formatter::buf is not a public field and therefore isn't very helpful in user-
facing documentation. Also, the other public fields of Formatter were made
private during stabilization of std::fmt (4af3494bb0) and can now only be read
via accessor methods.
Elias Holzmann [Sat, 30 Apr 2022 00:39:59 +0000 (02:39 +0200)]
std::fmt: Fix the grammar documentation
According to the grammar documented, the format specifier `{: }` should not be
legal because of the whitespace it contains. However, in reality, this is
perfectly fine because the actual implementation allows spaces before the
closing brace. Fixes #71088.
Also, the exact meaning of most of the terminal symbols was not specified, for
example the meaning of `identifier`.
Elias Holzmann [Sat, 30 Apr 2022 00:39:27 +0000 (02:39 +0200)]
std::fmt: Added argument index comments to examples for specifying precision
The examples for specifying the precision have comments explaining which
argument the specifier is referring to. However, for implicit positional
arguments, the examples simply talk about "next arg". To make it easier for
readers to follow the comments, "next arg" was supplemented with the actual
resulting argument index.
Elias Holzmann [Sat, 30 Apr 2022 00:38:22 +0000 (02:38 +0200)]
std::fmt: Fixed documentation for specifying precision via `.*`
The documentation stated that in case of the syntax `{<arg>:<spec>.*}`, "the
`<arg>` part refers to the value to print, and the precision must come in the
input preceding `<arg>`". This is not correct: the <arg> part does indeed refer
to the value to print, but the precision does not come in the input preciding
arg, but in the next implicit input (as if specified with {}).
bors [Sun, 1 May 2022 13:10:21 +0000 (13:10 +0000)]
Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk
Add `do yeet` expressions to allow experimentation in nightly
Two main goals for this:
- Ensure that trait restructuring in https://github.com/rust-lang/rust/issues/84277#issuecomment-1066120333 doesn't accidentally close us off from the possibility of doing this in future, as sketched in https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#possibilities-for-yeet
- Experiment with the *existence* of syntax for this, to be able to weight the syntax-vs-library tradeoffs better than we can right now. Notably the syntax (with `do`) and name in this PR are not intended as candidates for stabilization, but they make a good v0 PR for adding this with minimal impact to compiler maintenance or priming one possible name choice over another.
r? `@oli-obk`
The lang `second` for doing this: https://github.com/rust-lang/lang-team/issues/160#issuecomment-1107896716
bors [Sun, 1 May 2022 10:29:39 +0000 (10:29 +0000)]
Auto merge of #96576 - oli-obk:post_monomorphization_error_backtrace, r=lqd
Also report the call site of PME errors locally.
Note this does not produce a full stack all the way to the first call that specifies all monomorphic parameters, it's just shallowly mentioning the last call site.
Tomasz Miąsko [Sun, 1 May 2022 00:00:00 +0000 (00:00 +0000)]
Update `RValue::Discriminant` documentation
`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.
bors [Sun, 1 May 2022 06:41:59 +0000 (06:41 +0000)]
Auto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay
Implement str to [u8] conversion for refcounted containers
This seems motivated to complete the APIs for shared containers since we already have similar allocation-free conversions for strings like `From<Box<[u8]>> for Box<str>`.
bors [Sun, 1 May 2022 00:50:46 +0000 (00:50 +0000)]
Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum
Support arrays of zeros in Vec's __rust_alloc_zeroed optimization
I happened to notice in https://users.rust-lang.org/t/any-advantage-of-box-u64-16-16-16-over-vec-u64/73500/3?u=scottmcm that the calloc optimization wasn't applying to vectors-of-arrays, so here's the easy fix for that.
Scott McMurray [Sat, 26 Mar 2022 06:43:54 +0000 (23:43 -0700)]
Add `do yeet` expressions to allow experimentation in nightly
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.
But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
Auto merge of #96347 - estebank:issue-96292, r=compiler-errors
Erase type params when suggesting fully qualified path
When suggesting the use of a fully qualified path for a method call that
is ambiguous because it has multiple candidates, erase type params in
the resulting code, as they would result in an error when applied. We
replace them with `_` in the output to rely on inference. There might be
cases where this still produces slighlty incomplete suggestions, but it
otherwise produces many more errors in relatively common cases.
Auto merge of #93803 - cjgillot:unify-bounds, r=oli-obk
Handle generic bounds in a uniform way in HIR
Generic bounds in HIR used to be split between bounds in the parameter definition and bounds in a where clause. This PR attempts to store all of those as where predicates.
This effectively desugars
```rust
fn foo<T: Default, U>(x: impl Copy) where U: Clone
```
into
```rust
fn foo<T, U, _V>(x: _V) where T: Default, U: Clone, _V: Copy
```
(where _V is actually hidden and called "impl Copy").
I managed to make compiler warnings more uniform.
About rustdoc: is making this desugaring user-visible acceptable?
About clippy: I don't understand the subtle logic in the `needless-lifetimes` lint.
Oli Scherer [Sat, 30 Apr 2022 09:04:15 +0000 (09:04 +0000)]
Also report the call site of PME errors locally.
Note this does not produce a full stack all the way to the first call that specifies all monomorphic parameters, it's just shallowly mentioning the last call site.
Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow.
This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
Rollup merge of #96562 - michaelwoerister:path-remapping-fixes, r=oli-obk
Fix duplicate directory separator in --remap-path-prefix.
The compiler will currently emit duplicate directory separators when `--remap-path-prefix` has an exact match of the working directory and it is invoked with a relative path to the main source file. For example
will produce the path `abc//src/main.rs` in debuginfo. This is because `some_path.join("")` will append a directory separator to `some_path` and then LLVM does not check if the working directory already ends a directory separator before concatenating it with the relative path.
Rollup merge of #96560 - abrown:update-docs, r=Dylan-DPC
Remove unnecessary environment variable in cf-protection documentation
Before merging the `cf-protection` flag, it was necessary to use a
locally-compiled version of `rustc`. This is no longer the case and the
documentation should reflect this.