]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd separate impl of unwrap_failed to avoid constructing trait objects
Manish Goregaokar [Fri, 10 Dec 2021 07:42:26 +0000 (13:12 +0530)]
Add separate impl of unwrap_failed to avoid constructing trait objects

2 years agoinline Option panics on panic_immediate_abort
Manish Goregaokar [Fri, 10 Dec 2021 07:38:06 +0000 (13:08 +0530)]
inline Option panics on panic_immediate_abort

2 years agoinline slice panics on panic_immediate_abort
Manish Goregaokar [Fri, 10 Dec 2021 07:35:06 +0000 (13:05 +0530)]
inline slice panics on panic_immediate_abort

2 years agoAuto merge of #85157 - the8472:drain-drop-in-place, r=Mark-Simulacrum
bors [Thu, 9 Dec 2021 15:01:42 +0000 (15:01 +0000)]
Auto merge of #85157 - the8472:drain-drop-in-place, r=Mark-Simulacrum

replace vec::Drain drop loops with drop_in_place

The `Drain::drop` implementation came up in https://github.com/rust-lang/rust/pull/82185#issuecomment-789584796 as potentially interfering with other optimization work due its widespread use somewhere in `println!`

`@rustbot` label T-libs-impl

2 years agoAuto merge of #81156 - DrMeepster:read_buf, r=joshtriplett
bors [Thu, 9 Dec 2021 10:11:55 +0000 (10:11 +0000)]
Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplett

Implement most of RFC 2930, providing the ReadBuf abstraction

This replaces the `Initializer` abstraction for permitting reading into uninitialized buffers, closing #42788.

This leaves several APIs described in the RFC out of scope for the initial implementation:

* read_buf_vectored
* `ReadBufs`

Closes #42788, by removing the relevant APIs.

2 years agoAuto merge of #91692 - matthiaskrgr:rollup-u7dvh0n, r=matthiaskrgr
bors [Thu, 9 Dec 2021 07:08:32 +0000 (07:08 +0000)]
Auto merge of #91692 - matthiaskrgr:rollup-u7dvh0n, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #87599 (Implement concat_bytes!)
 - #89999 (Update std::env::temp_dir to use GetTempPath2 on Windows when available.)
 - #90796 (Remove the reg_thumb register class for asm! on ARM)
 - #91042 (Use Vec extend instead of repeated pushes on several places)
 - #91634 (Do not attempt to suggest help for overly malformed struct/function call)
 - #91685 (Install llvm tools to sysroot when assembling local toolchain)

Failed merges:

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

2 years agoRollup merge of #91685 - Aaron1011:install-llvm-tools, r=Mark-Simulacrum
Matthias Krüger [Thu, 9 Dec 2021 04:08:34 +0000 (05:08 +0100)]
Rollup merge of #91685 - Aaron1011:install-llvm-tools, r=Mark-Simulacrum

Install llvm tools to sysroot when assembling local toolchain

Some projects (e.g. the `bootimage` crate) may require the
user to install the `llvm-tools-preview` rustup component.
However, this cannot be easily done with a locally built toolchain.

To allow a local toolchain to be used a drop-in replacement for
a normal rustup toolchain in more cases, this PR copies the built
LLVM tools to the sysoot. From the perspective a tool looking
at the sysroot, this is equivalent to installing `llvm-tools-preview`.

2 years agoRollup merge of #91634 - terrarier2111:fix-recover-from-variant-ice, r=nagisa
Matthias Krüger [Thu, 9 Dec 2021 04:08:33 +0000 (05:08 +0100)]
Rollup merge of #91634 - terrarier2111:fix-recover-from-variant-ice, r=nagisa

Do not attempt to suggest help for overly malformed struct/function call

This fixes: https://github.com/rust-lang/rust/issues/91461

2 years agoRollup merge of #91042 - Kobzol:vec-extend-cleanup, r=nagisa
Matthias Krüger [Thu, 9 Dec 2021 04:08:33 +0000 (05:08 +0100)]
Rollup merge of #91042 - Kobzol:vec-extend-cleanup, r=nagisa

Use Vec extend instead of repeated pushes on several places

Inspired by https://github.com/rust-lang/rust/pull/90813, I tried to use a simple regex (`for .*in.*\{\n.*push\(.*\);\n\s+}`) to search for more places that would use `Vec::push` in a loop and replace them with `Vec::extend`.

These probably won't have as much perf. impact as the original PR (if any), but it would probably be better to do a perf run to see if there are not any regressions.

2 years agoRollup merge of #90796 - Amanieu:remove_reg_thumb, r=joshtriplett
Matthias Krüger [Thu, 9 Dec 2021 04:08:32 +0000 (05:08 +0100)]
Rollup merge of #90796 - Amanieu:remove_reg_thumb, r=joshtriplett

Remove the reg_thumb register class for asm! on ARM

Also restricts r8-r14 from being used on Thumb1 targets as per #90736.

cc ``@Lokathor``

r? ``@joshtriplett``

2 years agoRollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se
Matthias Krüger [Thu, 9 Dec 2021 04:08:31 +0000 (05:08 +0100)]
Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se

Update std::env::temp_dir to use GetTempPath2 on Windows when available.

As a security measure, Windows 11 introduces a new temporary directory API, GetTempPath2.
When the calling process is running as SYSTEM, a separate temporary directory
will be returned inaccessible to non-SYSTEM processes. For non-SYSTEM processes
the behavior will be the same as before.

This can help mitigate against attacks such as this one:
https://medium.com/csis-techblog/cve-2020-1088-yet-another-arbitrary-delete-eop-a00b97d8c3e2

Compatibility risk: Software which relies on temporary files to communicate between SYSTEM and non-SYSTEM
processes may be affected by this change. In many cases, such patterns may be vulnerable to the very
attacks the new API was introduced to harden against.
I'm unclear on the Rust project's tolerance for such change-of-behavior in the standard library. If anything,
this PR is meant to raise awareness of the issue and hopefully start the conversation.

How tested: Taking the example code from the documentation and running it through psexec (from SysInternals) on
Win10 and Win11.
On Win10:
C:\test>psexec -s C:\test\main.exe
<...>
Temporary directory: C:\WINDOWS\TEMP\

On Win11:
C:\test>psexec -s C:\test\main.exe
<...>
Temporary directory: C:\Windows\SystemTemp\

2 years agoRollup merge of #87599 - Smittyvb:concat_bytes, r=Mark-Simulacrum
Matthias Krüger [Thu, 9 Dec 2021 04:08:30 +0000 (05:08 +0100)]
Rollup merge of #87599 - Smittyvb:concat_bytes, r=Mark-Simulacrum

Implement concat_bytes!

This implements the unstable `concat_bytes!` macro, which has tracking issue #87555. It can be used like:
```rust
#![feature(concat_bytes)]

fn main() {
    assert_eq!(concat_bytes!(), &[]);
    assert_eq!(concat_bytes!(b'A', b"BC", [68, b'E', 70]), b"ABCDEF");
}
```
If strings or characters are used where byte strings or byte characters are required, it suggests adding a `b` prefix. If a number is used outside of an array it suggests arrayifying it. If a boolean is used it suggests replacing it with the numeric value of that number. Doubly nested arrays of bytes are disallowed.

2 years agoAuto merge of #91691 - matthiaskrgr:rollup-wfommdr, r=matthiaskrgr
bors [Thu, 9 Dec 2021 04:04:01 +0000 (04:04 +0000)]
Auto merge of #91691 - matthiaskrgr:rollup-wfommdr, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #91042 (Use Vec extend instead of repeated pushes on several places)
 - #91476 (Improve 'cannot contain emoji' error.)
 - #91568 (Pretty print break and continue without redundant space)
 - #91645 (Implement `core::future::join!`)
 - #91666 (update Miri)

Failed merges:

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

2 years agoRollup merge of #91666 - RalfJung:miri, r=RalfJung
Matthias Krüger [Thu, 9 Dec 2021 04:02:23 +0000 (05:02 +0100)]
Rollup merge of #91666 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/91649
r? `@ghost`

2 years agoRollup merge of #91645 - ibraheemdev:future-join, r=joshtriplett
Matthias Krüger [Thu, 9 Dec 2021 04:02:22 +0000 (05:02 +0100)]
Rollup merge of #91645 - ibraheemdev:future-join, r=joshtriplett

Implement `core::future::join!`

`join!` polls multiple futures concurrently and returns their outputs.

```rust
async fn run() {
    let (a, b) = join!(async { 0 }, async { 1 });
}
```

cc `@rust-lang/wg-async-foundations`

2 years agoRollup merge of #91568 - dtolnay:breakspace, r=nagisa
Matthias Krüger [Thu, 9 Dec 2021 04:02:21 +0000 (05:02 +0100)]
Rollup merge of #91568 - dtolnay:breakspace, r=nagisa

Pretty print break and continue without redundant space

**Repro:**

```rust
macro_rules! m {
    ($e:expr) => { stringify!($e) };
}
fn main() {
    println!("{:?}", m!(loop { break; }));
    println!("{:?}", m!(loop { break 'a; }));
    println!("{:?}", m!(loop { break false; }));
}
```

**Before:**

- `"loop { break ; }"`
- `"loop { break 'a ; }"`
- `"loop { break false ; }"`

**After:**

- `"loop { break; }"`
- `"loop { break 'a; }"`
- `"loop { break false; }"`

<br>

Notice that `return` and `yield` already follow the same approach as this PR of printing the space *before* each additional piece following the keyword, rather than *after* each thing.

https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_ast_pretty/src/pprust/state.rs#L2148-L2154

https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_ast_pretty/src/pprust/state.rs#L2221-L2228

2 years agoRollup merge of #91476 - m-ou-se:ferris-identifier, r=estebank
Matthias Krüger [Thu, 9 Dec 2021 04:02:20 +0000 (05:02 +0100)]
Rollup merge of #91476 - m-ou-se:ferris-identifier, r=estebank

Improve 'cannot contain emoji' error.

Before:

```
error: identifiers cannot contain emoji: `🦀`
 --> src/main.rs:2:9
  |
2 |     let 🦀 = 1;
  |         ^^
```

After:
```
error: Ferris cannot be used as an identifier
 --> src/main.rs:2:9
  |
2 |     let 🦀 = 1;
  |         ^^ help: try using their name instead: `ferris`
```

r? `@estebank`

2 years agoRollup merge of #91042 - Kobzol:vec-extend-cleanup, r=nagisa
Matthias Krüger [Thu, 9 Dec 2021 04:02:19 +0000 (05:02 +0100)]
Rollup merge of #91042 - Kobzol:vec-extend-cleanup, r=nagisa

Use Vec extend instead of repeated pushes on several places

Inspired by https://github.com/rust-lang/rust/pull/90813, I tried to use a simple regex (`for .*in.*\{\n.*push\(.*\);\n\s+}`) to search for more places that would use `Vec::push` in a loop and replace them with `Vec::extend`.

These probably won't have as much perf. impact as the original PR (if any), but it would probably be better to do a perf run to see if there are not any regressions.

2 years agoAuto merge of #91677 - matthiaskrgr:rollup-yiczced, r=matthiaskrgr
bors [Thu, 9 Dec 2021 00:55:49 +0000 (00:55 +0000)]
Auto merge of #91677 - matthiaskrgr:rollup-yiczced, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #91245 (suggest casting between i/u32 and char)
 - #91337 (Add a suggestion if `macro_rules` is misspelled)
 - #91534 (Make rustdoc headings black, and markdown blue)
 - #91637 (Add test for packed drops in generators)
 - #91667 (Fix indent of itemTypes in search.js)

Failed merges:

 - #91568 (Pretty print break and continue without redundant space)

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

2 years agoInstall llvm tools to sysroot when assembling local toolchain
Aaron Hill [Thu, 9 Dec 2021 00:35:53 +0000 (18:35 -0600)]
Install llvm tools to sysroot when assembling local toolchain

Some projects (e.g. the `bootimage` crate) may require the
user to install the `llvm-tools-preview` rustup component.
However, this cannot be easily done with a locally built toolchain.

To allow a local toolchain to be used a drop-in replacement for
a normal rustup toolchain in more cases, this PR copies the built
LLVM tools to the sysoot. From the perspective a tool looking
at the sysroot, this is equivalent to installing `llvm-tools-preview`.

2 years agoUse `*mut [T]` instead of `[MaybeUninit<T>]`
The 8472 [Wed, 8 Dec 2021 23:20:13 +0000 (00:20 +0100)]
Use `*mut [T]` instead of `[MaybeUninit<T>]`

2 years agoPretty print break and continue without redundant space
David Tolnay [Sun, 5 Dec 2021 20:35:09 +0000 (12:35 -0800)]
Pretty print break and continue without redundant space

2 years agotrim down expansion of `core::future::join`
Ibraheem Ahmed [Wed, 8 Dec 2021 22:08:23 +0000 (17:08 -0500)]
trim down expansion of `core::future::join`

2 years agoRollup merge of #91667 - GuillaumeGomez:fix-index-itemtypes, r=notriddle
Matthias Krüger [Wed, 8 Dec 2021 22:18:07 +0000 (23:18 +0100)]
Rollup merge of #91667 - GuillaumeGomez:fix-index-itemtypes, r=notriddle

Fix indent of itemTypes in search.js

It has been bugging me for quite some time now. Finally took the time to clean it up a bit.

r? ```@notriddle```

2 years agoRollup merge of #91637 - tmiasko:generator-packed-drop, r=ecstatic-morse
Matthias Krüger [Wed, 8 Dec 2021 22:18:06 +0000 (23:18 +0100)]
Rollup merge of #91637 - tmiasko:generator-packed-drop, r=ecstatic-morse

Add test for packed drops in generators

r? ```@ecstatic-morse```

2 years agoRollup merge of #91534 - jsha:heading-color, r=GuillaumeGomez
Matthias Krüger [Wed, 8 Dec 2021 22:18:05 +0000 (23:18 +0100)]
Rollup merge of #91534 - jsha:heading-color, r=GuillaumeGomez

Make rustdoc headings black, and markdown blue

Demo:

https://rustdoc.crud.net/jsha/heading-color/std/string/index.html#structs
https://rustdoc.crud.net/jsha/heading-color/std/string/struct.String.html#examples

Fixes #91304

r? ```@camelid``` /cc ```@GuillaumeGomez```

(Note: we may want to make rustdoc headings and markdown headings the same color -- #90245 -- but we would want to do that intentionally; this is fixing up a change that did so accidentally)

2 years agoRollup merge of #91337 - FabianWolff:issue-91227-misspelled-macro, r=nagisa
Matthias Krüger [Wed, 8 Dec 2021 22:18:04 +0000 (23:18 +0100)]
Rollup merge of #91337 - FabianWolff:issue-91227-misspelled-macro, r=nagisa

Add a suggestion if `macro_rules` is misspelled

Fixes #91227.

2 years agoRollup merge of #91245 - cameron1024:suggest-i32-u32-char-cast, r=nagisa
Matthias Krüger [Wed, 8 Dec 2021 22:18:03 +0000 (23:18 +0100)]
Rollup merge of #91245 - cameron1024:suggest-i32-u32-char-cast, r=nagisa

suggest casting between i/u32 and char

As discussed in https://github.com/rust-lang/rust/issues/91063 , this adds a suggestion for converting between i32/u32 <-> char with `as`, and a short explanation for why this is safe

2 years agoUse Vec extend instead of repeated pushes in several places
Jakub Beránek [Wed, 8 Dec 2021 21:56:26 +0000 (22:56 +0100)]
Use Vec extend instead of repeated pushes in several places

2 years agoremove implicit .await from `core::future::join`
Ibraheem Ahmed [Wed, 8 Dec 2021 21:44:48 +0000 (16:44 -0500)]
remove implicit .await from `core::future::join`

2 years agoDo not attempt to suggest help for overly malformed struct/function call
threadexception [Tue, 7 Dec 2021 15:44:51 +0000 (16:44 +0100)]
Do not attempt to suggest help for overly malformed struct/function call

2 years agoAuto merge of #91665 - matthiaskrgr:rollup-o3wnkam, r=matthiaskrgr
bors [Wed, 8 Dec 2021 18:45:03 +0000 (18:45 +0000)]
Auto merge of #91665 - matthiaskrgr:rollup-o3wnkam, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90709 (Only shown relevant type params in E0283 label)
 - #91551 (Allow for failure of subst_normalize_erasing_regions in const_eval)
 - #91570 (Evaluate inline const pat early and report error if too generic)
 - #91571 (Remove unneeded access to pretty printer's `s` field in favor of deref)
 - #91610 (Link to rustdoc_json_types docs instead of rustdoc-json RFC)
 - #91619 (Update cargo)
 - #91630 (Add missing whitespace before disabled HTML attribute)

Failed merges:

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

2 years agoFix indent of itemTypes in search.js
Guillaume Gomez [Wed, 8 Dec 2021 16:31:56 +0000 (17:31 +0100)]
Fix indent of itemTypes in search.js

2 years agoupdate Miri
Ralf Jung [Wed, 8 Dec 2021 15:53:12 +0000 (10:53 -0500)]
update Miri

2 years agoRollup merge of #91630 - GuillaumeGomez:missing-whitespace, r=notriddle
Matthias Krüger [Wed, 8 Dec 2021 15:08:12 +0000 (16:08 +0100)]
Rollup merge of #91630 - GuillaumeGomez:missing-whitespace, r=notriddle

Add missing whitespace before disabled HTML attribute

On the [w3c HTML checker](https://validator.w3.org/nu/#textarea), with the current generated HTML we get:

![Screenshot from 2021-12-07 15-10-38](https://user-images.githubusercontent.com/3050060/145044653-b38fb679-da76-4890-853f-b696d8fdc06e.png)

The problem was that we were telling tera to remove too many whitespace.

r? ````@notriddle````

2 years agoRollup merge of #91619 - ehuss:update-cargo, r=ehuss
Matthias Krüger [Wed, 8 Dec 2021 15:08:11 +0000 (16:08 +0100)]
Rollup merge of #91619 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in 294967c53f0c70d598fc54ca189313c86c576ea7..40dc281755137ee804bc9b3b08e782773b726e44
2021-11-29 19:04:22 +0000 to 2021-12-06 21:54:44 +0000
- Unify the description of quiet flag (rust-lang/cargo#10168)
- Stabilize future-incompat-report (rust-lang/cargo#10165)
- Support abbreviating `--release` as `-r` (rust-lang/cargo#10133)
- doc: nudge towards simple version requirements (rust-lang/cargo#10158)
- Upgrade clap to 2.34.0 (rust-lang/cargo#10164)
- Treat EOPNOTSUPP the same as ENOTSUP when ignoring failed flock calls. (rust-lang/cargo#10157)
- Add note about RUSTFLAGS removal from build scripts. (rust-lang/cargo#10141)
- Make clippy happy (rust-lang/cargo#10139)

2 years agoRollup merge of #91610 - aDotInTheVoid:patch-2, r=GuillaumeGomez
Matthias Krüger [Wed, 8 Dec 2021 15:08:10 +0000 (16:08 +0100)]
Rollup merge of #91610 - aDotInTheVoid:patch-2, r=GuillaumeGomez

Link to rustdoc_json_types docs instead of rustdoc-json RFC

The JSON format has had [many changes](https://github.com/rust-lang/rust/commits/master/src/rustdoc-json-types) since the RFC, so the rustdoc output is the only up to date reference

```@rustdoc``` modify labels: +A-rustdoc-json +A-docs

2 years agoRollup merge of #91571 - dtolnay:printerderef, r=Mark-Simulacrum
Matthias Krüger [Wed, 8 Dec 2021 15:08:09 +0000 (16:08 +0100)]
Rollup merge of #91571 - dtolnay:printerderef, r=Mark-Simulacrum

Remove unneeded access to pretty printer's `s` field in favor of deref

I found it taxing in some of my recent PRs touching the pretty printer to maintain consistency with the surrounding code, since the current code is all over the place about whether it uses `self.s.…()` or `self.…()` for invoking methods of `rustc_ast_pretty::pp::Printer`.

This PR standardizes on `self.…()` &mdash; relying on the `Deref` and `DerefMut` impls introduced by [#62532](https://github.com/rust-lang/rust/pull/62532/commits/cab453250a3ceae5cf0cf7eac836c03b37e4ca8e).

2 years agoRollup merge of #91570 - nbdd0121:const_typeck, r=oli-obk
Matthias Krüger [Wed, 8 Dec 2021 15:08:08 +0000 (16:08 +0100)]
Rollup merge of #91570 - nbdd0121:const_typeck, r=oli-obk

Evaluate inline const pat early and report error if too generic

Fix #90150

````@rustbot```` label: T-compiler F-inline_const

2 years agoRollup merge of #91551 - b-naber:const-eval-normalization-ice, r=oli-obk
Matthias Krüger [Wed, 8 Dec 2021 15:08:07 +0000 (16:08 +0100)]
Rollup merge of #91551 - b-naber:const-eval-normalization-ice, r=oli-obk

Allow for failure of subst_normalize_erasing_regions in const_eval

Fixes https://github.com/rust-lang/rust/issues/72845

Using associated types that cannot be normalized previously resulted in an ICE. We now allow for normalization failure and return a "TooGeneric" error in that case.

r? ```@RalfJung``` maybe?

2 years agoRollup merge of #90709 - estebank:erase-known-type-params, r=nagisa
Matthias Krüger [Wed, 8 Dec 2021 15:08:06 +0000 (16:08 +0100)]
Rollup merge of #90709 - estebank:erase-known-type-params, r=nagisa

Only shown relevant type params in E0283 label

When we point at a binding to suggest giving it a type, erase all the
type for ADTs that have been resolved, leaving only the ones that could
not be inferred. For small shallow types this is not a problem, but for
big nested types with lots of params, this can otherwise cause a lot of
unnecessary visual output.

2 years agoAuto merge of #91604 - nikic:section-flags, r=nagisa
bors [Wed, 8 Dec 2021 14:58:48 +0000 (14:58 +0000)]
Auto merge of #91604 - nikic:section-flags, r=nagisa

Use object crate for .rustc metadata generation

We already use the object crate for generating uncompressed .rmeta
metadata object files. This switches the generation of compressed
.rustc object files to use the object crate as well. These have
slightly different requirements in that .rmeta should be completely
excluded from any final compilation artifacts, while .rustc should
be part of shared objects, but not loaded into memory.

The primary motivation for this change is #90326: In LLVM 14, the
current way of setting section flags (and in particular, preventing
the setting of SHF_ALLOC) will no longer work. There are other ways
we could work around this, but switching to the object crate seems
like the most elegant, as we already use it for .rmeta, and as it
makes this independent of the codegen backend. In particular, we
don't need separate handling in codegen_llvm and codegen_gcc.
codegen_cranelift should be able to reuse the implementation as
well, though I have omitted that here, as it is not based on
codegen_ssa.

This change mostly extracts the existing code for .rmeta handling
to allow using it for .rustc as well, and adjusts the codegen
infrastructure to handle the metadata object file separately: We
no longer create a backend-specific module for it, and directly
produce the compiled module instead.

This does not `fix` #90326 by itself yet, as .llvmbc will need to be
handled separately.

r? `@nagisa`

2 years agoAuto merge of #91656 - matthiaskrgr:rollup-lk96y6d, r=matthiaskrgr
bors [Wed, 8 Dec 2021 11:22:02 +0000 (11:22 +0000)]
Auto merge of #91656 - matthiaskrgr:rollup-lk96y6d, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #83744 (Deprecate crate_type and crate_name nested inside #![cfg_attr])
 - #90550 (Update certificates in some Ubuntu 16 images.)
 - #91272 (Print a suggestion when comparing references to primitive types in `const fn`)
 - #91467 (Emphasise that an OsStr[ing] is not necessarily a platform string)
 - #91531 (Do not add `;` to expected tokens list when it's wrong)
 - #91577 (Address some FIXMEs left over from #91475)
 - #91638 (Remove `in_band_lifetimes` from `rustc_mir_transform`)

Failed merges:

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

2 years agoRollup merge of #91638 - scottmcm:less-inband-2-of-28, r=petrochenkov
Matthias Krüger [Wed, 8 Dec 2021 10:09:01 +0000 (11:09 +0100)]
Rollup merge of #91638 - scottmcm:less-inband-2-of-28, r=petrochenkov

Remove `in_band_lifetimes` from `rustc_mir_transform`

Like #91580, this was inspired by the conversation in #44524 about possibly removing the feature from the compiler.  This crate is a heavy `'tcx` user, so is a nice case study.

r? ``@petrochenkov``

Three interesting ones:

This one had the `'tcx` declared on the function, despite the trait taking a `'tcx`:
```diff
-impl Visitor<'_> for UsedLocals {
+impl<'tcx> Visitor<'tcx> for UsedLocals {
     fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
```

This one use in-band for one, and underscore for the other:
```diff
-pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
+pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
```

A spurious name, since there's no single-use-lifetime warning:
```diff
-pub fn run_passes(tcx: TyCtxt<'tcx>, body: &'mir mut Body<'tcx>, passes: &[&dyn MirPass<'tcx>]) {
+pub fn run_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, passes: &[&dyn MirPass<'tcx>]) {
```

2 years agoRollup merge of #91577 - ecstatic-morse:mir-pass-manager-cleanup, r=oli-obk
Matthias Krüger [Wed, 8 Dec 2021 10:09:00 +0000 (11:09 +0100)]
Rollup merge of #91577 - ecstatic-morse:mir-pass-manager-cleanup, r=oli-obk

Address some FIXMEs left over from #91475

This shouldn't change behavior, only clarify what we're currently doing. I filed #91576 to see if the treatment of generator drop shims is intentional.

cc #91475

2 years agoRollup merge of #91531 - notriddle:notriddle/issue-87647-expected-semicolon, r=estebank
Matthias Krüger [Wed, 8 Dec 2021 10:08:59 +0000 (11:08 +0100)]
Rollup merge of #91531 - notriddle:notriddle/issue-87647-expected-semicolon, r=estebank

Do not add `;` to expected tokens list when it's wrong

There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff).

Fixes #87647

2 years agoRollup merge of #91467 - ChrisDenton:confusing-os-string, r=Mark-Simulacrum
Matthias Krüger [Wed, 8 Dec 2021 10:08:58 +0000 (11:08 +0100)]
Rollup merge of #91467 - ChrisDenton:confusing-os-string, r=Mark-Simulacrum

Emphasise that an OsStr[ing] is not necessarily a platform string

Fixes #53261

Since that issue was filed, #56141 added a further clarification to the `OsString` docs. However the ffi docs may still leave the impression that an `OsStr` is in the platform native form. This PR aims to further emphasise that an `OsStr` is not necessarily a platform string.

2 years agoRollup merge of #91272 - FabianWolff:issue-90870-const-fn-eq, r=wesleywiser
Matthias Krüger [Wed, 8 Dec 2021 10:08:57 +0000 (11:08 +0100)]
Rollup merge of #91272 - FabianWolff:issue-90870-const-fn-eq, r=wesleywiser

Print a suggestion when comparing references to primitive types in `const fn`

Fixes #90870.

2 years agoRollup merge of #90550 - ehuss:update-ca, r=Mark-Simulacrum
Matthias Krüger [Wed, 8 Dec 2021 10:08:56 +0000 (11:08 +0100)]
Rollup merge of #90550 - ehuss:update-ca, r=Mark-Simulacrum

Update certificates in some Ubuntu 16 images.

These images use crosstool-ng, which needs to download various things off the internet. The certificate for `www.kernel.org` no longer works with the ca-certificates in Ubuntu 16. This resolves the issue by grabbing from a newer image a certificate bundle from https://curl.se/ca/cacert.pem, which is usually somewhat up to date.

2 years agoRollup merge of #83744 - bjorn3:deprecate_cfg_attr_crate_type_name, r=Mark-Simulacrum
Matthias Krüger [Wed, 8 Dec 2021 10:08:55 +0000 (11:08 +0100)]
Rollup merge of #83744 - bjorn3:deprecate_cfg_attr_crate_type_name, r=Mark-Simulacrum

Deprecate crate_type and crate_name nested inside #![cfg_attr]

This implements the proposal in https://github.com/rust-lang/rust/pull/83676#issuecomment-811213956, with a future compatibility lint imposed on usage of crate_type/crate_name inside cfg's.

This is a compromise between removing `#![crate_type]` and `#![crate_name]` completely and keeping them as a whole, which requires somewhat of a hack in rustc and is impossible to support by gcc-rust. By only removing `#![crate_type]` and `#![crate_name]` nested inside `#![cfg_attr]` it becomes possible to parse them before a big chunk of the compiler has started.

Replaces https://github.com/rust-lang/rust/pull/83676

```rust
#![crate_type = "lib"] // remains working
#![cfg_attr(foo, crate_type = "bin")] // will stop working
```

# Rationale

As it currently is it is possible to try to access the stable crate id before it is actually set, which will panic. The fact that the Session contains mutable state beyond debugging things also doesn't completely sit well with me. Especially once parallel rustc becomes the default.

I think there is currently also a cyclic dependency where you need to set the stable crate id to be able to load crates, but you need to load crates to expand proc macro attributes that may define #![crate_name] or #![crate_type]. Currently crate level proc macro attributes are unstable or completely unsupported (can't remember which), so this is not a problem, but it may become an issue in the future.

Finally if we want to add incremental compilation to macro expansion or even parsing, we need the StableCrateId to be created together with the Session or even earlier as incremental compilation determines the incremental compilation session dir based on the StableCrateId.

2 years agoAuto merge of #91512 - scottmcm:array-intoiter-advance, r=Mark-Simulacrum
bors [Wed, 8 Dec 2021 07:54:30 +0000 (07:54 +0000)]
Auto merge of #91512 - scottmcm:array-intoiter-advance, r=Mark-Simulacrum

Override `Iterator::advance(_back)_by` for `array::IntoIter`

Because I happened to notice that `nth` is currently getting codegen'd as a loop even for `Copy` types: <https://rust.godbolt.org/z/fPqv7Gvs7>

<details>
<summary>LLVM before and after</summary>

Rust:

```rust
#[no_mangle]
pub fn array_intoiter_nth(it: &mut std::array::IntoIter<i32, 100>, n: usize) -> Option<i32> {
    it.nth(n)
}
```

Current nightly:
```llvmir
define { i32, i32 } `@array_intoiter_nth(%"core::array::iter::IntoIter<i32,` 100_usize>"* noalias nocapture align 8 dereferenceable(416) %it, i64 %n) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* `@rust_eh_personality` !dbg !6 {
start:
  %_3.i.i.i4.i.i = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 0, i32 0
  %_4.i.i.i5.i.i = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 0, i32 1
  %_4.i.i.i.i.i.i = load i64, i64* %_4.i.i.i5.i.i, align 8, !alias.scope !10
  %.not.i.i = icmp eq i64 %n, 0, !dbg !15
  %_3.i.i.i.i.pre.i = load i64, i64* %_3.i.i.i4.i.i, align 8, !dbg !40, !alias.scope !41
  br i1 %.not.i.i, label %bb4.i, label %bb4.preheader.i.i, !dbg !42

bb4.preheader.i.i:                                ; preds = %start
  %umax.i = tail call i64 `@llvm.umax.i64(i64` %_3.i.i.i.i.pre.i, i64 %_4.i.i.i.i.i.i) #3, !dbg !43
  %0 = sub i64 %umax.i, %_3.i.i.i.i.pre.i, !dbg !43
  br label %bb4.i.i, !dbg !43

bb4.i.i:                                          ; preds = %bb3.i.i.i.i, %bb4.preheader.i.i
  %_3.i.i.i.i.i.i = phi i64 [ %2, %bb3.i.i.i.i ], [ %_3.i.i.i.i.pre.i, %bb4.preheader.i.i ], !dbg !52
  %iter.sroa.0.016.i.i = phi i64 [ %1, %bb3.i.i.i.i ], [ 0, %bb4.preheader.i.i ]
  %1 = add nuw i64 %iter.sroa.0.016.i.i, 1, !dbg !54
  %exitcond.not.i = icmp eq i64 %iter.sroa.0.016.i.i, %0, !dbg !52
  br i1 %exitcond.not.i, label %core::iter::traits::iterator::Iterator::nth.exit, label %bb3.i.i.i.i, !dbg !43

bb3.i.i.i.i:                                      ; preds = %bb4.i.i
  %2 = add nuw i64 %_3.i.i.i.i.i.i, 1, !dbg !63
  store i64 %2, i64* %_3.i.i.i4.i.i, align 8, !dbg !66, !alias.scope !75
  %exitcond.not.i.i = icmp eq i64 %1, %n, !dbg !15
  br i1 %exitcond.not.i.i, label %bb4.i, label %bb4.i.i, !dbg !42

bb4.i:                                            ; preds = %bb3.i.i.i.i, %start
  %_3.i.i.i.i.i = phi i64 [ %_3.i.i.i.i.pre.i, %start ], [ %2, %bb3.i.i.i.i ], !dbg !84
  %3 = icmp ult i64 %_3.i.i.i.i.i, %_4.i.i.i.i.i.i, !dbg !84
  br i1 %3, label %bb3.i.i.i, label %core::iter::traits::iterator::Iterator::nth.exit, !dbg !89

bb3.i.i.i:                                        ; preds = %bb4.i
  %4 = add nuw i64 %_3.i.i.i.i.i, 1, !dbg !90
  store i64 %4, i64* %_3.i.i.i4.i.i, align 8, !dbg !93, !alias.scope !96
  %5 = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 1, i64 %_3.i.i.i.i.i, !dbg !105
  %6 = load i32, i32* %5, align 4, !dbg !131, !alias.scope !141, !noalias !144
  br label %core::iter::traits::iterator::Iterator::nth.exit, !dbg !149

core::iter::traits::iterator::Iterator::nth.exit: ; preds = %bb4.i.i, %bb4.i, %bb3.i.i.i
  %.sroa.3.0.i = phi i32 [ %6, %bb3.i.i.i ], [ undef, %bb4.i ], [ undef, %bb4.i.i ], !dbg !40
  %.sroa.0.0.i = phi i32 [ 1, %bb3.i.i.i ], [ 0, %bb4.i ], [ 0, %bb4.i.i ], !dbg !40
  %7 = insertvalue { i32, i32 } undef, i32 %.sroa.0.0.i, 0, !dbg !150
  %8 = insertvalue { i32, i32 } %7, i32 %.sroa.3.0.i, 1, !dbg !150
  ret { i32, i32 } %8, !dbg !151
}
```

With this PR:
```llvmir
define { i32, i32 } `@array_intoiter_nth(%"core::array::iter::IntoIter<i32,` 100_usize>"* noalias nocapture align 8 dereferenceable(416) %it, i64 %n) unnamed_addr #0 personality i32 (...)* `@__CxxFrameHandler3` {
start:
  %0 = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 0, i32 1
  %_2.i.i.i.i = load i64, i64* %0, align 8, !alias.scope !6, !noalias !13
  %1 = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 0, i32 0
  %_3.i.i.i.i = load i64, i64* %1, align 8, !alias.scope !16
  %2 = sub i64 %_2.i.i.i.i, %_3.i.i.i.i
  %3 = icmp ult i64 %2, %n
  %.0.sroa.speculated.i.i.i.i.i = select i1 %3, i64 %2, i64 %n
  %_10.i.i = add i64 %.0.sroa.speculated.i.i.i.i.i, %_3.i.i.i.i
  store i64 %_10.i.i, i64* %1, align 8, !alias.scope !16
  %.not.i = xor i1 %3, true
  %4 = icmp ult i64 %_10.i.i, %_2.i.i.i.i
  %or.cond.i = select i1 %.not.i, i1 %4, i1 false
  br i1 %or.cond.i, label %bb3.i.i.i, label %_ZN4core4iter6traits8iterator8Iterator3nth17hcbc727011e9e2a3bE.exit

bb3.i.i.i:                                        ; preds = %start
  %5 = add nuw i64 %_10.i.i, 1
  store i64 %5, i64* %1, align 8, !alias.scope !17
  %6 = getelementptr inbounds %"core::array::iter::IntoIter<i32, 100_usize>", %"core::array::iter::IntoIter<i32, 100_usize>"* %it, i64 0, i32 1, i64 %_10.i.i
  %7 = load i32, i32* %6, align 4, !alias.scope !26, !noalias !29
  br label %_ZN4core4iter6traits8iterator8Iterator3nth17hcbc727011e9e2a3bE.exit

_ZN4core4iter6traits8iterator8Iterator3nth17hcbc727011e9e2a3bE.exit: ; preds = %start, %bb3.i.i.i
  %.sroa.3.0.i = phi i32 [ undef, %start ], [ %7, %bb3.i.i.i ]
  %.sroa.0.0.i = phi i32 [ 0, %start ], [ 1, %bb3.i.i.i ]
  %8 = insertvalue { i32, i32 } undef, i32 %.sroa.0.0.i, 0
  %9 = insertvalue { i32, i32 } %8, i32 %.sroa.3.0.i, 1
  ret { i32, i32 } %9
}
```
</details>

2 years agocorrect typo
DrMeepster [Wed, 8 Dec 2021 06:09:14 +0000 (22:09 -0800)]
correct typo

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoRemove `in_band_lifetimes` from `rustc_mir_transform`
Scott McMurray [Mon, 6 Dec 2021 08:48:37 +0000 (00:48 -0800)]
Remove `in_band_lifetimes` from `rustc_mir_transform`

This one is a heavy `'tcx` user.

Two interesting ones:

This one had the `'tcx` declared on the function, despite the trait taking a `'tcx`:
```diff
-impl Visitor<'_> for UsedLocals {
+impl<'tcx> Visitor<'tcx> for UsedLocals {
     fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
```

This one use in-band for one, and underscore for the other:
```diff
-pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
+pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
```

2 years agoAuto merge of #91500 - ehuss:update-mdbook, r=Mark-Simulacrum
bors [Wed, 8 Dec 2021 04:46:39 +0000 (04:46 +0000)]
Auto merge of #91500 - ehuss:update-mdbook, r=Mark-Simulacrum

Update mdbook

This just includes a few minor fixes:
* https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0413
* https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0414

2 years agoadd tests for `core::future::join`
Ibraheem Ahmed [Wed, 8 Dec 2021 02:10:39 +0000 (21:10 -0500)]
add tests for `core::future::join`

2 years agogenerate `MaybeDone` futures inline `join`
Ibraheem Ahmed [Wed, 8 Dec 2021 02:01:10 +0000 (21:01 -0500)]
generate `MaybeDone` futures inline `join`

2 years agoimplement `core::future::join`
Ibraheem Ahmed [Wed, 8 Dec 2021 01:59:16 +0000 (20:59 -0500)]
implement `core::future::join`

2 years agoAuto merge of #91484 - workingjubilee:simd-remove-autosplats, r=Mark-Simulacrum
bors [Wed, 8 Dec 2021 01:37:59 +0000 (01:37 +0000)]
Auto merge of #91484 - workingjubilee:simd-remove-autosplats, r=Mark-Simulacrum

Sync portable-simd to remove autosplats

This PR syncs portable-simd in up to https://github.com/rust-lang/portable-simd/commit/a8385522ade6f67853edac730b5bf164ddb298fd in order to address the type inference breakages documented on nightly in https://github.com/rust-lang/rust/issues/90904 by removing the vector + scalar binary operations (called "autosplats", "broadcasting", or "rank promotion", depending on who you ask) that allow `{scalar} + &'_ {scalar}` to fail in some cases, because it becomes possible the programmer may have meant `{scalar} + &'_ {vector}`.

A few quality-of-life improvements make their way in as well:
- Lane counts can now go to 64, as LLVM seems to have fixed their miscompilation for those.
- `{i,u}8x64` to `__m512i` is now available.
- a bunch of `#[must_use]` notes appear throughout the module.
- Some implementations, mostly instances of `impl core::ops::{Op}<Simd> for Simd` that aren't `{vector} + {vector}` (e.g. `{vector} + &'_ {vector}`), leverage some generics and `where` bounds now to make them easier to understand by reducing a dozen implementations into one (and make it possible for people to open the docs on less burly devices).
- And some internal-only improvements.

None of these changes should affect a beta backport, only actual users of `core::simd` (and most aren't even visible in the programmatic sense), though I can extract an even more minimal changeset for beta if necessary. It seemed simpler to just keep moving forward.

2 years agoRemove the reg_thumb register class for asm! on ARM
Amanieu d'Antras [Thu, 11 Nov 2021 12:42:38 +0000 (12:42 +0000)]
Remove the reg_thumb register class for asm! on ARM

Also restricts r8-r14 from being used on Thumb1 targets as per #90736.

2 years agoAuto merge of #91407 - the8472:deserialize-unchecked-utf8, r=michaelwoerister
bors [Tue, 7 Dec 2021 21:50:46 +0000 (21:50 +0000)]
Auto merge of #91407 - the8472:deserialize-unchecked-utf8, r=michaelwoerister

Avoid string validation in rustc_serialize, check a marker byte instead

Since the serialization format isn't self-describing we need a way to detect when encoder and decoder don't match up. But for strings it doesn't have to be utf8 validation, which currently does cost a few percent of performance.
Instead we can use a marker byte at the end to be reasonably sure that we're dealing with a string and it wasn't overwritten in some way.

2 years agoRemove unneeded access to pretty printer's `s` field in favor of deref
David Tolnay [Sun, 5 Dec 2021 21:33:39 +0000 (13:33 -0800)]
Remove unneeded access to pretty printer's `s` field in favor of deref

2 years agoFuture compatibility warning on cfg_attr on crate_type and crate_name
bjorn3 [Thu, 1 Apr 2021 09:34:39 +0000 (11:34 +0200)]
Future compatibility warning on cfg_attr on crate_type and crate_name

2 years agoAuto merge of #91224 - couchand:2021-11/avr-asm, r=Amanieu
bors [Tue, 7 Dec 2021 14:23:01 +0000 (14:23 +0000)]
Auto merge of #91224 - couchand:2021-11/avr-asm, r=Amanieu

Support AVR for inline asm!

A first pass at support for the AVR platform in inline `asm!`.  Passes the initial compiler tests, have not yet done more complete verification.

In particular, the register classes could use a lot more fleshing out, this draft PR so far only includes the most basic.

cc `@Amanieu` `@dylanmckay`

2 years agoAdd missing whitespace before disabled HTML attribute
Guillaume Gomez [Tue, 7 Dec 2021 14:11:00 +0000 (15:11 +0100)]
Add missing whitespace before disabled HTML attribute

2 years agoAuto merge of #91627 - matthiaskrgr:rollup-z3e2peg, r=matthiaskrgr
bors [Tue, 7 Dec 2021 11:18:26 +0000 (11:18 +0000)]
Auto merge of #91627 - matthiaskrgr:rollup-z3e2peg, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #87614 (Recommend fix `count()` -> `len()` on slices)
 - #91065 (Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE)
 - #91312 (Fix AnonConst ICE)
 - #91341 (Add `array::IntoIter::{empty, from_raw_parts}`)
 - #91493 (Remove a dead code path.)
 - #91503 (Tweak "call this function" suggestion to have smaller span)
 - #91547 (Suggest try_reserve in try_reserve_exact)
 - #91562 (Pretty print async block without redundant space)
 - #91620 (Update books)
 - #91622 (:arrow_up: rust-analyzer)

Failed merges:

 - #91571 (Remove unneeded access to pretty printer's `s` field in favor of deref)

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

2 years agoRollup merge of #91622 - lnicola:rust-analyzer-2021-12-07, r=lnicola
Matthias Krüger [Tue, 7 Dec 2021 10:05:08 +0000 (11:05 +0100)]
Rollup merge of #91622 - lnicola:rust-analyzer-2021-12-07, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoRollup merge of #91620 - ehuss:update-books, r=ehuss
Matthias Krüger [Tue, 7 Dec 2021 10:05:07 +0000 (11:05 +0100)]
Rollup merge of #91620 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in c6b4bf831e9a40aec34f53067d20634839a6778b..49681ea4a9fa81173dbe9ffed74b4d4a35eae9e3
2021-11-09 02:30:56 +0900 to 2021-11-24 16:27:28 +0900
- Clarify that drop flag fields only apply to older Rust versions (rust-lang/nomicon#324)

## reference

2 commits in c0f222da23568477155991d391c9ce918e381351..954f3d441ad880737a13e241108f791a4d2a38cd
2021-11-22 10:30:57 -0800 to 2021-11-29 11:11:30 -0800
- Say that bare trait objects are rejected in the 2021 edition (rust-lang/reference#1111)
- Update 'Subtyping and Variance' example to use `dyn Trait` syntax (rust-lang/reference#1110)

## book

5 commits in a5e0c5b2c5f9054be3b961aea2c7edfeea591de8..5f9358faeb1f46e19b8a23a21e79fd7fe150491e
2021-11-19 17:06:19 -0500 to 2021-12-05 21:33:16 -0500
- 1.57
- Update to 1.56
- Snapshot of ch 11 for nostarch
- Clarify how to check for an error in tests returning Result
- Update book repo links for default branch rename

## rust-by-example

1 commits in 43f82530210b83cf888282b207ed13d5893da9b2..1ca6a7bd1d73edc4a3e6c7d6a40f5d4b66c1e517
2021-11-21 22:31:50 -0300 to 2021-11-23 17:48:53 -0300
- Removed `u32` at the end of ints (rust-lang/rust-by-example#1477)

## rustc-dev-guide

10 commits in a2fc9635029c04e692474965a6606f8e286d539a..a374e7d8bb6b79de45b92295d06b4ac0ef35bc09
2021-11-18 13:31:13 -0500 to 2021-12-03 09:26:47 -0800
- Update LLVM coverage mapping format version supported by rustc (rust-lang/rustc-dev-guide#1267)
- Improve 'Running tests manually' section
- Fix some links
- Update for review comments.
- Document rustfix-only-machine-applicable
- Apply suggestions from pierwill
- Document more compiletest headers.
- make it compile with 1.56.0 no warning
- make it compile with 1.56.0
- make it compile with 1.56.0

## edition-guide

1 commits in 8e0ec8c77d8b28b86159fdee9d33a758225ecf9c..beea0a3cdc3885375342fd010f9ad658e6a5e09a
2021-11-12 06:30:23 -0800 to 2021-12-05 07:06:45 -0800
- Fix typo (neccesary -&gt; necessary) (rust-lang/edition-guide#274)

2 years agoRollup merge of #91562 - dtolnay:asyncspace, r=Mark-Simulacrum
Matthias Krüger [Tue, 7 Dec 2021 10:05:06 +0000 (11:05 +0100)]
Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-Simulacrum

Pretty print async block without redundant space

**Repro:**

```rust
macro_rules! m {
    ($e:expr) => { stringify!($e) };
}
fn main() {
    println!("{:?}", m!(async {}));
}
```

**Before:** <code>"async&nbsp;&nbsp;{}"</code>
**After:** `"async {}"`

<br>

In this function:

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2049-L2051

the `print_capture_clause` and `word_nbsp`/`word_space` calls already put a space after the `async` and `move` keywords being printed. The extra `self.s.space()` call removed by this PR resulted in the redundant double space.

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2640-L2645

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L34-L37

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L5-L8

2 years agoRollup merge of #91547 - TennyZhuang:suggest_try_reserve, r=scottmcm
Matthias Krüger [Tue, 7 Dec 2021 10:05:04 +0000 (11:05 +0100)]
Rollup merge of #91547 - TennyZhuang:suggest_try_reserve, r=scottmcm

Suggest try_reserve in try_reserve_exact

During developing #91529 , I found that `try_reserve_exact` suggests `reserve` for further insertions. I think it's a mistake by copy&paste, `try_reserve` is better here.

2 years agoRollup merge of #91503 - estebank:call-fn-span, r=michaelwoerister
Matthias Krüger [Tue, 7 Dec 2021 10:05:03 +0000 (11:05 +0100)]
Rollup merge of #91503 - estebank:call-fn-span, r=michaelwoerister

Tweak "call this function" suggestion to have smaller span

2 years agoRollup merge of #91493 - oli-obk:cleanup, r=michaelwoerister
Matthias Krüger [Tue, 7 Dec 2021 10:05:00 +0000 (11:05 +0100)]
Rollup merge of #91493 - oli-obk:cleanup, r=michaelwoerister

Remove a dead code path.

It is neither documented nor can I see any way it could ever be reached.

Also, no tests fail when turning that arm into an ICE

2 years agoRollup merge of #91341 - scottmcm:array-iter-frp, r=kennytm
Matthias Krüger [Tue, 7 Dec 2021 10:04:59 +0000 (11:04 +0100)]
Rollup merge of #91341 - scottmcm:array-iter-frp, r=kennytm

Add `array::IntoIter::{empty, from_raw_parts}`

`array::IntoIter` has a bunch of really handy logic for dealing with partial arrays, but it's currently hamstrung by only being creatable from a fully-initialized array.

This PR adds two new constructors:
- a safe & const `empty`, since `[].into_iter()` can only give `IntoIter<T, 0>`, not `IntoIter<T, N>`.
- an unsafe `from_raw_parts`, to allow experimentation with new uses.

(Slice & vec iterators don't need `from_raw_parts` because you `from_raw_parts` the slice or vec instead, but there's no useful way to made a `<[T; N]>::from_raw_parts`, so I think this is a reasonable place to have one.)

2 years agoRollup merge of #91312 - terrarier2111:anon-const-ice, r=jackh726
Matthias Krüger [Tue, 7 Dec 2021 10:04:58 +0000 (11:04 +0100)]
Rollup merge of #91312 - terrarier2111:anon-const-ice, r=jackh726

Fix AnonConst ICE

I am not sure if this is even the correct place to fix this issue, but i went down the path where the generic args came from and i wasn't able to find a clear cause for this down there. But if anybody has a suggestion what i should do, just tell me.
This fixes: https://github.com/rust-lang/rust/issues/91267

2 years agoRollup merge of #91065 - wesleywiser:add_incr_test, r=jackh726
Matthias Krüger [Tue, 7 Dec 2021 10:04:57 +0000 (11:04 +0100)]
Rollup merge of #91065 - wesleywiser:add_incr_test, r=jackh726

Add test for evaluate_obligation: Ok(EvaluatedToOkModuloRegions) ICE

Adds the minimial repro test case from #85360. The fix for #85360 was
supposed to be #85868 however the repro was resolved in the 2021-07-05
nightly while #85868 didn't land until 2021-09-03. The reason for that
is d34a3a401b4e44f289a4d5bf53da83367cbb6aa7 **also** resolves that
issue.

To test if #85868 actually fixes #85360, I reverted
d34a3a401b4e44f289a4d5bf53da83367cbb6aa7 and found that #85868 does
indeed resolve #85360.

With that question resolved, add a test case to our incremental test
suite for the original Ok(EvaluatedToOkModuloRegions) ICE.

Thanks to ````@lqd```` for helping track this down!

2 years agoRollup merge of #87614 - notriddle:notriddle-count2len, r=Mark-Simulacrum
Matthias Krüger [Tue, 7 Dec 2021 10:04:56 +0000 (11:04 +0100)]
Rollup merge of #87614 - notriddle:notriddle-count2len, r=Mark-Simulacrum

Recommend fix `count()` -> `len()` on slices

Fixes #87302

2 years agoUse object crate for .rustc metadata generation
Nikita Popov [Thu, 2 Dec 2021 11:24:25 +0000 (12:24 +0100)]
Use object crate for .rustc metadata generation

We already use the object crate for generating uncompressed .rmeta
metadata object files. This switches the generation of compressed
.rustc object files to use the object crate as well. These have
slightly different requirements in that .rmeta should be completely
excluded from any final compilation artifacts, while .rustc should
be part of shared objects, but not loaded into memory.

The primary motivation for this change is #90326: In LLVM 14, the
current way of setting section flags (and in particular, preventing
the setting of SHF_ALLOC) will no longer work. There are other ways
we could work around this, but switching to the object crate seems
like the most elegant, as we already use it for .rmeta, and as it
makes this independent of the codegen backend. In particular, we
don't need separate handling in codegen_llvm and codegen_gcc.
codegen_cranelift should be able to reuse the implementation as
well, though I have omitted that here, as it is not based on
codegen_ssa.

This change mostly extracts the existing code for .rmeta handling
to allow using it for .rustc as well, and adjust the codegen
infrastructure to handle the metadata object file separately: We
no longer create a backend-specific module for it, and directly
produce the compiled module instead.

This does not fix #90326 by itself yet, as .llvmbc will need to be
handled separately.

2 years agoAuto merge of #85013 - Mark-Simulacrum:dominators-bitset, r=pnkfelix
bors [Tue, 7 Dec 2021 08:12:47 +0000 (08:12 +0000)]
Auto merge of #85013 - Mark-Simulacrum:dominators-bitset, r=pnkfelix

Replace dominators algorithm with simple Lengauer-Tarjan

This PR replaces our dominators implementation with that of the simple Lengauer-Tarjan algorithm, which is (to my knowledge and research) the currently accepted 'best' algorithm. The more complex variant has higher constant time overheads, and Semi-NCA (which is arguably a variant of Lengauer-Tarjan too) is not the preferred variant by the first paper cited in the documentation comments: simple Lengauer-Tarjan "is less sensitive to pathological instances, we think it should be preferred where performance guarantees are important" - which they are for us.

This work originally arose from noting that the keccak benchmark spent a considerable portion of its time (both instructions and cycles) in the dominator computations, which sparked an interest in potentially optimizing that code. The current algorithm largely proves slow on long "parallel" chains where the nearest common ancestor lookup (i.e., the intersect function) does not quickly identify a root; it is also inherently a pointer-chasing algorithm so is relatively slow on modern CPUs due to needing to hit memory - though usually in cache - in a tight loop, which still costs several cycles.

This was replaced with a bitset-based algorithm, previously studied in literature but implemented directly from dataflow equations in our case, which proved to be a significant speed up on the keccak benchmark: 20% instruction count wins, as can be seen in [this performance report](https://perf.rust-lang.org/compare.html?start=377d1a984cd2a53327092b90aa1d8b7e22d1e347&end=542da47ff78aa462384062229dad0675792f2638). This algorithm is also relatively simple in comparison to other algorithms and is easy to understand. However, these performance results showed a regression on a number of other benchmarks, and I was unable to get the bitsets to perform well enough that those regressions could be fully mitigated. The implementation "attempt" is seen here in the first commit, and is intended to be kept primarily so that future optimizers do not repeat that path (or can easily refer to the attempt).

The final version of this PR chooses the simple Lengauer-Tarjan algorithm, and implements it along with a number of optimizations found in literature. The current implementation is a slight improvement for many benchmarks, with keccak still being an outlier at ~20%. The implementation in this PR first implements the most basic variant of the algorithm directly from the pseudocode on page 16, physical, or 28 in the PDF of the first paper ("Linear-Time Algorithms for Dominators and Related Problems"). This is then followed by a number of commits which update the implementation to apply various performance improvements, as suggested by the paper. Finally, the last commit annotates the implementation with a number of comments, mostly drawn from the paper, which intend to help readers understand what is going on - these are incomplete without the paper, but writing them certainly helped my understanding. They may be helpful if future optimization attempts are attempted, so I chose to add them in.

2 years agos/from_raw_parts/new_unchecked/
Scott McMurray [Tue, 7 Dec 2021 06:59:04 +0000 (22:59 -0800)]
s/from_raw_parts/new_unchecked/

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 7 Dec 2021 05:46:50 +0000 (07:46 +0200)]
:arrow_up: rust-analyzer

2 years agoUpdate books
Eric Huss [Tue, 7 Dec 2021 04:45:37 +0000 (20:45 -0800)]
Update books

2 years agoUpdate cargo
Eric Huss [Tue, 7 Dec 2021 04:33:00 +0000 (20:33 -0800)]
Update cargo

2 years agoAuto merge of #91599 - RalfJung:miri, r=RalfJung
bors [Tue, 7 Dec 2021 04:19:50 +0000 (04:19 +0000)]
Auto merge of #91599 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/91542
r? `@ghost`

2 years agoRecommend fix `count()` -> `len()` on slices
Michael Howell [Fri, 30 Jul 2021 06:23:17 +0000 (23:23 -0700)]
Recommend fix `count()` -> `len()` on slices

Fixes #87302

2 years agoAdd test with multiple type params failing inference
Esteban Kuber [Fri, 19 Nov 2021 06:10:43 +0000 (06:10 +0000)]
Add test with multiple type params failing inference

2 years agoRefer to const params as "const params" and not "type params"
Esteban Kuber [Mon, 8 Nov 2021 21:10:00 +0000 (21:10 +0000)]
Refer to const params as "const params" and not "type params"

2 years agoRefer to uninferred `const` params by their name, instead of `{ _: _ }`
Esteban Kuber [Mon, 8 Nov 2021 20:32:17 +0000 (20:32 +0000)]
Refer to uninferred `const` params by their name, instead of `{ _: _ }`

When the value of a const param isn't inferred, replace it with the
param name from the definition.

2 years agoOnly shown relevant type params in E0283 label
Esteban Kuber [Mon, 8 Nov 2021 19:15:54 +0000 (19:15 +0000)]
Only shown relevant type params in E0283 label

When we point at a binding to suggest giving it a type, erase all the
type for ADTs that have been resolved, leaving only the ones that could
not be inferred. For small shallow types this is not a problem, but for
big nested types with lots of params, this can otherwise cause a lot of
unnecessary visual output.

2 years agoImplement concat_bytes!
Smitty [Thu, 29 Jul 2021 17:00:55 +0000 (13:00 -0400)]
Implement concat_bytes!

The tracking issue for this is #87555.

2 years agoAnnotate comments onto the LT algorithm
Mark Rousskov [Mon, 10 May 2021 19:50:50 +0000 (15:50 -0400)]
Annotate comments onto the LT algorithm

2 years agoAuto merge of #91590 - flip1995:clippyup, r=Manishearth
bors [Tue, 7 Dec 2021 01:25:44 +0000 (01:25 +0000)]
Auto merge of #91590 - flip1995:clippyup, r=Manishearth

Update Clippy

Since RLS is now already broken #91543 , we shouldn't be blocked by it anymore. I plan to do the RLS update once new rustc-ap packages are released.

r? `@Manishearth`

2 years agoAdd test for packed drops in generators
Tomasz Miąsko [Tue, 7 Dec 2021 00:00:00 +0000 (00:00 +0000)]
Add test for packed drops in generators

2 years agoLink to rustdoc_json_types docs instead of rustdoc-json RFC
Nixon Enraght-Moony [Mon, 6 Dec 2021 23:28:32 +0000 (23:28 +0000)]
Link to rustdoc_json_types docs instead of rustdoc-json RFC

2 years agoAvoid using Option where values are always Some
Mark Rousskov [Mon, 10 May 2021 14:50:08 +0000 (10:50 -0400)]
Avoid using Option where values are always Some

2 years agoCreate newtype around the pre order index
Mark Rousskov [Sun, 9 May 2021 23:10:17 +0000 (19:10 -0400)]
Create newtype around the pre order index

2 years agoUse variables rather than lengths directly
Mark Rousskov [Sun, 9 May 2021 22:59:52 +0000 (18:59 -0400)]
Use variables rather than lengths directly

2 years agoOptimize: reuse the real-to-preorder mapping as the visited set
Mark Rousskov [Sun, 9 May 2021 16:56:58 +0000 (12:56 -0400)]
Optimize: reuse the real-to-preorder mapping as the visited set

2 years agoRemove separate RPO traversal
Mark Rousskov [Sat, 8 May 2021 23:50:50 +0000 (19:50 -0400)]
Remove separate RPO traversal

This integrates the preorder and postorder traversals into one.

2 years agoUse preorder indices for data structures
Mark Rousskov [Sat, 8 May 2021 23:13:11 +0000 (19:13 -0400)]
Use preorder indices for data structures

This largely avoids remapping from and to the 'real' indices, with the exception
of predecessor lookup and the final merge back, and is conceptually better.

2 years agoAvoid inserting into buckets if not necessary
Mark Rousskov [Sun, 9 May 2021 18:06:05 +0000 (14:06 -0400)]
Avoid inserting into buckets if not necessary

2 years agoOptimization: process buckets only once
Mark Rousskov [Sun, 9 May 2021 18:05:32 +0000 (14:05 -0400)]
Optimization: process buckets only once