]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #98330 - conradludgate:io-slice-mut-docs, r=Dylan-DPC
Yuki Okushi [Tue, 21 Jun 2022 11:08:17 +0000 (20:08 +0900)]
Rollup merge of #98330 - conradludgate:io-slice-mut-docs, r=Dylan-DPC

update ioslice docs to use shared slices

I noticed that IoSlice docs were taking unnecessary mut slices, when they only accept shared slices

2 years agoRollup merge of #98329 - oli-obk:fast_path_ice, r=cjgillot
Yuki Okushi [Tue, 21 Jun 2022 11:08:16 +0000 (20:08 +0900)]
Rollup merge of #98329 - oli-obk:fast_path_ice, r=cjgillot

Avoid an ICE and instead let the compiler report a useful error

Fixes #98299

2 years agoRollup merge of #98323 - lnicola:rust-analyzer-2022-06-21, r=lnicola
Yuki Okushi [Tue, 21 Jun 2022 11:08:15 +0000 (20:08 +0900)]
Rollup merge of #98323 - lnicola:rust-analyzer-2022-06-21, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #98313 - m-ou-se:fix-comments, r=joshtriplett
Yuki Okushi [Tue, 21 Jun 2022 11:08:14 +0000 (20:08 +0900)]
Rollup merge of #98313 - m-ou-se:fix-comments, r=joshtriplett

Remove lies in comments.

> does not have a const constructor

> pub const fn new() -> Self

🤔

2 years agoRollup merge of #98306 - eggyal:add-unevaluated-to-blanket-fallibletypefolder, r...
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.

r? ```@nnethercote```

2 years agoRollup merge of #98278 - nnethercote:some-token-stream-cleanups, r=petrochenkov
Yuki Okushi [Tue, 21 Jun 2022 11:08:12 +0000 (20:08 +0900)]
Rollup merge of #98278 - nnethercote:some-token-stream-cleanups, r=petrochenkov

Some token stream cleanups

Best reviewed one commit at a time.

r? ```@petrochenkov```

2 years agoRollup merge of #98124 - jsha:defer-crates, r=GuillaumeGomez
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.

r? ```@GuillaumeGomez```

Demo: https://rustdoc.crud.net/jsha/defer-crates/std/index.html

2 years agoRollup merge of #98022 - compiler-errors:erroneous-borrowck-span, r=oli-obk
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.

2 years agoRollup merge of #97805 - coolreader18:trace-suggestions, r=oli-obk
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.

2 years agoRollup merge of #97269 - RalfJung:transmute, r=m-ou-se
Yuki Okushi [Tue, 21 Jun 2022 11:08:08 +0000 (20:08 +0900)]
Rollup merge of #97269 - RalfJung:transmute, r=m-ou-se

adjust transmute const stabilization version

With 1.46, this became callable only in `const`/`static` items.

Only since 1.56 is this callable in `const fn`: [changelog](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1560-2021-10-21)

Also see [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/transmute.20const.20fn.20stabilization).

2 years agoRollup merge of #94033 - joshtriplett:documentation-is-running-better-go-catch-it...
Yuki Okushi [Tue, 21 Jun 2022 11:08:07 +0000 (20:08 +0900)]
Rollup merge of #94033 - joshtriplett:documentation-is-running-better-go-catch-it, r=m-ou-se

Improve docs for `is_running` to explain use case

2 years agoAuto merge of #95576 - DrMeepster:box_erasure, r=oli-obk
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.

Hopefully, this is the end of the Box<T, A> ICEs.

2 years agoupdate cpu-usage-over-time-plot script
notseanray [Tue, 29 Mar 2022 18:05:58 +0000 (13:05 -0500)]
update cpu-usage-over-time-plot script

fix tidy checks and correct cpu-usage-over-time-plot script

2 years agoAdd a full regression test for #73727
Yuki Okushi [Tue, 21 Jun 2022 10:08:48 +0000 (19:08 +0900)]
Add a full regression test for #73727

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2 years agoUse futex based thread parker on Fuchsia.
Mara Bos [Fri, 6 May 2022 10:05:40 +0000 (12:05 +0200)]
Use futex based thread parker on Fuchsia.

2 years agoupdate ioslice docs to use shared slices
Conrad Ludgate [Tue, 21 Jun 2022 09:45:17 +0000 (11:45 +0200)]
update ioslice docs to use shared slices

2 years agoAvoid an ICE and instead let the compiler report a useful error
Oli Scherer [Tue, 21 Jun 2022 08:47:02 +0000 (08:47 +0000)]
Avoid an ICE and instead let the compiler report a useful error

2 years agoAuto merge of #97657 - Urgau:check-cfg-many-mut, r=oli-obk
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.

cc `@petrochenkov`

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 21 Jun 2022 05:12:17 +0000 (08:12 +0300)]
:arrow_up: rust-analyzer

2 years agoProvide a segment res in more cases
Michael Goulet [Mon, 20 Jun 2022 01:21:01 +0000 (18:21 -0700)]
Provide a segment res in more cases

2 years agoGive name if anonymous region appears in impl signature
Michael Goulet [Tue, 21 Jun 2022 03:47:25 +0000 (03:47 +0000)]
Give name if anonymous region appears in impl signature

2 years agoAuto merge of #98148 - c410-f3r:assert-compiler, r=oli-obk
bors [Tue, 21 Jun 2022 03:44:54 +0000 (03:44 +0000)]
Auto merge of #98148 - c410-f3r:assert-compiler, r=oli-obk

[RFC 2011] Expand expressions where possible

Tracking issue: https://github.com/rust-lang/rust/issues/44838
Fourth step of https://github.com/rust-lang/rust/pull/96496

Extends https://github.com/rust-lang/rust/pull/97665 considering expressions that are good candidates for expansion.

r? `@oli-obk`

2 years agoAuto merge of #98307 - matthiaskrgr:rollup-rb3huha, r=matthiaskrgr
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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agorustdoc: optimize loading of source sidebar
Jacob Hoffman-Andrews [Mon, 20 Jun 2022 19:41:11 +0000 (12:41 -0700)]
rustdoc: optimize loading of source sidebar

The source sidebar has a setting to remember whether it should be open or
closed. Previously, this setting was handled in source-script.js, which
is loaded with `defer`, meaning it is often run after the document is rendered.
Since CSS renders the source sidebar as closed by default, changing this
after the initial render results in a relayout.

Instead, handle the setting in storage.js, which is the first script to load
and is the only script that blocks render. This avoids a relayout and means
navigating between files with the sidebar open is faster.

2 years agoFix panic by checking if `CStore` has the crate data we want before actually querying it
Guillaume Gomez [Mon, 20 Jun 2022 21:31:40 +0000 (23:31 +0200)]
Fix panic by checking if `CStore` has the crate data we want before actually querying it

2 years agoRemove lies in comments.
Mara Bos [Mon, 20 Jun 2022 20:59:48 +0000 (22:59 +0200)]
Remove lies in comments.

2 years agoImprove docs for `is_running` to explain use case
Josh Triplett [Tue, 15 Feb 2022 22:51:24 +0000 (14:51 -0800)]
Improve docs for `is_running` to explain use case

2 years agoIntegrate `generate_macro_def_id_path` into `href_with_root_path`
Guillaume Gomez [Mon, 20 Jun 2022 20:32:49 +0000 (22:32 +0200)]
Integrate `generate_macro_def_id_path` into `href_with_root_path`

2 years agoAdd test for macro support in "jump to def" feature
Guillaume Gomez [Fri, 26 Nov 2021 20:20:45 +0000 (21:20 +0100)]
Add test for macro support in "jump to def" feature

2 years agoImprove code readability and documentation
Guillaume Gomez [Sat, 18 Jun 2022 13:50:37 +0000 (15:50 +0200)]
Improve code readability and documentation

2 years agoRollup merge of #98296 - JohnTitor:generator-unstable-book-link, r=Dylan-DPC
Matthias Krüger [Mon, 20 Jun 2022 18:13:12 +0000 (20:13 +0200)]
Rollup merge of #98296 - JohnTitor:generator-unstable-book-link, r=Dylan-DPC

Add a link to the unstable book page on Generator doc comment

This makes it easier to jump into the Generator section on the unstable book.

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2 years agoRollup merge of #98276 - compiler-errors:const-format-macro, r=oli-obk
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.

Fixes #93665

2 years agoRollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obk
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:)

Fixes #94866

2 years agoRollup merge of #98235 - liuw:mir-gen-drop-magic-value, r=davidtwco
Matthias Krüger [Mon, 20 Jun 2022 18:13:09 +0000 (20:13 +0200)]
Rollup merge of #98235 - liuw:mir-gen-drop-magic-value, r=davidtwco

Drop magic value 3 from code

Magic value 3 is used to create state for a yield point. It is in fact
the number of reserved variants.

Lift RESERVED_VARIANTS out to module scope and use it instead.

2 years agoImprove loading of crates.js and sidebar-items.js
Jacob Hoffman-Andrews [Wed, 15 Jun 2022 06:25:51 +0000 (23:25 -0700)]
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 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.

Remove excess script fields

2 years agoAuto merge of #93765 - zhangyunhao116:heapsort, r=m-ou-se
bors [Mon, 20 Jun 2022 18:09:30 +0000 (18:09 +0000)]
Auto merge of #93765 - zhangyunhao116:heapsort, r=m-ou-se

Optimize heapsort

The new implementation is about 10% faster than the previous one(sorting random 1000 items).

2 years ago`try_fold_unevaluated` for infallible folders
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.

r? @nnethercote

2 years agodon't alloc error string if no error emitted
klensy [Mon, 20 Jun 2022 17:42:58 +0000 (20:42 +0300)]
don't alloc error string if no error emitted

2 years agoRename ContextInfo into HrefContext
Guillaume Gomez [Sat, 18 Jun 2022 13:32:26 +0000 (15:32 +0200)]
Rename ContextInfo into HrefContext

2 years agoAdd support for macro in "jump to def" feature
Guillaume Gomez [Fri, 26 Nov 2021 20:20:24 +0000 (21:20 +0100)]
Add support for macro in "jump to def" feature

2 years agoAdd a link to the unstable book page on Generator doc comment
Yuki Okushi [Mon, 20 Jun 2022 14:19:10 +0000 (23:19 +0900)]
Add a link to the unstable book page on Generator doc comment

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2 years agoAuto merge of #98292 - Dylan-DPC:rollup-hueb8tm, r=Dylan-DPC
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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #98159 - PrestonFrom:issue_95665, r=petrochenkov
Dylan DPC [Mon, 20 Jun 2022 12:56:41 +0000 (14:56 +0200)]
Rollup merge of #98159 - PrestonFrom:issue_95665, r=petrochenkov

Include ForeignItem when visiting types for WF check

Addresses Issue 95665 by including `hir::Node::ForeignItem` as a valid
type to visit in `diagnostic_hir_wf_check`.

Fixes #95665

2 years agoRollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-se
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.

2 years agoRollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se
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);
```

2 years agoRollup merge of #97149 - ChrisDenton:win_async_pipes, r=m-ou-se
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.

# Example:

```rust
use std::process::{Command, Stdio};

Command::new("cmd")
    .async_pipes(true)
    .stdin(Stdio::piped())
    .stdout(Stdio::piped())
    .stderr(Stdio::piped())
    .spawn()
    .unwrap();
```

2 years agoRollup merge of #96719 - mbartlett21:patch-4, r=Dylan-DPC
Dylan DPC [Mon, 20 Jun 2022 12:56:36 +0000 (14:56 +0200)]
Rollup merge of #96719 - mbartlett21:patch-4, r=Dylan-DPC

Fix the generator example for `pin!()`

The previous generator example is not actually self-referential, since the reference is created after the yield.

CC #93178 (tracking issue)

2 years agoRollup merge of #96609 - ibraheemdev:arc-downcast-unchecked, r=m-ou-se
Dylan DPC [Mon, 20 Jun 2022 12:56:35 +0000 (14:56 +0200)]
Rollup merge of #96609 - ibraheemdev:arc-downcast-unchecked, r=m-ou-se

Add `{Arc, Rc}::downcast_unchecked`

Part of #90850.

2 years agoRollup merge of #94855 - m-ou-se:advance-slice-panic-docs, r=kennytm
Dylan DPC [Mon, 20 Jun 2022 12:56:34 +0000 (14:56 +0200)]
Rollup merge of #94855 - m-ou-se:advance-slice-panic-docs, r=kennytm

Panic when advance_slices()'ing too far and update docs.

This updates advance_slices() to panic when advancing too far, like advance() already does. And updates the docs to say so.

See https://github.com/rust-lang/rust/issues/62726#issuecomment-1065253213

2 years agoRollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
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.

2 years agoWindows: `CommandExt::async_pipes`
Chris Denton [Wed, 18 May 2022 18:52:10 +0000 (19:52 +0100)]
Windows: `CommandExt::async_pipes`

2 years agoAuto merge of #97674 - nnethercote:oblig-forest-tweaks, r=nikomatsakis
bors [Mon, 20 Jun 2022 10:58:56 +0000 (10:58 +0000)]
Auto merge of #97674 - nnethercote:oblig-forest-tweaks, r=nikomatsakis

Obligation forest tweaks

A few minor improvements to the code.

r? `@nikomatsakis`

2 years ago`Stdio::make_pipe`
Chris Denton [Wed, 18 May 2022 19:14:29 +0000 (20:14 +0100)]
`Stdio::make_pipe`

2 years agoDrop magic value 3 from code
Wei Liu [Sat, 18 Jun 2022 17:19:24 +0000 (17:19 +0000)]
Drop magic value 3 from code

Magic value 3 is used to create state for a yield point. It is in fact
the number of reserved variants.

Lift RESERVED_VARIANTS out to module scope and use it instead.

2 years agoOptimize heapsort
zhangyunhao [Mon, 20 Jun 2022 08:30:27 +0000 (08:30 +0000)]
Optimize heapsort

2 years agoAuto merge of #98284 - JohnTitor:rollup-7lbs143, r=JohnTitor
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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoShow #![feature] in example.
Mara Bos [Mon, 20 Jun 2022 08:00:55 +0000 (10:00 +0200)]
Show #![feature] in example.

2 years agoRollup merge of #98281 - Nilstrieb:map-drain-typo, r=JohnTitor
Yuki Okushi [Mon, 20 Jun 2022 07:41:50 +0000 (16:41 +0900)]
Rollup merge of #98281 - Nilstrieb:map-drain-typo, r=JohnTitor

Fix typo in `HashMap::drain` docs

It's a map, not a vector.

Fixes #98275.

2 years agoRollup merge of #98274 - compiler-errors:self-type-error, r=cjgillot
Yuki Okushi [Mon, 20 Jun 2022 07:41:49 +0000 (16:41 +0900)]
Rollup merge of #98274 - compiler-errors:self-type-error, r=cjgillot

Minor improvements on error for `Self` type in items that don't allow it

Fixes #93796

2 years agoRollup merge of #98273 - Piturnah:patch-1, r=compiler-errors
Yuki Okushi [Mon, 20 Jun 2022 07:41:48 +0000 (16:41 +0900)]
Rollup merge of #98273 - Piturnah:patch-1, r=compiler-errors

Fix minor documentation typo

Fixes incorrect pluralisation of `crate` in documentation for rustc_trait_selection

2 years agoRollup merge of #98268 - compiler-errors:disallowed-generics-better, r=lcnr
Yuki Okushi [Mon, 20 Jun 2022 07:41:47 +0000 (16:41 +0900)]
Rollup merge of #98268 - compiler-errors:disallowed-generics-better, r=lcnr

Improve `lifetime arguments are not allowed on` error message

Actually mention what thing we're improperly trying to add lifetime generics to.

2 years agoRollup merge of #98183 - dtolnay:emptybound, r=lcnr
Yuki Okushi [Mon, 20 Jun 2022 07:41:46 +0000 (16:41 +0900)]
Rollup merge of #98183 - dtolnay:emptybound, r=lcnr

Fix pretty printing of empty bound lists in where-clause

Repro:

```rust
macro_rules! assert_item_stringify {
    ($item:item $expected:literal) => {
        assert_eq!(stringify!($item), $expected);
    };
}

fn main() {
    assert_item_stringify! {
        fn f<'a, T>() where 'a:, T: {}
        "fn f<'a, T>() where 'a:, T: {}"
    }
}
```

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 `:`
```

2 years agopoint at private fields in struct literal
Takayuki Maeda [Mon, 20 Jun 2022 07:29:05 +0000 (16:29 +0900)]
point at private fields in struct literal

2 years agoFix typo in `HashMap::drain` docs
nils [Mon, 20 Jun 2022 07:17:08 +0000 (09:17 +0200)]
Fix typo in `HashMap::drain` docs

It's a map, not a vector.

2 years agoAuto merge of #98264 - compiler-errors:missing-arg-placeholder, r=jackh726
bors [Mon, 20 Jun 2022 05:37:17 +0000 (05:37 +0000)]
Auto merge of #98264 - compiler-errors:missing-arg-placeholder, r=jackh726

Make missing argument placeholder more obvious that it's a placeholder

Use `/* ty */` instead of `{ty}`, since people might be misled into thinking that this is valid syntax, and not just a diagnostic placeholder.

Fixes #96880

2 years agoAdd blank lines between methods in `proc_macro_server.rs`.
Nicholas Nethercote [Mon, 20 Jun 2022 03:52:48 +0000 (13:52 +1000)]
Add blank lines between methods in `proc_macro_server.rs`.

Because that's the standard way of doing it.

2 years agoInclude ForeignItem when visiting types for WF check
Preston From [Thu, 16 Jun 2022 04:44:07 +0000 (22:44 -0600)]
Include ForeignItem when visiting types for WF check

Addresses Issue 95665 by including `hir::Node::ForeignItem` as a valid
type to visit in `diagnostic_hir_wf_check`.

Fixes #95665

2 years agoMerge `TokenStreamBuilder::push` into `TokenStreamBuilder::build`.
Nicholas Nethercote [Mon, 20 Jun 2022 03:00:43 +0000 (13:00 +1000)]
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.

2 years agoMention formatting macros when encountering ArgumentV1::new in const
Michael Goulet [Mon, 20 Jun 2022 03:13:08 +0000 (20:13 -0700)]
Mention formatting macros when encountering ArgumentV1::new in const

2 years agoAuto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
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.

2 years agoDon't suggest adding Self as a type parameter
Michael Goulet [Mon, 20 Jun 2022 02:25:50 +0000 (19:25 -0700)]
Don't suggest adding Self as a type parameter

2 years agoMention what item is using an invalid `Self` type
Michael Goulet [Mon, 20 Jun 2022 02:24:28 +0000 (19:24 -0700)]
Mention what item is using an invalid `Self` type

2 years agoFix minor documentation typo
Peter Hebden [Mon, 20 Jun 2022 02:30:21 +0000 (03:30 +0100)]
Fix minor documentation typo

Incorrect pluralisation of `crate`

2 years agoBe more specific for what lifetimes are not allowed on
Michael Goulet [Mon, 20 Jun 2022 00:54:19 +0000 (17:54 -0700)]
Be more specific for what lifetimes are not allowed on

2 years agoAuto merge of #98265 - JohnTitor:rollup-wtfqc4g, r=JohnTitor
bors [Mon, 20 Jun 2022 00:40:07 +0000 (00:40 +0000)]
Auto merge of #98265 - JohnTitor:rollup-wtfqc4g, r=JohnTitor

Rollup of 4 pull requests

Successful merges:

 - #95534 (Add `core::mem::copy` to complement `core::mem::drop`.)
 - #97912 (Stabilize `Path::try_exists()` and improve doc)
 - #98225 (Make debug_triple depend on target json file content rather than file path)
 - #98257 (Fix typos in `IntoFuture` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoBe more hygenic with spans
Michael Goulet [Sun, 19 Jun 2022 23:46:26 +0000 (16:46 -0700)]
Be more hygenic with spans

2 years agoUse `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`
Michael Goulet [Sun, 19 Jun 2022 23:27:29 +0000 (16:27 -0700)]
Use `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`

2 years agoOnly omit trailing comma if block doesn't come from macro expansion
Michael Goulet [Sun, 19 Jun 2022 23:27:26 +0000 (16:27 -0700)]
Only omit trailing comma if block doesn't come from macro expansion

2 years agoRemove `TokenStream::from_streams`.
Nicholas Nethercote [Sun, 19 Jun 2022 23:33:08 +0000 (09:33 +1000)]
Remove `TokenStream::from_streams`.

By inlining it into the only non-test call site. The one test call site
is changed to use `TokenStreamBuilder`.

2 years agoRemove `Cursor::index`.
Nicholas Nethercote [Sun, 19 Jun 2022 23:27:58 +0000 (09:27 +1000)]
Remove `Cursor::index`.

It's unused.

2 years agoRemove `Cursor::append`.
Nicholas Nethercote [Sun, 19 Jun 2022 23:14:18 +0000 (09:14 +1000)]
Remove `Cursor::append`.

It's a weird function: it lets you modify the token stream in the middle
of iteration. There is only one call site, and it is only used for the
rare `ProceduralMasquerade` legacy case.

2 years agoRollup merge of #98257 - kadiwa4:into_future_doc_typos, r=Dylan-DPC
Yuki Okushi [Sun, 19 Jun 2022 22:37:43 +0000 (07:37 +0900)]
Rollup merge of #98257 - kadiwa4:into_future_doc_typos, r=Dylan-DPC

Fix typos in `IntoFuture` docs

2 years agoRollup merge of #98225 - bjorn3:stable_target_json_hash, r=nagisa
Yuki Okushi [Sun, 19 Jun 2022 22:37:42 +0000 (07:37 +0900)]
Rollup merge of #98225 - bjorn3:stable_target_json_hash, r=nagisa

Make debug_triple depend on target json file content rather than file path

This ensures that changes to target json files will force a recompilation. And more importantly that moving the files doesn't force a recompilation.

This should fix https://github.com/Rust-for-Linux/linux/issues/792 (cc ``@ojeda)``

2 years agoRollup merge of #97912 - Kixunil:stabilize_path_try_exists, r=dtolnay
Yuki Okushi [Sun, 19 Jun 2022 22:37:41 +0000 (07:37 +0900)]
Rollup merge of #97912 - Kixunil:stabilize_path_try_exists, r=dtolnay

Stabilize `Path::try_exists()` and improve doc

This stabilizes the `Path::try_exists()` method which returns
`Result<bool, io::Error>` instead of `bool` allowing handling of errors
unrelated to the file not existing. (e.g permission errors)

Along with the stabilization it also:

* Warns that the `exists()` method is error-prone and suggests to use
  the newly stabilized one.
* Suggests it instead of `metadata()` to handle errors.
* Mentions TOCTOU bugs to avoid false assumption that `try_exists()` is
  completely safe fixed version of `exists()`.
* Renames the feature of still-unstable `std::fs::try_exists()` to
  `fs_try_exists` to avoid name conflict.

The tracking issue #83186 remains open to track `fs_try_exists`.

2 years agoRollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett
Yuki Okushi [Sun, 19 Jun 2022 22:37:40 +0000 (07:37 +0900)]
Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett

Add `core::mem::copy` to complement `core::mem::drop`.

This is useful for combinators. I didn't add `clone` since you can already
use `Clone::clone` in its place; copy has no such corresponding function.

2 years agoAuto merge of #97268 - jyn514:faster-assemble, r=Mark-Simulacrum
bors [Sun, 19 Jun 2022 22:22:07 +0000 (22:22 +0000)]
Auto merge of #97268 - jyn514:faster-assemble, r=Mark-Simulacrum

Make "Assemble stage1 compiler" orders of magnitude faster (take 2)

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.

- Panic if we generate a symbolic link in a tarball
- Change install to use copy internally, like in my previous PR
- Change copy to dereference symbolic links, which avoids the previous regression in #96803.

I also took the liberty of fixing `x dist llvm-tools` to work even if you don't call `x build` previously.

2 years agoMake missing argument placeholder more obvious that it's a placeholder
Michael Goulet [Sun, 19 Jun 2022 22:10:42 +0000 (15:10 -0700)]
Make missing argument placeholder more obvious that it's a placeholder

2 years agoAdd `core::mem::copy` to complement `core::mem::drop`.
Joshua Nelson [Thu, 31 Mar 2022 18:01:26 +0000 (13:01 -0500)]
Add `core::mem::copy` to complement `core::mem::drop`.

This is useful for combinators. I didn't add `clone` since you can already
use `Clone::clone` in its place; copy has no such corresponding function.

2 years agoOnly use special async fn case for actual async fns in borrowck diagnostics.
Camille GILLOT [Fri, 13 May 2022 17:08:57 +0000 (19:08 +0200)]
Only use special async fn case for actual async fns in borrowck diagnostics.

2 years agoMake "Assemble stage1 compiler" orders of magnitude faster
Joshua Nelson [Sat, 7 May 2022 03:42:36 +0000 (22:42 -0500)]
Make "Assemble stage1 compiler" orders of magnitude faster

This used to take upwards of 5 seconds for me locally. I found that the
culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change
it to use `copy()` internally, which uses hard links instead when
available.

Note that this has a change in behavior: Installing a file will also
change permissions on the source, not just the destination, if hard
links are used.

To avoid changing the behavior on symlinks for existing code, I
introduce a new function `copy_internal` which only dereferences
symlinks when told to do so.

2 years agoPanic if `dist` generates a symbolic link in a generated tarball
Joshua Nelson [Thu, 26 May 2022 15:27:44 +0000 (11:27 -0400)]
Panic if `dist` generates a symbolic link in a generated tarball

This avoids regressions in rustup-toolchain-install-master

2 years agoLeave the responsibility to create `Fresh` lifetimes to lowering.
Camille GILLOT [Mon, 6 Jun 2022 07:02:24 +0000 (09:02 +0200)]
Leave the responsibility to create `Fresh` lifetimes to lowering.

2 years agoGreatly improve error reporting for futures and generators in `note_obligation_cause_...
Joshua Nelson [Sun, 19 Jun 2022 18:59:36 +0000 (13:59 -0500)]
Greatly improve error reporting for futures and generators in `note_obligation_cause_code`

Most futures don't go through this code path, because they're caught by
`maybe_note_obligation_cause_for_async_await`. But all generators do,
and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses.

At some point, we may want to consider unifying this with the code for `maybe_note_async_await`,
so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points.
But both functions are quite complicated, and it's not clear to me how to combine them;
this seems like a good incremental improvement.

2 years agoMake matches exhaustive.
Camille GILLOT [Sun, 5 Jun 2022 19:55:30 +0000 (21:55 +0200)]
Make matches exhaustive.

2 years agoRemove the `region` terminology.
Camille GILLOT [Sun, 5 Jun 2022 19:43:02 +0000 (21:43 +0200)]
Remove the `region` terminology.

2 years agoAuto merge of #98247 - jackh726:regionkind-rustc-type-ir, r=compiler-errors
bors [Sun, 19 Jun 2022 19:55:45 +0000 (19:55 +0000)]
Auto merge of #98247 - jackh726:regionkind-rustc-type-ir, r=compiler-errors

Move RegionKind to rustc_type_ir

(Also UniverseIndex)

r? rust-lang/types

2 years agoFix documentation for with_capacity and reserve families of methods
jmaargh [Sat, 9 Apr 2022 15:42:26 +0000 (16:42 +0100)]
Fix documentation for with_capacity and reserve families of methods

Documentation for the following methods

    with_capacity
    with_capacity_in
    with_capacity_and_hasher
    reserve
    reserve_exact
    try_reserve
    try_reserve_exact

was inconsistent and often not entirely correct where they existed on the following types

    Vec
    VecDeque
    String
    OsString
    PathBuf
    BinaryHeap
    HashSet
    HashMap
    BufWriter
    LineWriter

since the allocator is allowed to allocate more than the requested capacity in all such cases, and will frequently "allocate" much more in the case of zero-sized types (I also checked BufReader, but there the docs appear to be accurate as it appears to actually allocate the exact capacity).

Some effort was made to make the documentation more consistent between types as well.

Fix with_capacity* methods for Vec

Fix *reserve*  methods for Vec

Fix docs for *reserve* methods of VecDeque

Fix docs for String::with_capacity

Fix docs for *reserve* methods of String

Fix docs for OsString::with_capacity

Fix docs for *reserve* methods on OsString

Fix docs for with_capacity* methods on HashSet

Fix docs for *reserve methods of HashSet

Fix docs for with_capacity* methods of HashMap

Fix docs for *reserve methods on HashMap

Fix expect messages about OOM in doctests

Fix docs for BinaryHeap::with_capacity

Fix docs for *reserve* methods of BinaryHeap

Fix typos

Fix docs for with_capacity on BufWriter and LineWriter

Fix consistent use of `hasher` between `HashMap` and `HashSet`

Fix warning in doc test

Add test for capacity of vec with ZST

Fix doc test error

2 years agoAuto merge of #98224 - eddyb:proc-macro-spurious-repr, r=bjorn3
bors [Sun, 19 Jun 2022 17:32:12 +0000 (17:32 +0000)]
Auto merge of #98224 - eddyb:proc-macro-spurious-repr, r=bjorn3

proc_macro/bridge: remove `#[repr(C)]` from non-ABI-relevant types.

Not sure how this happened, maybe some of these were passed through the bridge a long time ago?

r? `@bjorn3`

2 years agoPreserve the path of the target spec json file for usage by rustdoc
bjorn3 [Sat, 18 Jun 2022 10:48:46 +0000 (10:48 +0000)]
Preserve the path of the target spec json file for usage by rustdoc

2 years agotypos in `IntoFuture` docs
KaDiWa4 [Sun, 19 Jun 2022 15:07:38 +0000 (17:07 +0200)]
typos in `IntoFuture` docs