Commit graph

153517 commits

Author SHA1 Message Date
Léo Lanteri Thauvin
d9ed23a913
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`
2021-08-25 15:49:03 +02:00
Léo Lanteri Thauvin
16fd95c482
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
2021-08-25 15:49:02 +02:00
Léo Lanteri Thauvin
3eee91b403
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
2021-08-25 15:49:01 +02:00
Léo Lanteri Thauvin
82ecb0f412
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.
2021-08-25 15:49:00 +02:00
Léo Lanteri Thauvin
0aabf4bb4b
Rollup merge of #88293 - est31:fix_grammar, r=Mark-Simulacrum
Fix grammar in alloc test
2021-08-25 15:48:59 +02:00
Léo Lanteri Thauvin
dc2c9746f8
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
2021-08-25 15:48:58 +02:00
Léo Lanteri Thauvin
e6d922b018
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
2021-08-25 15:48:57 +02:00
Léo Lanteri Thauvin
3375283763
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`
2021-08-25 15:48:55 +02:00
Léo Lanteri Thauvin
069330633e
Rollup merge of #88267 - sexxi-goose:truncate_unique, r=nikomatsakis
2229: Update signature for truncate function

r? `@nikomatsakis`
2021-08-25 15:48:54 +02:00
Léo Lanteri Thauvin
cc2a1271d4
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
2021-08-25 15:48:53 +02:00
Léo Lanteri Thauvin
b09c2547df
Rollup merge of #88223 - scottmcm:fix-alias, r=yaahc
Remove the `TryV2` alias

Post-bootstrap-update cleanup.

(No more `try_trait_transition` feature.)
2021-08-25 15:48:52 +02:00
Léo Lanteri Thauvin
f2cbbb93a2
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.
2021-08-25 15:48:51 +02:00
Léo Lanteri Thauvin
891fa3c555
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.
2021-08-25 15:48:50 +02:00
Léo Lanteri Thauvin
2512fb0a0b
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>
2021-08-25 15:48:49 +02:00
Léo Lanteri Thauvin
214d8e3cd4
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
2021-08-25 15:48:48 +02:00
Léo Lanteri Thauvin
ccefe27670
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();
```
2021-08-25 15:48:47 +02:00
Joshua Nelson
f858c7c300 Add mutable-noalias to the release notes for 1.54 2021-08-25 07:11:48 -05:00
bors
958d788a0b 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.
2021-08-25 10:58:43 +00:00
bors
9863bf51a5 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`
2021-08-25 08:12:16 +00:00
bors
1a9ac38def 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.
2021-08-25 05:31:26 +00:00
bors
e5484cec0e 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.
2021-08-25 02:17:41 +00:00
Santiago Pastorino
dbadab54df
Add type of a let tait test impl trait straight in let 2021-08-24 22:52:41 -03:00
Santiago Pastorino
08e20d9b28
Add type of a let tait test 2021-08-24 22:10:38 -03:00
bors
faa0a10406 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`
2021-08-24 23:30:44 +00:00
bors
b03ccace57 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)`
2021-08-24 20:49:55 +00:00
Mariano Casco
09e02a8919 Add SAFETY comments to core::slice::sort::partition_in_blocks 2021-08-24 16:47:26 -03:00
Frank Steffahn
90354c719a Make explanations of cross-references between make_mut and get_mut more accurate 2021-08-24 21:34:12 +02:00
Frank Steffahn
335bf7ca6b Clarifiy weak pointers being diassociated…
…noting the fact that `clone` is not called.

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2021-08-24 21:17:20 +02:00
Andreas Liljeqvist
f17e384a43 use convention for with_* methods 2021-08-24 19:41:58 +02:00
bors
0599f34033 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.
2021-08-24 17:41:24 +00:00
Ian Jackson
db13636f03 Stabilise BufWriter::into_parts
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 18:26:18 +01:00
Ian Jackson
7b5c0ecb3d Fix tidy
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 17:45:53 +01:00
est31
8f7007991e Fix grammar 2021-08-24 17:56:39 +02:00
Ian Jackson
4c0203eb4b 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>
2021-08-24 16:53:58 +01:00
Ian Jackson
54df693dd7 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>
2021-08-24 16:51:58 +01:00
inquisitivecrystal
1f3170cf16 Update tests
This updates tests to reflect that `force-warn` is now stable.
2021-08-24 11:39:22 -04:00
inquisitivecrystal
228a5f4096 Document force-warn
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2021-08-24 11:21:49 -04:00
inquisitivecrystal
aee2c30f69 Stabilize force-warn 2021-08-24 11:19:55 -04:00
inquisitivecrystal
d89b4a705c Tidy up lint command line flags 2021-08-24 11:19:55 -04:00
bors
b5fe3bc065 Auto merge of #87900 - jackh726:issue-87429, r=nikomatsakis
Use bound vars for GAT params in param_env in check_type_bounds

Fixes #87429
2021-08-24 14:55:48 +00:00
asquared31415
0b81c2eb82 Move named_asm_labels to a HIR lint 2021-08-24 08:23:58 -04:00
Andy Wang
7ed9f2e6aa
Ignore test on Windows 2021-08-24 13:21:27 +01:00
bors
47ab5f7ce2 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`
2021-08-24 12:13:37 +00:00
Tomasz Miąsko
9f6f8620e1 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.
2021-08-24 13:31:11 +02:00
Andreas Liljeqvist
e3f07b2e30 Force inline: small functions and single call-site 2021-08-24 10:18:07 +02:00
Patrick Amrein
8f65d154c8 allow specifying an ios version for the llvm target 2021-08-24 08:23:05 +02:00
bors
f66e825f73 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.
2021-08-24 03:58:22 +00:00
Eric Huss
2af3b20ad8 Update books 2021-08-23 19:42:31 -07:00
bors
5ca596f486 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:
fc81ad22c4/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()`:
fc81ad22c4/compiler/rustc_passes/src/liveness.rs (L981)
fc81ad22c4/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.
2021-08-24 01:36:09 +00:00
Frank Steffahn
6248dbcf70 Also fix “a OwningRef 2021-08-24 02:28:38 +02:00