]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #88215 - jyn514:lazy-loading, r=petrochenkov
Manish Goregaokar [Thu, 26 Aug 2021 19:38:07 +0000 (12:38 -0700)]
Rollup merge of #88215 - jyn514:lazy-loading, r=petrochenkov

Reland #83738: "rustdoc: Don't load all extern crates unconditionally"

I hopefully found all the bugs :crossed_fingers: time for a take two. See the last commit for details on what went wrong before.

r? `@petrochenkov` (but feel free to reassign to Guillaume if you don't have time.)

Closes https://github.com/rust-lang/rust/issues/68427. Includes a fix for https://github.com/rust-lang/rust/issues/84738.

2 years agoRollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank
Manish Goregaokar [Thu, 26 Aug 2021 19:38:06 +0000 (12:38 -0700)]
Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank

Make spans for tuple patterns in E0023 more precise

As suggested in #86307. Closes #86307.

r? ````@estebank````

2 years agoRollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco
Manish Goregaokar [Thu, 26 Aug 2021 19:38:05 +0000 (12:38 -0700)]
Rollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco

Fix debugger stepping behavior with `match` expressions

Previously, we would set up the source lines for `match` expressions so
that the code generated to perform the test of the scrutinee was matched
to the line of the arm that required the test and then jump from the arm
block to the "next" block was matched to all of the lines in the `match`
expression.

While that makes sense, it has the side effect of causing strange
stepping behavior in debuggers.

I've changed the source information so that all of the generated tests
are sourced to `match {scrutinee}` and the jumps are sourced to the last
line of the block they are inside. This resolves the weird stepping
behavior in all debuggers and resolves some instances of "ambiguous
symbol" errors in WinDbg preventing the user from setting breakpoints at
`match` expressions.

Before:

https://user-images.githubusercontent.com/831192/128577421-ee0c9c03-da28-4d16-997a-d57988a7bb7f.mp4

After:

https://user-images.githubusercontent.com/831192/128577433-2ceab04d-953e-4e31-9387-93f049c71ff3.mp4

Fixes #87817

2 years agoFix the bugs and add a regression test
Joshua Nelson [Sat, 21 Aug 2021 20:14:56 +0000 (20:14 +0000)]
Fix the bugs and add a regression test

- All attributes for an item need to be considered at once, they can't
  be considered a line at a time.
- The top-level crate was not being visited. This bug was caught by
  `extern-crate-used-only-in-link`, which I'm very glad I added.
- Make the loader private to the module, so that only one function is
  exposed.

2 years agoAuto merge of #88308 - eddyb:cooked-layouts, r=nagisa
bors [Thu, 26 Aug 2021 15:24:01 +0000 (15:24 +0000)]
Auto merge of #88308 - eddyb:cooked-layouts, r=nagisa

Morph `layout_raw` query into `layout_of`.

Before this PR, `LayoutCx::layout_of` wrapped the `layout_raw` query, to:
* normalize the type, before attempting to compute the layout
* pass the layout to `record_layout_for_printing`, for `-Zprint-type-sizes`

Moving those two responsibilities into the query may reduce overhead (due to cached calls skipping those steps), but I want to do a perf run to know.

One of the changes I had to make was changing the return type of the query, to be able to both get out the type produced by normalizing inside the query *and* to match the signature of the old `TyCtxt::layout_of`. This change may be worse, perf-wise, so that's another reason I want to check.

r? `@nagisa` cc `@oli-obk`

2 years agoAdd test for stepping though `match` expressions
Wesley Wiser [Fri, 6 Aug 2021 18:13:10 +0000 (14:13 -0400)]
Add test for stepping though `match` expressions

2 years agoAuto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk
bors [Thu, 26 Aug 2021 10:49:25 +0000 (10:49 +0000)]
Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk

Use undef for uninitialized bytes in constants

Fixes #83657

This generates good code when the const is fully uninit, e.g.

```rust
#[no_mangle]
pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> {
    const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit();
    M
}
```
generates
```asm
fully_uninit:
ret
```

as you would expect.

There is no improvement, however, when it's partially uninit, e.g.

```rust
pub struct PartiallyUninit {
    x: u64,
    y: MaybeUninit<[u8; 10]>
}

#[no_mangle]
pub const fn partially_uninit() -> PartiallyUninit {
    const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeefcafe, y: MaybeUninit::uninit() };
    X
}
```
generates
```asm
partially_uninit:
mov rax, rdi
mov rcx, qword ptr [rip + .L__unnamed_1+16]
mov qword ptr [rdi + 16], rcx
movups xmm0, xmmword ptr [rip + .L__unnamed_1]
movups xmmword ptr [rdi], xmm0
ret

.L__unnamed_1:
.asciz "\376\312\357\276\255\336\000"
.zero 16
.size .L__unnamed_1, 24
```
which copies a bunch of zeros in place of the undef bytes, the same as before this change.

Edit: generating partially-undef constants isn't viable at the moment anyways due to #84565, so it's disabled

2 years agoAuto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez
bors [Thu, 26 Aug 2021 08:04:29 +0000 (08:04 +0000)]
Auto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez

rustdoc: Move Cache from Context to SharedContext

r? `@camelid`

2 years agoAuto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa
bors [Thu, 26 Aug 2021 05:23:35 +0000 (05:23 +0000)]
Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa

Use if-let guards in the codebase and various other pattern cleanups

Dogfooding if-let guards as experimentation for the feature.

Tracking issue #51114. Conflicts with #87937.

2 years agoAuto merge of #88069 - Mark-Simulacrum:llvm-pgo, r=pietroalbini
bors [Thu, 26 Aug 2021 01:14:16 +0000 (01:14 +0000)]
Auto merge of #88069 - Mark-Simulacrum:llvm-pgo, r=pietroalbini

PGO for LLVM builds on x86_64-unknown-linux-gnu in CI

This shows up to 6% less instruction counts with larger - up to 18% - wins on cycles
on multiple benchmarks, and up to 19% wins on the -j1 wall times for rustc self-compilation.

We can afford to spend the extra cycles building LLVM essentially once more for
the x86_64-unknown-linux-gnu CI build today. The builder finishes in around 50
minutes on average, and this adds just 10 more minutes. Given the sizeable
improvements in compiler performance, this is definitely worth it.

2 years agouse a peekable iterator to check the first chunk
Erik Desjardins [Wed, 25 Aug 2021 21:44:27 +0000 (17:44 -0400)]
use a peekable iterator to check the first chunk

2 years agoyet more comment improvements
Erik Desjardins [Wed, 25 Aug 2021 21:40:57 +0000 (17:40 -0400)]
yet more comment improvements

2 years agoimprove comments
Erik Desjardins [Sun, 15 Aug 2021 16:24:58 +0000 (12:24 -0400)]
improve comments

2 years agoput code in a more logical order
Erik Desjardins [Sat, 14 Aug 2021 18:13:06 +0000 (14:13 -0400)]
put code in a more logical order

2 years agoadd comments
Erik Desjardins [Sat, 14 Aug 2021 17:54:35 +0000 (13:54 -0400)]
add comments

2 years agoimplement InitMaskCompressed using InitChunkIter, cleanup
Erik Desjardins [Wed, 11 Aug 2021 03:16:11 +0000 (23:16 -0400)]
implement InitMaskCompressed using InitChunkIter, cleanup

2 years agooptimize initialization checks
Erik Desjardins [Tue, 10 Aug 2021 23:29:18 +0000 (19:29 -0400)]
optimize initialization checks

2 years agoimprove comment
Erik Desjardins [Tue, 10 Aug 2021 05:26:33 +0000 (01:26 -0400)]
improve comment

2 years agodon't generate partially-undef consts
Erik Desjardins [Tue, 27 Apr 2021 04:15:41 +0000 (00:15 -0400)]
don't generate partially-undef consts

2 years agouse undef for uninitialized bytes in constants
Erik Desjardins [Wed, 31 Mar 2021 04:06:01 +0000 (00:06 -0400)]
use undef for uninitialized bytes in constants

2 years agoAdjust spans
Noah Lev [Wed, 25 Aug 2021 21:40:06 +0000 (14:40 -0700)]
Adjust spans

* Highlight the whole pattern if it has no fields
* Highlight the whole definition if it has no fields
* Only highlight the pattern name if the pattern is multi-line
* Determine whether a pattern is multi-line based on distance from name
  to last field, rather than first field

2 years agoBump download-ci-llvm stamp
Mark Rousskov [Wed, 25 Aug 2021 18:33:23 +0000 (14:33 -0400)]
Bump download-ci-llvm stamp

This will ensure the optimized LLVM is used for local builds after rebasing
immediately, rather than needing to wait for a future LLVM bump.

2 years agoBump sccache used in CI to v0.2.15
Mark Rousskov [Tue, 24 Aug 2021 21:15:14 +0000 (17:15 -0400)]
Bump sccache used in CI to v0.2.15

This skips bumping Windows sccache because we run into compilation failures when
doing so (-m32 not supported by clang-cl?). Not clear on cause, but seems
easiest to just hold back.

This should avoid PGO-related failures encountered on Linux, and more broadly
seems like a good idea on other platforms as well (though it is likely not
necessary right this moment).

2 years agoAuto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakis
bors [Wed, 25 Aug 2021 20:08:00 +0000 (20:08 +0000)]
Auto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakis

Normalize projections under binders

Fixes #70243
Fixes #70120
Fixes #62529
Fixes #87219

Issues to followup on after (probably fixed, but no test added here):
#76956
#56556
#79207
#85636

r? `@nikomatsakis`

2 years agoBless NLL compare mode
jackh726 [Wed, 25 Aug 2021 20:06:52 +0000 (16:06 -0400)]
Bless NLL compare mode

2 years agoFix debugger stepping behavior around `match` expressions
Wesley Wiser [Fri, 23 Jul 2021 22:55:36 +0000 (18:55 -0400)]
Fix debugger stepping behavior around `match` expressions

Previously, we would set up the source lines for `match` expressions so
that the code generated to perform the test of the scrutinee was matched
to the line of the arm that required the test and then jump from the arm
block to the "next" block was matched to all of the lines in the `match`
expression.

While that makes sense, it has the side effect of causing strange
stepping behavior in debuggers.

I've changed the source information so that all of the generated tests
are sourced to `match {scrutinee}` and the jumps are sourced to the last
line of the block they are inside. This resolves the weird stepping
behavior in all debuggers and resolves some instances of "ambiguous
symbol" errors in WinDbg preventing the user from setting breakpoints at
`match` expressions.

2 years agoVarious pattern cleanups
Léo Lanteri Thauvin [Mon, 16 Aug 2021 15:30:23 +0000 (17:30 +0200)]
Various pattern cleanups

2 years agoUse if-let guards in the codebase
Léo Lanteri Thauvin [Mon, 16 Aug 2021 15:29:49 +0000 (17:29 +0200)]
Use if-let guards in the codebase

2 years agoAuto merge of #88329 - LeSeulArtichaut:rollup-blg8hc0, r=LeSeulArtichaut
bors [Wed, 25 Aug 2021 16:22:57 +0000 (16:22 +0000)]
Auto merge of #88329 - LeSeulArtichaut:rollup-blg8hc0, r=LeSeulArtichaut

Rollup of 16 pull requests

Successful merges:

 - #87944 (add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells)
 - #88156 (Adjust / fix documentation of `Arc::make_mut`)
 - #88157 (bootstrap.py: recognize riscv64 when auto-detect)
 - #88196 (Refactor `named_asm_labels` to a HIR lint)
 - #88218 (Remove `Session.trait_methods_not_found`)
 - #88223 (Remove the `TryV2` alias)
 - #88226 (Fix typo “a Rc” → “an Rc” (and a few more))
 - #88267 (2229: Update signature for truncate function)
 - #88273 (Fix references to `ControlFlow` in docs)
 - #88277 (Update books)
 - #88291 (Add SAFETY comments to core::slice::sort::partition_in_blocks)
 - #88293 (Fix grammar in alloc test)
 - #88298 (Errorkind reorder)
 - #88299 (Stabilise BufWriter::into_parts)
 - #88314 (Add type of a let tait test)
 - #88325 (Add mutable-noalias to the release notes for 1.54)

Failed merges:

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

2 years agoRollup merge of #88325 - jyn514:noalias, r=XAMPPRocky
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:49:03 +0000 (15:49 +0200)]
Rollup merge of #88325 - jyn514:noalias, r=XAMPPRocky

Add mutable-noalias to the release notes for 1.54

It was enabled in #82834 and disabled in 1.53 by #86036, but it was never disabled on (then) nightly, so it still landed in 1.54.

This was mentioned on https://github.com/rust-lang/rust/pull/86696 but never made it into the release notes.

r? `@XAMPPRocky` cc `@nikic`

2 years agoRollup merge of #88314 - spastorino:type-of-a-let-tait-test, r=oli-obk
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:49:02 +0000 (15:49 +0200)]
Rollup merge of #88314 - spastorino:type-of-a-let-tait-test, r=oli-obk

Add type of a let tait test

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88299 - ijackson:bufwriter, r=Mark-Simulacrum
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:49:01 +0000 (15:49 +0200)]
Rollup merge of #88299 - ijackson:bufwriter, r=Mark-Simulacrum

Stabilise BufWriter::into_parts

The FCP for this has already completed, in #80690.

This was just blocked on #85901 (which changed the name), which is now merged.  The original stabilisation MR was #84770 but that has a lot of noise in it, and I also accidentally deleted the branch while trying to tidy up.  So here is a new MR.  Sorry for the noise.

Closes #80690

2 years agoRollup merge of #88298 - ijackson:errorkind-reorder, r=dtolnay
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:49:00 +0000 (15:49 +0200)]
Rollup merge of #88298 - ijackson:errorkind-reorder, r=dtolnay

Errorkind reorder

I was doing a bit more work in this area and the untidiness of these two orderings bothered me.

The commit messages have the detailed rationale.  For your convenience, I c&p them here:

```
    io::ErrorKind: rationalise ordering in main enum

    It is useful to keep some coherent structure to this ordering.  In
    particular, Other and Uncategorized should be next to each other, at
    the end.

    Also it seems to make sense to treat UnexpectedEof and OutOfMemory
    specially, since they are not like the other errors (despite
    OutOfMemory also being generatable by some OS errors).

    So:
     * Move Other to the end, just before Uncategorized
     * Move Unsupported to between Interrupted and UnexpectedEof
     * Add some comments documenting where to add things
```

```
    io::Error: alphabeticise the match in as_str()

    There was no rationale for the previous ordering.
```

r? kennytm   since that's who rust-highfive picked before, in #88294 which I accidentally closed.

2 years agoRollup merge of #88293 - est31:fix_grammar, r=Mark-Simulacrum
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:59 +0000 (15:48 +0200)]
Rollup merge of #88293 - est31:fix_grammar, r=Mark-Simulacrum

Fix grammar in alloc test

2 years agoRollup merge of #88291 - mdsn:partition-in-blocks-safety, r=Mark-Simulacrum
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:58 +0000 (15:48 +0200)]
Rollup merge of #88291 - mdsn:partition-in-blocks-safety, r=Mark-Simulacrum

Add SAFETY comments to core::slice::sort::partition_in_blocks

A few more SAFETY comments for #66219. There are still a few more in this module.

`@rustbot` label T-libs T-compiler C-cleanup

2 years agoRollup merge of #88277 - ehuss:update-books, r=ehuss
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:57 +0000 (15:48 +0200)]
Rollup merge of #88277 - ehuss:update-books, r=ehuss

Update books

## reference

1 commits in 4884fe45c14f8b22121760fb117181bb4da8dfe0..da6ea9b03f74cae0a292f40315723d7a3a973637
2021-07-28 21:31:28 -0700 to 2021-08-19 21:28:10 -0700
- Allow users to change status labels (rust-lang/reference#1083)

## book

7 commits in 7e49659102f0977d9142190e1ba23345c0f00eb1..687e21bde2ea10c261f79fa14797c5137425098d
2021-08-03 21:41:35 -0400 to 2021-08-18 20:48:38 -0400
- Small tweaks to Ferris size and position
- Retain previous height: auto just in case
- Shrink and move ferris when possible
- Snapshot chapter 6 for nostarch
- Demonstrate variable as catch-all for match. Fixes rust-lang/book#1868.
- Improve the if let example to have a binding pattern. Fixes rust-lang/book#1401.
- Fixes typo (rust-lang/book#2816)

## rust-by-example

1 commits in 0dc9cd4e89f00cb5230f120e1a083916386e422b..04f489c889235fe3b6dfe678ae5410d07deda958
2021-07-23 09:14:27 -0300 to 2021-08-17 08:01:20 -0300
- Grammar mistake (rust-lang/rust-by-example#1456)

## rustc-dev-guide

5 commits in c4644b427cbdaafc7a87be0ccdf5d8aaa07ac35f..cf0e151b7925a40f13fbc6573c6f97d5f94c7c17
2021-08-10 20:41:44 +0900 to 2021-08-22 11:47:02 -0300
- Fix typo “a Rc” → “an Rc” (rust-lang/rustc-dev-guide#1191)
- Expand THIR section with more details (rust-lang/rustc-dev-guide#1183)
- Remove docs for old -Z profile-queries flag
- update mdbook version to latest
- allow to quickly edit a page directly on github

2 years agoRollup merge of #88273 - jhpratt:update-iterator-docs, r=jyn514
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:55 +0000 (15:48 +0200)]
Rollup merge of #88273 - jhpratt:update-iterator-docs, r=jyn514

Fix references to `ControlFlow` in docs

The `Iterator::for_each` method previously stated that it was not possible to use `break` and `continue` in it — this has been updated to acknowledge the stabilization of `ControlFlow`. Additionally, `ControlFlow` was referred to as `crate::ops::ControlFlow` which is not the correct path for an end user.

r? `@jyn514`

2 years agoRollup merge of #88267 - sexxi-goose:truncate_unique, r=nikomatsakis
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:54 +0000 (15:48 +0200)]
Rollup merge of #88267 - sexxi-goose:truncate_unique, r=nikomatsakis

2229: Update signature for truncate function

r? `@nikomatsakis`

2 years agoRollup merge of #88226 - steffahn:an_rc, r=michaelwoerister
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:53 +0000 (15:48 +0200)]
Rollup merge of #88226 - steffahn:an_rc, r=michaelwoerister

Fix typo “a Rc” → “an Rc” (and a few more)

After stumbling about it in the dev-guide, I’ve devided to eliminate all mentions of “a Rc”, replacing it with “an Rc”. E.g.
```plain
$ rg "(^|[^'])\ba\b[^\w=:]*\bRc"
compiler/rustc_data_structures/src/owning_ref/mod.rs
1149:/// Typedef of a owning reference that uses a `Rc` as the owner.

library/std/src/ffi/os_str.rs
919:    /// Converts a [`OsString`] into a [`Rc`]`<OsStr>` without copying or allocating.

library/std/src/ffi/c_str.rs
961:    /// Converts a [`CString`] into a [`Rc`]`<CStr>` without copying or allocating.

src/doc/rustc-dev-guide/src/query.md
61:are cheaply cloneable; insert a `Rc` if necessary).

src/doc/book/src/ch15-06-reference-cycles.md
72:decreases the reference count of the `a` `Rc<List>` instance from 2 to 1 as

library/alloc/src/rc.rs
1746:    /// Converts a generic type `T` into a `Rc<T>`
```
_(the match in the book is a false positive)_
Since the dev-guide is a submodule, it’s getting a separate PR: rust-lang/rustc-dev-guide#1191

I’ve also gone ahead and done the same search for `RwLock` and hit a few cases in the `OwningRef` adaption. Then, I couldn’t keep the countless cases of “a owning …” or “a owner” unaddressed, which concludes this PR.

`@rustbot` label C-cleanup

2 years agoRollup merge of #88223 - scottmcm:fix-alias, r=yaahc
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:52 +0000 (15:48 +0200)]
Rollup merge of #88223 - scottmcm:fix-alias, r=yaahc

Remove the `TryV2` alias

Post-bootstrap-update cleanup.

(No more `try_trait_transition` feature.)

2 years agoRollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisa
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:51 +0000 (15:48 +0200)]
Rollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisa

Remove `Session.trait_methods_not_found`

Instead, avoid registering the problematic well-formed obligation
to begin with. This removes global untracked mutable state,
and avoids potential issues with incremental compilation.

2 years agoRollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=Amanieu
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:50 +0000 (15:48 +0200)]
Rollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=Amanieu

Refactor `named_asm_labels` to a HIR lint

As discussed on #88169, the `named_asm_labels` lint could be moved to a HIR lint.  That allows future lints or custom plugins or clippy lints to more easily access the `asm!` macro's data and create better error messages with the lints.

2 years agoRollup merge of #88157 - Icenowy:bootstrap-riscv64, r=Mark-Simulacrum
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:49 +0000 (15:48 +0200)]
Rollup merge of #88157 - Icenowy:bootstrap-riscv64, r=Mark-Simulacrum

bootstrap.py: recognize riscv64 when auto-detect

The architecture auto-detect table has no entry for riscv64 (which rustc
uses riscv64gc for the first part of triplet, assuming it's a generic
Linux distro).

Add it to the table to allow riscv64 systems to bootstrap Rust.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2 years agoRollup merge of #88156 - steffahn:arc_make_mut_and_weak, r=Mark-Simulacrum
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:48 +0000 (15:48 +0200)]
Rollup merge of #88156 - steffahn:arc_make_mut_and_weak, r=Mark-Simulacrum

Adjust / fix documentation of `Arc::make_mut`

Related discussion in the users forum:
[Whatʼs this alleged difference between Arc::make_mut and Rc::make_mut? – The Rust Programming Language Forum](https://users.rust-lang.org/t/what-s-this-alleged-difference-between-arc-make-mut-and-rc-make-mut/63747?u=steffahn)

Also includes a small formatting improvement in the documentation of `Rc::make_mut`.

This PR makes the two documentations in question complete analogs. The previously claimed point in which one “differs from the behavior of” the other turns out to be incorrect, AFAIK.

One remaining inaccuracy: `Weak` pointers aren’t disassociated from the allocation but only from the contained value, i.e. in case of outstanding `Weak` pointers there still is a new allocation created, just the call to `.clone()` is avoided, instead the value is moved from one allocation to the other.

`@rustbot` label T-libs-api, A-docs

2 years agoRollup merge of #87944 - oconnor663:as_array_of_cells, r=scottmcm
Léo Lanteri Thauvin [Wed, 25 Aug 2021 13:48:47 +0000 (15:48 +0200)]
Rollup merge of #87944 - oconnor663:as_array_of_cells, r=scottmcm

add Cell::as_array_of_cells, similar to Cell::as_slice_of_cells

I'd like to propose adding `Cell::as_array_of_cells`, as a natural analog to `Cell::as_slice_of_cells`. I don't have a specific use case in mind, other than that supporting slices but not arrays feels like a gap. Do other folks agree with that intuition? Would this addition be substantial enough to need an RFC?

---

Previously, converting `&mut [T; N]` to `&[Cell<T>; N]` looks like this:

```rust
let array = &mut [1, 2, 3];
let cells: &[Cell<i32>; 3] = Cell::from_mut(&mut array[..])
    .as_slice_of_cells()
    .try_into()
    .unwrap();
```

With this new helper method, it looks like this:

```rust
let array = &mut [1, 2, 3];
let cells = Cell::from_mut(array).as_array_of_cells();
```

2 years agoAuto merge of #87937 - LeSeulArtichaut:active-if-let-guards, r=nagisa
bors [Wed, 25 Aug 2021 13:42:02 +0000 (13:42 +0000)]
Auto merge of #87937 - LeSeulArtichaut:active-if-let-guards, r=nagisa

Don't mark `if_let_guard` as an incomplete feature

I don't think there is any reason for `if_let_guard` to be an incomplete feature, and I think the reason they were marked in the first place was simply because they weren't implemented at all.

r? `@pnkfelix`
cc tracking issue #51114

2 years agoAdd mutable-noalias to the release notes for 1.54
Joshua Nelson [Wed, 25 Aug 2021 12:11:48 +0000 (07:11 -0500)]
Add mutable-noalias to the release notes for 1.54

2 years agoAuto merge of #85344 - cbeuw:remap-across-cwd, r=michaelwoerister
bors [Wed, 25 Aug 2021 10:58:43 +0000 (10:58 +0000)]
Auto merge of #85344 - cbeuw:remap-across-cwd, r=michaelwoerister

Correctly handle remapping from path containing the current directory with trailing paths

If we have a `auxiliary/lib.rs`, and we generate the metadata with `--remap-path-prefix $PWD/auxiliary=xyz`, the path to `$PWD/auxiliary/lib.rs` won't be correctly remapped in the metadata. This is because internally, path to the working directory itself and relative paths to files under the working directory are remapped separately (hence neither are affected since neither has `$PWD/auxiliary` as prefix), but the concatenation between the working directory and the relative path is not remapped. This PR fixes that.

2 years agoAuto merge of #87875 - asquared31415:generic-lang-items, r=cjgillot
bors [Wed, 25 Aug 2021 08:12:16 +0000 (08:12 +0000)]
Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillot

Improve detection of generics on lang items

Adds detection for the required generics for all lang items.  Many lang items require an exact or minimum amount of generic arguments and if they don't exist, the compiler will ICE.  This does not add any additional validation about bounds on generics or any other lang item restrictions.

Fixes one of the ICEs in #87573

cc `@FabianWolff`

2 years agoAuto merge of #84333 - tmiasko:liveness-yield, r=tmandry
bors [Wed, 25 Aug 2021 05:31:26 +0000 (05:31 +0000)]
Auto merge of #84333 - tmiasko:liveness-yield, r=tmandry

Improve liveness analysis for generators

Liveness analysis for generators assumes that execution always continues
normally after a yield point, not accounting for the fact that generator
could be dropped before completion.

If generators captures any variables by reference, those variables could
be used within a generator, or when the generator completes, but also
after each yield point in the case the generator is dropped.

Account for the case when generator is dropped after yielding, but
before running to the completion. This effectively considers all
variables captured by reference to be used after a yield point.

Fixes #84292.

2 years agoReview comments
jackh726 [Wed, 25 Aug 2021 02:26:48 +0000 (22:26 -0400)]
Review comments

2 years agoAlso ignore typeoutlives predicates
jackh726 [Fri, 23 Jul 2021 18:26:02 +0000 (14:26 -0400)]
Also ignore typeoutlives predicates

2 years agoNormalize only after failure
jackh726 [Fri, 23 Jul 2021 04:10:56 +0000 (00:10 -0400)]
Normalize only after failure

2 years agoNormalize associated types with bound vars
Jack Huey [Mon, 3 May 2021 13:25:32 +0000 (09:25 -0400)]
Normalize associated types with bound vars

2 years agoAuto merge of #88242 - bonega:allocation_range, r=oli-obk
bors [Wed, 25 Aug 2021 02:17:41 +0000 (02:17 +0000)]
Auto merge of #88242 - bonega:allocation_range, r=oli-obk

Use custom wrap-around type instead of RangeInclusive

Two reasons:

1. More memory is allocated than necessary for `valid_range` in `Scalar`. The range is not used as an iterator and `exhausted` is never used.
2. `contains`, `count` etc. methods in `RangeInclusive` are doing very unhelpful(and dangerous!) things when used as a wrap-around range. - In general this PR wants to limit potentially confusing methods, that have a low probability of working.

Doing a local perf run, every metric shows improvement except for instructions.
Max-rss seem to have a very consistent improvement.

Sorry - newbie here, probably doing something wrong.

2 years agoAdd type of a let tait test impl trait straight in let
Santiago Pastorino [Wed, 25 Aug 2021 01:52:41 +0000 (22:52 -0300)]
Add type of a let tait test impl trait straight in let

2 years agoAdd type of a let tait test
Santiago Pastorino [Wed, 25 Aug 2021 01:10:38 +0000 (22:10 -0300)]
Add type of a let tait test

2 years agoAuto merge of #88271 - sexxi-goose:liveness, r=nikomatsakis
bors [Tue, 24 Aug 2021 23:30:44 +0000 (23:30 +0000)]
Auto merge of #88271 - sexxi-goose:liveness, r=nikomatsakis

2229: Consider varaiables mentioned in closure as used

Fixes: https://github.com/rust-lang/project-rfc-2229/issues/57
r? `@nikomatsakis`

2 years agoPGO for LLVM builds on x86_64-unknown-linux-gnu in CI
Mark Rousskov [Wed, 11 Aug 2021 17:17:21 +0000 (13:17 -0400)]
PGO for LLVM builds on x86_64-unknown-linux-gnu in CI

This shows up to 5% less instruction counts on multiple benchmarks, and up to
19% wins on the -j1 wall times for rustc self-compilation.

We can afford to spend the extra cycles building LLVM essentially once more for
the x86_64-unknown-linux-gnu CI build today. The builder finishes in around 50
minutes on average, and this adds just 10 more minutes. Given the sizeable
improvements in compiler performance, this is definitely worth it.

2 years agoAuto merge of #88266 - nikomatsakis:issue-87879, r=jackh726
bors [Tue, 24 Aug 2021 20:49:55 +0000 (20:49 +0000)]
Auto merge of #88266 - nikomatsakis:issue-87879, r=jackh726

resolve type variables after checking casts

r? `@jackh726`

Fixes #87814
Fixes #88118

Supercedes #87879 (cc `@ldm0)`

2 years agoAdd SAFETY comments to core::slice::sort::partition_in_blocks
Mariano Casco [Tue, 24 Aug 2021 15:04:02 +0000 (12:04 -0300)]
Add SAFETY comments to core::slice::sort::partition_in_blocks

2 years agoMake explanations of cross-references between `make_mut` and `get_mut` more accurate
Frank Steffahn [Tue, 24 Aug 2021 19:34:12 +0000 (21:34 +0200)]
Make explanations of cross-references between `make_mut` and `get_mut` more accurate

2 years agoClarifiy weak pointers being diassociated…
Frank Steffahn [Tue, 24 Aug 2021 19:15:26 +0000 (21:15 +0200)]
Clarifiy weak pointers being diassociated…

…noting the fact that `clone` is not called.

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2 years agoMorph `layout_raw` query into `layout_of`.
Eduard-Mihai Burtescu [Tue, 24 Aug 2021 18:29:30 +0000 (21:29 +0300)]
Morph `layout_raw` query into `layout_of`.

2 years agouse convention for with_* methods
Andreas Liljeqvist [Tue, 24 Aug 2021 17:41:58 +0000 (19:41 +0200)]
use convention for with_* methods

2 years agoAuto merge of #87472 - inquisitivecrystal:stabilize-force-warn, r=Mark-Simulacrum
bors [Tue, 24 Aug 2021 17:41:24 +0000 (17:41 +0000)]
Auto merge of #87472 - inquisitivecrystal:stabilize-force-warn, r=Mark-Simulacrum

Stabilize and document `--force-warn`

This PR will stabilize and document the `--force-warn` command line option. It is currently a draft, pending an FCP.

I've taken the liberty of tidying up the lint level command line options a bit as part of this. The changes are quite minor and should only affect rustc's help output. I'm making them here because they're trivial and, in one case, necessary to unify the way `--force-warn` with the way the other options are displayed.

I also want to mention that `@rylev` has done a ton of work on moving this along and deserves most of the credit. I'm just the one who landed up writing this particular PR.

Resolves #86516.

2 years agoStabilise BufWriter::into_parts
Ian Jackson [Fri, 30 Apr 2021 23:38:01 +0000 (00:38 +0100)]
Stabilise BufWriter::into_parts

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoFix tidy
Ian Jackson [Tue, 24 Aug 2021 16:44:16 +0000 (17:44 +0100)]
Fix tidy

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoFix grammar
est31 [Tue, 24 Aug 2021 15:56:39 +0000 (17:56 +0200)]
Fix grammar

2 years agoio::ErrorKind: rationalise ordering in main enum
Ian Jackson [Tue, 24 Aug 2021 15:53:58 +0000 (16:53 +0100)]
io::ErrorKind: rationalise ordering in main enum

It is useful to keep some coherent structure to this ordering.  In
particular, Other and Uncategorized should be next to each other, at
the end.

Also it seems to make sense to treat UnexpectedEof and OutOfMemory
specially, since they are not like the other errors (despite
OutOfMemory also being generatable by some OS errors).

So:
 * Move Other to the end, just before Uncategorized
 * Move Unsupported to between Interrupted and UnexpectedEof
 * Add some comments documenting where to add things

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoio::Error: alphabeticise the match in as_str()
Ian Jackson [Tue, 24 Aug 2021 15:51:58 +0000 (16:51 +0100)]
io::Error: alphabeticise the match in as_str()

There was no rationale for the previous ordering.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoUpdate tests
inquisitivecrystal [Sat, 24 Jul 2021 08:08:33 +0000 (01:08 -0700)]
Update tests

This updates tests to reflect that `force-warn` is now stable.

2 years agoDocument `force-warn`
inquisitivecrystal [Sat, 24 Jul 2021 06:31:09 +0000 (23:31 -0700)]
Document `force-warn`

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2 years agoStabilize `force-warn`
inquisitivecrystal [Sat, 24 Jul 2021 07:05:24 +0000 (00:05 -0700)]
Stabilize `force-warn`

2 years agoTidy up lint command line flags
inquisitivecrystal [Sat, 24 Jul 2021 06:59:17 +0000 (23:59 -0700)]
Tidy up lint command line flags

2 years agoAuto merge of #87900 - jackh726:issue-87429, r=nikomatsakis
bors [Tue, 24 Aug 2021 14:55:48 +0000 (14:55 +0000)]
Auto merge of #87900 - jackh726:issue-87429, r=nikomatsakis

Use bound vars for GAT params in param_env in check_type_bounds

Fixes #87429

2 years agoMove `named_asm_labels` to a HIR lint
asquared31415 [Thu, 19 Aug 2021 20:34:01 +0000 (16:34 -0400)]
Move `named_asm_labels` to a HIR lint

2 years agoIgnore test on Windows
Andy Wang [Tue, 24 Aug 2021 12:21:27 +0000 (13:21 +0100)]
Ignore test on Windows

2 years agoAuto merge of #87699 - ubamrein:use-iphone-deployment-target-for-llvm, r=petrochenkov
bors [Tue, 24 Aug 2021 12:13:37 +0000 (12:13 +0000)]
Auto merge of #87699 - ubamrein:use-iphone-deployment-target-for-llvm, r=petrochenkov

Allow specifying an deployment target version for all iOS llvm targets

Closes: https://github.com/rust-lang/rust/issues/79408
This pull requests adds the same procedure to define the iOS-version for the LLVM-target as was used for the simulator target and the desktop target.

This then closes the original problem mentioned in the above issue. The problem with incompatible bitcode remains, but is probably not easy fixable.

I realised that something is still not right. Try to fix that.

r? `@petrochenkov`

2 years agoImprove liveness analysis for generators
Tomasz Miąsko [Mon, 19 Apr 2021 00:00:00 +0000 (00:00 +0000)]
Improve liveness analysis for generators

Liveness analysis for generators assumes that execution always continues
normally after a yield point, not accounting for the fact that generator
could be dropped before completion.

If generators captures any variables by reference, those variables could
be used within a generator, or when the generator completes, but also
after each yield point in the case the generator is dropped.

Account for the case when generator is dropped after yielding, but
before running to the completion. This effectively considers all
variables captured by reference to be used after a yield point.

2 years agoForce inline: small functions and single call-site
Andreas Liljeqvist [Tue, 24 Aug 2021 08:18:07 +0000 (10:18 +0200)]
Force inline: small functions and single call-site

2 years agoallow specifying an ios version for the llvm target
Patrick Amrein [Mon, 2 Aug 2021 13:26:24 +0000 (15:26 +0200)]
allow specifying an ios version for the llvm target

2 years agoAuto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser
bors [Tue, 24 Aug 2021 03:58:22 +0000 (03:58 +0000)]
Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser

Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`

Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.

2 years agoUpdate books
Eric Huss [Tue, 24 Aug 2021 02:42:31 +0000 (19:42 -0700)]
Update books

2 years agoAuto merge of #85556 - FabianWolff:issue-85071, r=estebank,jackh726
bors [Tue, 24 Aug 2021 01:36:09 +0000 (01:36 +0000)]
Auto merge of #85556 - FabianWolff:issue-85071, r=estebank,jackh726

Warn about unreachable code following an expression with an uninhabited type

This pull request fixes #85071. The issue is that liveness analysis currently is "smarter" than reachability analysis when it comes to detecting uninhabited types: Unreachable code is detected during type checking, where full type information is not yet available. Therefore, the check for type inhabitedness is quite crude:
https://github.com/rust-lang/rust/blob/fc81ad22c453776de16acf9938976930cf8c9401/compiler/rustc_typeck/src/check/expr.rs#L202-L205

i.e. it only checks for `!`, but not other, non-trivially uninhabited types, such as empty enums, structs containing an uninhabited type, etc. By contrast, liveness analysis, which runs after type checking, can benefit from the more sophisticated `tcx.is_ty_uninhabited_from()`:
https://github.com/rust-lang/rust/blob/fc81ad22c453776de16acf9938976930cf8c9401/compiler/rustc_passes/src/liveness.rs#L981
https://github.com/rust-lang/rust/blob/fc81ad22c453776de16acf9938976930cf8c9401/compiler/rustc_passes/src/liveness.rs#L996

This can lead to confusing warnings when a variable is reported as unused, but the use of the variable is not reported as unreachable. For instance:
```rust
enum Foo {}
fn f() -> Foo {todo!()}

fn main() {
    let x = f();
    let _ = x;
}
```
currently leads to
```
warning: unused variable: `x`
 --> t1.rs:5:9
  |
5 |     let x = f();
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted
```
which is confusing, because `x` _appears_ to be used in line 6. With my changes, I get:
```
warning: unreachable expression
 --> t1.rs:6:13
  |
5 |     let x = f();
  |             --- any code following this expression is unreachable
6 |     let _ = x;
  |             ^ unreachable expression
  |
  = note: `#[warn(unreachable_code)]` on by default
note: this expression has type `Foo`, which is uninhabited
 --> t1.rs:5:13
  |
5 |     let x = f();
  |             ^^^

warning: unused variable: `x`
 --> t1.rs:5:9
  |
5 |     let x = f();
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted
```
My implementation is slightly inelegant because unreachable code warnings can now be issued in two different places (during type checking and during liveness analysis), but I think it is the solution with the least amount of unnecessary code duplication, given that the new warning integrates nicely with liveness analysis, where unreachable code is already implicitly detected for the purpose of finding unused variables.

2 years agoAlso fix “a `OwningRef`”
Frank Steffahn [Sun, 22 Aug 2021 10:41:53 +0000 (12:41 +0200)]
Also fix “a `OwningRef`”

2 years agoAlso fix “a RwLock*”
Frank Steffahn [Sun, 22 Aug 2021 10:39:39 +0000 (12:39 +0200)]
Also fix “a RwLock*”

2 years agoFix typo “a Rc” → “an Rc”
Frank Steffahn [Sun, 22 Aug 2021 10:33:27 +0000 (12:33 +0200)]
Fix typo “a Rc” → “an Rc”

2 years agoFix references to `ControlFlow` in docs
Jacob Pratt [Tue, 24 Aug 2021 00:02:17 +0000 (20:02 -0400)]
Fix references to `ControlFlow` in docs

2 years agoAuto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay
bors [Mon, 23 Aug 2021 22:55:19 +0000 (22:55 +0000)]
Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay

Get piece unchecked in `write`

We already use specialized `zip`, but it seems like we can do a little better by not checking `pieces` length at all.

`Arguments` constructors are now unsafe. So the `format_args!` expansion now includes an `unsafe` block.

<details>
<summary>Local Bench Diff</summary>

```text
 name                        before ns/iter  after ns/iter  diff ns/iter   diff %  speedup
 fmt::write_str_macro1       22,967          19,718               -3,249  -14.15%   x 1.16
 fmt::write_str_macro2       35,527          32,654               -2,873   -8.09%   x 1.09
 fmt::write_str_macro_debug  571,953         575,973               4,020    0.70%   x 0.99
 fmt::write_str_ref          9,579           9,459                  -120   -1.25%   x 1.01
 fmt::write_str_value        9,573           9,572                    -1   -0.01%   x 1.00
 fmt::write_u128_max         176             173                      -3   -1.70%   x 1.02
 fmt::write_u128_min         138             134                      -4   -2.90%   x 1.03
 fmt::write_u64_max          139             136                      -3   -2.16%   x 1.02
 fmt::write_u64_min          129             135                       6    4.65%   x 0.96
 fmt::write_vec_macro1       24,401          22,273               -2,128   -8.72%   x 1.10
 fmt::write_vec_macro2       37,096          35,602               -1,494   -4.03%   x 1.04
 fmt::write_vec_macro_debug  588,291         589,575               1,284    0.22%   x 1.00
 fmt::write_vec_ref          9,568           9,732                   164    1.71%   x 0.98
 fmt::write_vec_value        9,516           9,625                   109    1.15%   x 0.99
```
</details>

2 years ago2229: Consider varaiables mentioned in closure as used
Aman Arora [Mon, 23 Aug 2021 22:47:38 +0000 (18:47 -0400)]
2229: Consider varaiables mentioned in closure as used

2 years agofix test
Niko Matsakis [Mon, 23 Aug 2021 22:25:55 +0000 (22:25 +0000)]
fix test

2 years agox.py fmt
Niko Matsakis [Mon, 23 Aug 2021 22:21:21 +0000 (22:21 +0000)]
x.py fmt

2 years agoAdd comment and extra test
jackh726 [Mon, 23 Aug 2021 20:39:11 +0000 (16:39 -0400)]
Add comment and extra test

2 years agoAdd a couple more tests
jackh726 [Mon, 16 Aug 2021 14:49:36 +0000 (10:49 -0400)]
Add a couple more tests

2 years agoWhen checking associated type bounds, use bound vars for GAT params in param_env
jackh726 [Mon, 9 Aug 2021 23:26:13 +0000 (19:26 -0400)]
When checking associated type bounds, use bound vars for GAT params in param_env

2 years ago2229: Update signature for truncate function
Aman Arora [Mon, 23 Aug 2021 19:59:46 +0000 (15:59 -0400)]
2229: Update signature for truncate function

2 years agoAuto merge of #88265 - m-ou-se:rollup-soymv20, r=m-ou-se
bors [Mon, 23 Aug 2021 20:10:29 +0000 (20:10 +0000)]
Auto merge of #88265 - m-ou-se:rollup-soymv20, r=m-ou-se

Rollup of 6 pull requests

Successful merges:

 - #87976 (Account for tabs when highlighting multiline code suggestions)
 - #88174 (Clarify some wording in Rust 2021 lint docs)
 - #88188 (Greatly improve limitation handling on parallel rustdoc GUI test run)
 - #88230 (Fix typos “a”→“an”)
 - #88232 (Add notes to macro-not-found diagnostics to point out how things with the same name were not a match.)
 - #88259 (Do not mark `-Z thir-unsafeck` as unsound anymore)

Failed merges:

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

2 years agoadd trailing newline
Niko Matsakis [Mon, 23 Aug 2021 19:53:18 +0000 (19:53 +0000)]
add trailing newline

2 years agouseful debug printouts
Niko Matsakis [Mon, 23 Aug 2021 19:14:06 +0000 (19:14 +0000)]
useful debug printouts

The changes to dumping expressions seem particularly useful