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`.
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.
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.
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.
This new enum entry was introduced in https://reviews.llvm.org/D122268,
and if I'm reading correctly there's no case where we'd ever encounter
it in our uses of LLVM. To preserve the ability to compile this file
with -Werror -Wswitch we add an explicit case for this entry.
this is a breaking change in order to fix a soundness bug.
Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't.
Andrew Brown [Fri, 29 Apr 2022 17:32:34 +0000 (10:32 -0700)]
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.
Auto merge of #96468 - davidtwco:diagnostic-translation-subdiagnostic, r=oli-obk
macros: subdiagnostic derive
Add a new macro, `#[derive(SessionSubdiagnostic)]`, which can be applied to structs that represent subdiagnostics, such as labels, notes, helps or suggestions.
`#[derive(SessionSubdiagnostic)]` can be used with the existing `#[derive(SessionDiagnostic)]`. All diagnostics implemented using either derive are translatable, and this new derive should make it easier to port existing diagnostics to using these derives.
For example, consider the following subdiagnostic types...
Auto merge of #96548 - Dylan-DPC:rollup-m3xkqxg, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #96477 (Update data layout string for wasm64-unknown-unknown)
- #96481 (HashMap doc: Don't use monospace font for 'Entry Api')
- #96492 (Revert "Re-export core::ffi types from std::ffi")
- #96516 (Revert diagnostic duplication and accidental stabilization)
- #96523 (Add ``@feat.00`` symbol to symbols.o for COFF)
Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.
We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
David Wood [Wed, 27 Apr 2022 04:43:36 +0000 (05:43 +0100)]
macros: allow setting applicability in attribute
In the initial implementation of the `SessionSubdiagnostic`, the
`Applicability` of a suggestion can be set both as a field and as part
of the attribute, this commit adds the same support to the original
`SessionDiagnostic` derive.
David Wood [Tue, 26 Apr 2022 05:17:33 +0000 (06:17 +0100)]
errors: `span_suggestion` takes `impl ToString`
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.
Auto merge of #96393 - joboet:pthread_parker, r=thomcc
std: directly use pthread in UNIX parker implementation
`Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways.
This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives.
I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
Auto merge of #96528 - Dylan-DPC:rollup-iedbjli, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #95312 (Ensure that `'_` and GAT yields errors)
- #96405 (Migrate ambiguous plus diagnostic to the new derive macro)
- #96409 (Recover suggestions to introduce named lifetime under NLL)
- #96433 (rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`)
- #96480 (Fixed grammatical error in example comment)
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`
Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.
After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.
cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``