bors [Wed, 22 Jun 2022 10:48:58 +0000 (10:48 +0000)]
Auto merge of #98279 - cjgillot:all-fresh-nofn, r=petrochenkov
Create elided lifetime parameters for function-like types
Split from https://github.com/rust-lang/rust/pull/97720
This PR refactor lifetime generic parameters in bare function types and parenthesized traits to introduce the additional required lifetimes as fresh parameters in a `for<>` bound.
This PR does the same to lifetimes appearing in closure signatures, and as-if introducing `for<>` bounds on closures (without the associated change in semantics).
Yuki Okushi [Wed, 22 Jun 2022 06:16:12 +0000 (15:16 +0900)]
Rollup merge of #97818 - compiler-errors:rpit-error-spanned, r=oli-obk
Point at return expression for RPIT-related error
Certainly this needs some diagnostic refining, but I wanted to show that it was possible first and foremost. Not sure if this is the right approach. Open to feedback.
Yuki Okushi [Wed, 22 Jun 2022 06:16:11 +0000 (15:16 +0900)]
Rollup merge of #97516 - RalfJung:atomics, r=joshtriplett
clarify how Rust atomics correspond to C++ atomics
``@cbeuw`` noted in https://github.com/rust-lang/miri/pull/1963 that the correspondence between C++ atomics and Rust atomics is not quite as obvious as one might think, since in Rust I can use `get_mut` to treat previously non-atomic data as atomic. However, I think using C++20 `atomic_ref`, we can establish a suitable relation between the two -- or do you see problems with that ``@cbeuw?`` (I recall you said there was some issue, but it was deep inside that PR and Github makes it impossible to find...)
Cc ``@thomcc;`` not sure whom else to ping for atomic memory model things.
bors [Wed, 22 Jun 2022 00:28:20 +0000 (00:28 +0000)]
Auto merge of #98359 - JohnTitor:rollup-v30vyzr, r=JohnTitor
Rollup of 6 pull requests
Successful merges:
- #97867 (lub: don't bail out due to empty binders)
- #98099 (interpret: convert_tag_add_extra: allow tagger to raise errors)
- #98199 (Move some tests to more reasonable directories)
- #98334 (Add a full regression test for #73727)
- #98336 (Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint)
- #98344 (This comment is out dated and misleading, the arm is about TAITs)
Yuki Okushi [Tue, 21 Jun 2022 22:04:04 +0000 (07:04 +0900)]
Rollup merge of #98336 - fmease:remove-faulty-doc-hidden-lint, r=GuillaumeGomez
Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint
Fixes #96890.
It was found out that `#[doc(hidden)]` on trait impl items does indeed have an effect on the generated documentation (see the linked issue). In my opinion and the one of [others](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60/near/281846219), rustdoc's output is actually a bit flawed in that regard but that should be tracked in a new issue I suppose (I will open an issue for that in the near future).
The check was introduced in #96008 which is marked to be part of version `1.62` (current `beta`). As far as I understand, this means that **this PR needs to be backported** to `beta` to fix #96890 on time. Correct me if I am wrong.
CC `@dtolnay` (in case you would like to agree or disagree with my decision to fully remove this check)
Yuki Okushi [Tue, 21 Jun 2022 22:03:59 +0000 (07:03 +0900)]
Rollup merge of #97867 - lcnr:lub-binder, r=oli-obk
lub: don't bail out due to empty binders
allows for the following to compile. The equivalent code using `struct Wrapper<'upper>(fn(&'upper ());` already compiles on stable.
```rust
let _: fn(&'upper ()) = match v {
true => lt_in_fn::<'a>(),
false => lt_in_fn::<'b>(),
};
```
see https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7034a677190110941223cafac6632f70 for a complete example
bors [Tue, 21 Jun 2022 16:24:56 +0000 (16:24 +0000)]
Auto merge of #98098 - bjorn3:archive_refactor, r=michaelwoerister
Remove the source archive functionality of ArchiveWriter
We now build archives through strictly additive means rather than taking an existing archive and potentially substracting parts. This is simpler and makes it easier to swap out the archive writer in https://github.com/rust-lang/rust/pull/97485.
Yuki Okushi [Tue, 21 Jun 2022 11:08:13 +0000 (20:08 +0900)]
Rollup merge of #98306 - eggyal:add-unevaluated-to-blanket-fallibletypefolder, r=nnethercote
`try_fold_unevaluated` for infallible folders
#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override.
Yuki Okushi [Tue, 21 Jun 2022 11:08:11 +0000 (20:08 +0900)]
Rollup merge of #98124 - jsha:defer-crates, r=GuillaumeGomez
Improve loading of crates.js and sidebar-items.js
Now that the "All Crates" dropdown is only rendered on the search results page,
there is no need to load crates.js on most pages. Load it only on crate pages.
Also, add the `defer` attribute so it does not block HTML parsing.
For sidebar-items.js, move the script tag to `<head>`. Since it already has the
defer attribute it won't block loading. The defer attribute does preserve
ordering between scripts, so instead of the callback on load, it can set a
global variable on load, which is slightly simpler. Also, since it is required
to finish rendering the page, beginning its load earlier is better.
Remove generation and handling of sidebar-vars. Everything there can be computed
with information available in JS via other means.
Remove the extra_scripts fields of the `Page` template. They were only
used by source-script.js and source-files.js, which are now linked by the template
based on whether it is rendering a source page.
Remove the "other" wrapper in the sidebar. It was unnecessary.
Yuki Okushi [Tue, 21 Jun 2022 11:08:10 +0000 (20:08 +0900)]
Rollup merge of #98022 - compiler-errors:erroneous-borrowck-span, r=oli-obk
Fix erroneous span for borrowck error
I am not confident that this is the correct fix, but it does the job. Open to suggestions for a real fix instead.
Fixes #97997
The issue is that we pass a [dummy location](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/mir/visit.rs.html#302) when type-checking the ["required consts"](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.required_consts) that are needed by the MIR body during borrowck. This means that when we fail to evaluate the constant, we use the span of `bb0[0]`, instead of the actual span of the constant.
There are quite a few other places that use `START_BLOCK.start_location()`, `Location::START`, etc. when calling for a random/unspecified `Location` value. This is because, unlike (for example) `Span`, we don't have a dummy/miscellaneous value to use instead. I would appreciate guidance (either in this PR, or a follow-up) on what needs to be done to clean this up in general.
Yuki Okushi [Tue, 21 Jun 2022 11:08:09 +0000 (20:08 +0900)]
Rollup merge of #97805 - coolreader18:trace-suggestions, r=oli-obk
Add proper tracing spans to rustc_trait_selection::traits::error_reporting
While I was trying to figure out #97704 I did some of this to make the logs more legible, so I figured I'd do the whole module and open a PR with it. afaict this is an ongoing process in the compiler from the log->tracing transition? but lmk if there was a reason for the more verbose forms of logging as they are.
Also, for some of the functions with only one log in them, I put the function name as a message for that log instead of `#[instrument]`-ing the whole function with a span? but maybe the latter would actually be preferable, I'm not actually sure.
bors [Tue, 21 Jun 2022 11:00:39 +0000 (11:00 +0000)]
Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obk
Remove dereferencing of Box from codegen
Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains.
bors [Tue, 21 Jun 2022 07:40:32 +0000 (07:40 +0000)]
Auto merge of #97657 - Urgau:check-cfg-many-mut, r=oli-obk
Use get_many_mut to reduce the cost of setting up check cfg values
This PR use the newly added [`get_many_mut`](https://github.com/rust-lang/rust/issues/97601) function in [`HashMap`](https://doc.rust-lang.org/nightly/std/collections/hash_map/struct.HashMap.html#method.get_many_mut) to reduce the cost of setting up the initial check cfg values.
bors [Mon, 20 Jun 2022 22:34:50 +0000 (22:34 +0000)]
Auto merge of #98307 - matthiaskrgr:rollup-rb3huha, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #98235 (Drop magic value 3 from code)
- #98267 (Don't omit comma when suggesting wildcard arm after macro expr)
- #98276 (Mention formatting macros when encountering `ArgumentV1` method in const)
- #98296 (Add a link to the unstable book page on Generator doc comment)
Matthias Krüger [Mon, 20 Jun 2022 18:13:11 +0000 (20:13 +0200)]
Rollup merge of #98276 - compiler-errors:const-format-macro, r=oli-obk
Mention formatting macros when encountering `ArgumentV1` method in const
Also open to just closing this if it's overkill. There are a lot of other distracting error messages around, so maybe it's not worth fixing just this one.
Matthias Krüger [Mon, 20 Jun 2022 18:13:10 +0000 (20:13 +0200)]
Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obk
Don't omit comma when suggesting wildcard arm after macro expr
* Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()`
* Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro
* Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier :rose:)
Now that the "All Crates" dropdown is only rendered on the search results page,
there is no need to load crates.js on most pages. Load it only on crate pages.
Also, add the `defer` attribute so it does not block page rendering.
For sidebar-items.js, move the script tag to `<head>`. Since it already has the
defer attribute it won't block loading. The defer attribute does preserve
ordering between scripts, so instead of the callback on load, it can set a
global variable on load, which is slightly simpler. Also, since it is required
to finish rendering the page, beginning its load earlier is better.
Remove generation and handling of sidebar-vars. Everything there can be computed
with information available in JS via other means.
Remove the "other" wrapper in the sidebar. It was unnecessary.
Alan Egerton [Mon, 20 Jun 2022 18:03:37 +0000 (19:03 +0100)]
`try_fold_unevaluated` for infallible folders
#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override.
bors [Mon, 20 Jun 2022 13:24:31 +0000 (13:24 +0000)]
Auto merge of #98292 - Dylan-DPC:rollup-hueb8tm, r=Dylan-DPC
Rollup of 8 pull requests
Successful merges:
- #93080 (Implement `core::slice::IterMut::as_mut_slice` and `impl<T> AsMut<[T]> for IterMut<'_, T>`)
- #94855 (Panic when advance_slices()'ing too far and update docs.)
- #96609 (Add `{Arc, Rc}::downcast_unchecked`)
- #96719 (Fix the generator example for `pin!()`)
- #97149 (Windows: `CommandExt::async_pipes`)
- #97150 (`Stdio::makes_pipe`)
- #97837 (Document Rust's stance on `/proc/self/mem`)
- #98159 (Include ForeignItem when visiting types for WF check)
Dylan DPC [Mon, 20 Jun 2022 12:56:40 +0000 (14:56 +0200)]
Rollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-se
Document Rust's stance on `/proc/self/mem`
Add documentation to `std::os::unix::io` describing Rust's stance on
`/proc/self/mem`, treating it as an external entity which is outside
the scope of Rust's safety guarantees.
Dylan DPC [Mon, 20 Jun 2022 12:56:39 +0000 (14:56 +0200)]
Rollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se
`Stdio::makes_pipe`
Wrappers around `std::process::Command` may want to be able to override pipe creation. However, [`std::process::Stdio`](https://doc.rust-lang.org/std/process/struct.Stdio.html) is opaque so there's no way to tell if `Command` was told to create new pipes or not.
This is in some ways a more generic (and cross-platform) alternative to #97149. However, unlike that feature, this comes with the price of the user needing to actually create their own pipes rather than reusing the std one. So I think it stands (or not) on its own.
# Example
```rust
#![feature(stdio_makes_pipe)]
use std::process::Stdio;
let io = Stdio::piped();
assert_eq!(io.makes_pipe(), true);
```
Dylan DPC [Mon, 20 Jun 2022 12:56:38 +0000 (14:56 +0200)]
Rollup merge of #97149 - ChrisDenton:win_async_pipes, r=m-ou-se
Windows: `CommandExt::async_pipes`
Discussed in https://github.com/tokio-rs/tokio/issues/4670 was the need for third party crates to be able to force `process::Command::spawn` to create pipes as async.
This implements the suggestion for a `async_pipes` method that gives third party crates that option.
Dylan DPC [Mon, 20 Jun 2022 12:56:33 +0000 (14:56 +0200)]
Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
Implement `core::slice::IterMut::as_mut_slice` and `impl<T> AsMut<[T]> for IterMut<'_, T>`
As per [the zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60std.3A.3Aslice.3A.3AIterMut.3A.3Aas_mut_slice.60), the `AsMut` impl has been commented out, with a comment near the `#[unstable(...)]` to uncomment it when `as_mut_slice` gets stabilized.
bors [Mon, 20 Jun 2022 08:18:07 +0000 (08:18 +0000)]
Auto merge of #98284 - JohnTitor:rollup-7lbs143, r=JohnTitor
Rollup of 5 pull requests
Successful merges:
- #98183 (Fix pretty printing of empty bound lists in where-clause)
- #98268 (Improve `lifetime arguments are not allowed on` error message)
- #98273 (Fix minor documentation typo)
- #98274 (Minor improvements on error for `Self` type in items that don't allow it)
- #98281 (Fix typo in `HashMap::drain` docs)
Previously this assertion would fail because rustc renders the where-clause as `where 'a, T` which is invalid syntax.
This PR makes the above assertion pass.
This bug also affects `-Zunpretty=expanded`. The intention is for that to emit syntactically valid code, but the buggy output is not valid Rust syntax.
```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
fn f<'a, T>() where 'a, T {}
```
```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded | rustc -
error: expected `:`, found `,`
--> <anon>:7:23
|
7 | fn f<'a, T>() where 'a, T {}
| ^ expected `:`
```
Merge `TokenStreamBuilder::push` into `TokenStreamBuilder::build`.
Both functions do some modifying of streams using `make_mut`:
- `push` sometimes glues the first token of the next stream to the last
token of the first stream.
- `build` appends tokens to the first stream.
By doing all of this in the one place, things are simpler. The first
stream can be modified in both ways (if necessary) in the one place, and
any next stream with the first token removed doesn't need to be stored.
bors [Mon, 20 Jun 2022 03:08:52 +0000 (03:08 +0000)]
Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
Fix `SourceScope` for `if let` bindings.
Fixes #97799.
I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.