]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRequire a box expression's type to be Sized
Anton Golov [Fri, 20 Aug 2021 14:25:52 +0000 (16:25 +0200)]
Require a box expression's type to be Sized

2 years agoChange example and tests for E0161.
Anton Golov [Fri, 20 Aug 2021 13:59:42 +0000 (15:59 +0200)]
Change example and tests for E0161.

The code will not emit this warning once box expressions require a sized
type (since that error is emitted earlier in the flow).

2 years agoAuto merge of #87329 - sunfishcode:sunfishcode/io-safety, r=joshtriplett
bors [Fri, 20 Aug 2021 11:00:55 +0000 (11:00 +0000)]
Auto merge of #87329 - sunfishcode:sunfishcode/io-safety, r=joshtriplett

I/O safety.

Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and
implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd`
for relevant types, along with Windows counterparts for handles and
sockets.

Tracking issue: <https://github.com/rust-lang/rust/issues/87074>

RFC: <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>

Highlights:
 - The doc comments at the top of library/std/src/os/unix/io/mod.rs and library/std/src/os/windows/io/mod.rs
 - The new types and traits in library/std/src/os/unix/io/fd.rs and library/std/src/os/windows/io/handle.rs
 - The removal of the `RawHandle` struct the Windows impl, which had the same name as the `RawHandle` type alias, and its functionality is now folded into `Handle`.

Managing five levels of wrapping (File wraps sys::fs::File wraps sys::fs::FileDesc wraps OwnedFd wraps RawFd, etc.) made for a fair amount of churn and verbose as/into/from sequences in some places. I've managed to simplify some of them, but I'm open to ideas here.

r? `@joshtriplett`

2 years agoAuto merge of #88000 - bjorn3:fix_cg_llvm_clif_compile, r=Mark-Simulacrum
bors [Fri, 20 Aug 2021 07:30:28 +0000 (07:30 +0000)]
Auto merge of #88000 - bjorn3:fix_cg_llvm_clif_compile, r=Mark-Simulacrum

Fix compiling other codegen backends when llvm is enabled

Extracted from #81746

Without this change rustbuild will not pass the required linker argument to find libllvm. While other backends likely don't use libllvm, it is necessary to be able to link against rustc_driver as the llvm backend is linked into it.

2 years agoAuto merge of #86898 - the8472:path-cmp, r=dtolnay
bors [Fri, 20 Aug 2021 05:00:45 +0000 (05:00 +0000)]
Auto merge of #86898 - the8472:path-cmp, r=dtolnay

Add fast path for Path::cmp that skips over long shared prefixes

```
# before
test path::tests::bench_path_cmp_fast_path_buf_sort               ... bench:      60,811 ns/iter (+/- 865)
test path::tests::bench_path_cmp_fast_path_long                   ... bench:       6,459 ns/iter (+/- 275)
test path::tests::bench_path_cmp_fast_path_short                  ... bench:       1,777 ns/iter (+/- 34)

# after
test path::tests::bench_path_cmp_fast_path_buf_sort               ... bench:      38,140 ns/iter (+/- 211)
test path::tests::bench_path_cmp_fast_path_long                   ... bench:       1,471 ns/iter (+/- 24)
test path::tests::bench_path_cmp_fast_path_short                  ... bench:       1,106 ns/iter (+/- 9)
```

2 years agoAuto merge of #88039 - sexxi-goose:fix-87987, r=nikomatsakis
bors [Fri, 20 Aug 2021 02:19:58 +0000 (02:19 +0000)]
Auto merge of #88039 - sexxi-goose:fix-87987, r=nikomatsakis

RFC2229 Only compute place if upvars can be resolved

Closes https://github.com/rust-lang/rust/issues/87987

This PR fixes an ICE when trying to unwrap an Err. This error appears when trying to convert a PlaceBuilder into Place when upvars can't yet be resolved. We should only try to convert a PlaceBuilder into Place if upvars can be resolved.

r? `@nikomatsakis`

2 years agoAuto merge of #87996 - sexxi-goose:fix-87988, r=nikomatsakis
bors [Thu, 19 Aug 2021 23:33:22 +0000 (23:33 +0000)]
Auto merge of #87996 - sexxi-goose:fix-87988, r=nikomatsakis

RFC2229 Add missing edge case

Closes https://github.com/rust-lang/rust/issues/87988

This PR fixes an ICE where a match discriminant is not being read when expected. This ICE was the result of a missing edge case which assumed that if a pattern is of type `PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Struct(..) | PatKind::Tuple(..)` then a place could only be a multi variant if the place is of type kind Adt.

2 years agoFix doc test failures on Windows.
Dan Gohman [Thu, 19 Aug 2021 23:15:29 +0000 (16:15 -0700)]
Fix doc test failures on Windows.

2 years agoAuto merge of #88165 - GuillaumeGomez:rollup-4o0v2ps, r=GuillaumeGomez
bors [Thu, 19 Aug 2021 20:31:05 +0000 (20:31 +0000)]
Auto merge of #88165 - GuillaumeGomez:rollup-4o0v2ps, r=GuillaumeGomez

Rollup of 8 pull requests

Successful merges:

 - #86123 (Preserve more spans in internal `rustc_queries!` macro)
 - #87874 (Add TcpStream type to TcpListener::incoming docs)
 - #88034 (rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible)
 - #88050 (Remove `HashStable` impls for `FileName` and `RealFileName`)
 - #88093 ([rustdoc] Wrap code blocks in `<code>` tag)
 - #88146 (Add tests for some `feature(const_evaluatable_checked)` incr comp issues)
 - #88153 (Update .mailmap)
 - #88159 (Use a trait instead of the now disallowed missing trait there)

Failed merges:

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

2 years agoFactor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI.
Dan Gohman [Thu, 19 Aug 2021 19:24:25 +0000 (12:24 -0700)]
Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI.

2 years agoFix syntax for non-doc comments, and use `crate::` instead of `std::`.
Dan Gohman [Thu, 19 Aug 2021 19:23:04 +0000 (12:23 -0700)]
Fix syntax for non-doc comments, and use `crate::` instead of `std::`.

2 years agoAdd I/O safety trait impls for process::Stdio and process::Child.
Dan Gohman [Tue, 17 Aug 2021 23:28:00 +0000 (16:28 -0700)]
Add I/O safety trait impls for process::Stdio and process::Child.

2 years agoUse the correct `into_*` on Windows to avoid dropping a stdio handle.
Dan Gohman [Fri, 13 Aug 2021 05:00:06 +0000 (22:00 -0700)]
Use the correct `into_*` on Windows to avoid dropping a stdio handle.

Use `into_raw_handle()` rather than `into_inner()` to completely consume a
`Handle` without dropping its contained handle.

2 years agoRemove the `#![feature(io_safety)]` from lib.rs.
Dan Gohman [Fri, 6 Aug 2021 13:11:22 +0000 (06:11 -0700)]
Remove the `#![feature(io_safety)]` from lib.rs.

2 years agoFix an unused import warning.
Dan Gohman [Wed, 4 Aug 2021 12:58:06 +0000 (07:58 -0500)]
Fix an unused import warning.

2 years agoUpdate PidFd for the new I/O safety APIs.
Dan Gohman [Tue, 3 Aug 2021 12:31:59 +0000 (07:31 -0500)]
Update PidFd for the new I/O safety APIs.

2 years agoRename OptionFileHandle to HandleOrInvalid and make it just wrap an Option<OwnedHandle>
Dan Gohman [Thu, 29 Jul 2021 20:36:44 +0000 (13:36 -0700)]
Rename OptionFileHandle to HandleOrInvalid and make it just wrap an Option<OwnedHandle>

The name (and updated documentation) make the FFI-only usage clearer, and wrapping Option<OwnedHandle> avoids the need to write a separate Drop or Debug impl.

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoDon't encourage migration until io_safety is stablized.
Dan Gohman [Wed, 28 Jul 2021 16:00:18 +0000 (09:00 -0700)]
Don't encourage migration until io_safety is stablized.

2 years agoFactor out Unix and WASI fd code into a common module.
Dan Gohman [Wed, 28 Jul 2021 14:28:58 +0000 (07:28 -0700)]
Factor out Unix and WASI fd code into a common module.

2 years agoSynchronize minor differences between Unix and WASI implementations.
Dan Gohman [Wed, 28 Jul 2021 14:02:51 +0000 (07:02 -0700)]
Synchronize minor differences between Unix and WASI implementations.

2 years agoAdd more comments about the `INVALID_HANDLE_VALUE` situation.
Dan Gohman [Wed, 28 Jul 2021 13:52:45 +0000 (06:52 -0700)]
Add more comments about the `INVALID_HANDLE_VALUE` situation.

2 years agoAdd comments about impls for File, TcpStream, ChildStdin, etc.
Dan Gohman [Wed, 28 Jul 2021 13:28:06 +0000 (06:28 -0700)]
Add comments about impls for File, TcpStream, ChildStdin, etc.

2 years agoFix copypasta of "Unix" within the WASI directory.
Dan Gohman [Wed, 28 Jul 2021 00:33:55 +0000 (17:33 -0700)]
Fix copypasta of "Unix" within the WASI directory.

2 years agoReword the description of dup2/dup3.
Dan Gohman [Wed, 28 Jul 2021 00:32:04 +0000 (17:32 -0700)]
Reword the description of dup2/dup3.

2 years agoAdd Safety comments to the `As*` for `Owned*` implementations.
Dan Gohman [Wed, 28 Jul 2021 00:15:40 +0000 (17:15 -0700)]
Add Safety comments to the `As*` for `Owned*` implementations.

2 years agoAdd Owned*, Borrowed*, and As* to the preludes.
Dan Gohman [Wed, 28 Jul 2021 00:12:40 +0000 (17:12 -0700)]
Add Owned*, Borrowed*, and As* to the preludes.

2 years agoRename `OwnedFd`'s private field to match it's debug output.
Dan Gohman [Wed, 28 Jul 2021 00:08:27 +0000 (17:08 -0700)]
Rename `OwnedFd`'s private field to match it's debug output.

2 years agoDelete a spurious empty comment line.
Dan Gohman [Wed, 28 Jul 2021 00:05:55 +0000 (17:05 -0700)]
Delete a spurious empty comment line.

2 years agoAdd a comment about how `OwnedHandle` should not be used with registry handles.
Dan Gohman [Wed, 28 Jul 2021 00:05:24 +0000 (17:05 -0700)]
Add a comment about how `OwnedHandle` should not be used with registry handles.

2 years agoAdd a comment about `OptionFileHandle`.
Dan Gohman [Tue, 27 Jul 2021 23:59:46 +0000 (16:59 -0700)]
Add a comment about `OptionFileHandle`.

2 years agoBe more precise about `mmap` and undefined behavior.
Dan Gohman [Tue, 27 Jul 2021 23:58:38 +0000 (16:58 -0700)]
Be more precise about `mmap` and undefined behavior.

`mmap` doesn't *always* cause undefined behavior; it depends on the
details of how you use it.

2 years agoAdd a test to ensure that RawFd is the size we assume it is.
Dan Gohman [Tue, 27 Jul 2021 23:57:38 +0000 (16:57 -0700)]
Add a test to ensure that RawFd is the size we assume it is.

2 years agoUpdate library/std/src/os/windows/io/socket.rs
Dan Gohman [Wed, 28 Jul 2021 00:23:13 +0000 (17:23 -0700)]
Update library/std/src/os/windows/io/socket.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoUpdate library/std/src/os/windows/io/handle.rs
Dan Gohman [Wed, 21 Jul 2021 17:49:16 +0000 (10:49 -0700)]
Update library/std/src/os/windows/io/handle.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoUpdate library/std/src/os/unix/io/fd.rs
Dan Gohman [Wed, 21 Jul 2021 17:06:26 +0000 (10:06 -0700)]
Update library/std/src/os/unix/io/fd.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoI/O safety.
Dan Gohman [Thu, 1 Jul 2021 04:44:30 +0000 (21:44 -0700)]
I/O safety.

Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and
implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd`
for relevant types, along with Windows counterparts for handles and
sockets.

Tracking issue:
 - <https://github.com/rust-lang/rust/issues/87074>

RFC:
 - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>

2 years agoRollup merge of #88159 - spastorino:fix-unused-generic-param-test, r=oli-obk
Guillaume Gomez [Thu, 19 Aug 2021 17:30:12 +0000 (19:30 +0200)]
Rollup merge of #88159 - spastorino:fix-unused-generic-param-test, r=oli-obk

Use a trait instead of the now disallowed missing trait there

To properly test the unused generic parameter and just that we need to use a trait in the tait. Missing the trait there is already tested and is not what we meant to test here.

r? `@oli-obk`

2 years agoRollup merge of #88153 - hkmatsumoto:mailmap, r=Mark-Simulacrum
Guillaume Gomez [Thu, 19 Aug 2021 17:30:11 +0000 (19:30 +0200)]
Rollup merge of #88153 - hkmatsumoto:mailmap, r=Mark-Simulacrum

Update .mailmap

2 years agoRollup merge of #88146 - BoxyUwU:tests-cec-incr-comp, r=oli-obk
Guillaume Gomez [Thu, 19 Aug 2021 17:30:10 +0000 (19:30 +0200)]
Rollup merge of #88146 - BoxyUwU:tests-cec-incr-comp, r=oli-obk

Add tests for some `feature(const_evaluatable_checked)` incr comp issues

Closes #77650
Closes #79251

#79251 didn't seem to be ICEing anymore so added regression tests for that aswell

r? `@oli-obk`

2 years agoRollup merge of #88093 - Kobzol:rustdoc-wrap-code-in-code-tag, r=GuillaumeGomez
Guillaume Gomez [Thu, 19 Aug 2021 17:30:09 +0000 (19:30 +0200)]
Rollup merge of #88093 - Kobzol:rustdoc-wrap-code-in-code-tag, r=GuillaumeGomez

[rustdoc] Wrap code blocks in <code> tag

This PR modifies Rustdoc output so that fenced code snippets, items and whole file source codes are wrapped in `<pre><code>` instead of just `<pre>`. This should improve the semantic meaning of the generated content.

I'm not sure what to do about `render_attributes_in_pre` and `render_attributes_in_code`. These functions were clearly expected to be used for things inside `<pre>` or `<code>`, and since I added `<code>` in this PR, some of them will be used in a different context than before. However, it seems to me that even before they were not consistent. For example, `item_constant` used `render_attributes_in_code` for its attributes, however there was no `<code>` used for constants before this PR...

Should I create some `rustdoc-gui` tests? For example to check that all `<pre>` tags have a `<code>` child?

Fixes: https://github.com/rust-lang/rust/issues/88020
2 years agoRollup merge of #88050 - Aaron1011:filename-hash-stable, r=michaelwoerister
Guillaume Gomez [Thu, 19 Aug 2021 17:30:07 +0000 (19:30 +0200)]
Rollup merge of #88050 - Aaron1011:filename-hash-stable, r=michaelwoerister

Remove `HashStable` impls for `FileName` and `RealFileName`

These impls were unused, and incorrectly hashed the local
(non-remapped) path for `RealFileName::Remapped` (which would
break reproducible builds if these impls were used).

2 years agoRollup merge of #88034 - petrochenkov:localevel2, r=wesleywiser
Guillaume Gomez [Thu, 19 Aug 2021 17:30:06 +0000 (19:30 +0200)]
Rollup merge of #88034 - petrochenkov:localevel2, r=wesleywiser

rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible

Follow up to https://github.com/rust-lang/rust/pull/87568

2 years agoRollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum
Guillaume Gomez [Thu, 19 Aug 2021 17:30:05 +0000 (19:30 +0200)]
Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum

Add TcpStream type to TcpListener::incoming docs

## Context

While going through the "The Rust Programming Language" book (Klabnik & Nichols), the TCP server example directs us to use TcpListener::incoming. I was curious how I could pass this value to a function (before reading ahead in the book), so I looked up the docs to determine the signature.

When I opened the docs, I found https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming, which didn't mention TcpStream anywhere in the example.

Eventually, I clicked on https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.accept in the docs (after clicking a few other locations first), and was able to surmise that the value contained TcpStream.

## Opportunity

While this type is mentioned several times in this doc, I feel that someone should be able to fully use the results of the TcpListner::incoming iterator based solely on the docs of just this method.

## Implementation

I took the code from the top-level TcpListener https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming and blended it with the existing docs for TcpListener::incoming https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming.

It does make the example a little longer, and it also introduces a little duplication. It also gives the reader the type signatures they need to move on to the next step.

## Additional considerations

I noticed that in this doc, `handle_connection` and `handle_client` are both used to accept a TcpStream in the docs on this page. I want to standardize on one function name convention, so readers don't accidentally think two different concepts are being referenced. I didn't want to cram do too much in one PR, I can update this PR to make that change, or I could send another PR (if you would like).

First attempted contribution to Rust (and I'm also still very new, hence reading through the rust book for the first time)! Would you please let me know what you think?

2 years agoRollup merge of #86123 - Aaron1011:query-span, r=cjgillot
Guillaume Gomez [Thu, 19 Aug 2021 17:30:04 +0000 (19:30 +0200)]
Rollup merge of #86123 - Aaron1011:query-span, r=cjgillot

Preserve more spans in internal `rustc_queries!` macro

We now preserve the span of the various query modifiers, and
use the span of the query's name for the commas that we
generate to separate the modifiers. This makes debugging issues with the
internal query macro infrastructure much nicer - previously, we
would get errors messages pointing at the entire call site
(the `rustc_queries!` invocation), which isn't very useful.

This should have no effect when compilation succeeds.

A concrete example of an error message produced after this changed:

```
error: local ambiguity: multiple parsing options: built-in NTs tt ('modifiers') or 1 other option.
    --> /home/aaron/repos/rust/compiler/rustc_middle/src/query/mod.rs:23:11
     |
12   | / rustc_queries! {
13   | |     query trigger_delay_span_bug(key: DefId) -> () {
14   | |         desc { "trigger a delay span bug" }
15   | |     }
...    |
23   | |     query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
     | |           ^^^^^^^^^
...    |
1715 | |     }
1716 | | }
     | |_- in this expansion of `rustc_query_append!`
     |
    ::: compiler/rustc_query_impl/src/lib.rs:51:1
     |
51   |   rustc_query_append! { [define_queries!][<'tcx>] }
     |   ------------------------------------------------- in this macro invocation
```

The particular bug shown in this error message will be fixed
in a separate PR.

2 years agoAuto merge of #88151 - alexcrichton:update-backtrace, r=Mark-Simulacrum
bors [Thu, 19 Aug 2021 17:20:59 +0000 (17:20 +0000)]
Auto merge of #88151 - alexcrichton:update-backtrace, r=Mark-Simulacrum

Update the backtrace crate in libstd

This commit updates the backtrace crate in libstd now that dependencies
have been updated to use `memchr` from the standard library as well.
This is mostly just making sure deps are up-to-date and have all the
latest-and-greatest fixes and such.

Closes rust-lang/backtrace-rs#432

2 years agoAuto merge of #88124 - tmiasko:start-block-critical-edge, r=oli-obk
bors [Thu, 19 Aug 2021 14:35:16 +0000 (14:35 +0000)]
Auto merge of #88124 - tmiasko:start-block-critical-edge, r=oli-obk

Split critical edge targeting the start block

Fixes #88043.

2 years agoUpdate the backtrace crate in libstd
Alex Crichton [Thu, 19 Aug 2021 02:44:24 +0000 (19:44 -0700)]
Update the backtrace crate in libstd

This commit updates the backtrace crate in libstd now that dependencies
have been updated to use `memchr` from the standard library as well.
This is mostly just making sure deps are up-to-date and have all the
latest-and-greatest fixes and such.

Closes rust-lang/backtrace-rs#432

2 years agoUse a trait instead of the now disallowed missing trait there
Santiago Pastorino [Thu, 19 Aug 2021 13:48:20 +0000 (10:48 -0300)]
Use a trait instead of the now disallowed missing trait there

2 years agoAuto merge of #88023 - devnexen:fbsd_arm64, r=nagisa
bors [Thu, 19 Aug 2021 11:54:27 +0000 (11:54 +0000)]
Auto merge of #88023 - devnexen:fbsd_arm64, r=nagisa

freebsd arm64 add supported sanitizers.

2 years agoUpdate .mailmap
Hirochika Matsumoto [Thu, 19 Aug 2021 09:44:43 +0000 (18:44 +0900)]
Update .mailmap

2 years agoAuto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay
bors [Thu, 19 Aug 2021 09:08:11 +0000 (09:08 +0000)]
Auto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay

Unbox mutexes, condvars and rwlocks on hermit

[RustyHermit](https://github.com/hermitcore/rusty-hermit) provides now movable synchronization primitives and we are able to unbox mutexes and condvars.

2 years ago[rustdoc] Wrap code blocks in <code> tag
Jakub Beránek [Mon, 16 Aug 2021 21:19:00 +0000 (23:19 +0200)]
[rustdoc] Wrap code blocks in <code> tag

2 years agoAuto merge of #87986 - Aaron1011:incr-double-panic, r=estebank
bors [Thu, 19 Aug 2021 06:27:17 +0000 (06:27 +0000)]
Auto merge of #87986 - Aaron1011:incr-double-panic, r=estebank

Prevent double panic when handling incremental fingerprint mismatch

When an incremental fingerprint mismatch occurs, we debug-print
our `DepNode` and query result. Unfortunately, the debug printing
process may cause us to run additional queries, which can result
in a re-entrant fingerprint mismatch error.

To avoid a double panic, this commit adds a thread-local variable
to detect re-entrant calls.

2 years agoAuto merge of #88143 - GuillaumeGomez:rollup-sgh318f, r=GuillaumeGomez
bors [Thu, 19 Aug 2021 03:45:50 +0000 (03:45 +0000)]
Auto merge of #88143 - GuillaumeGomez:rollup-sgh318f, r=GuillaumeGomez

Rollup of 10 pull requests

Successful merges:

 - #87818 (Fix anchors display in rustdoc)
 - #87983 (Use more accurate spans when proposing adding lifetime to item)
 - #88012 (Change WASI's `RawFd` from `u32` to `c_int` (`i32`).)
 - #88031 (Make `BuildHasher` object safe)
 - #88036 (Fix dead code warning when inline const is used in pattern)
 - #88082 (Take into account jobs number for rustdoc GUI tests)
 - #88109 (Fix environment variable getter docs)
 - #88111 (Add background-color on clickable definitions in source code)
 - #88129 (Fix dataflow graphviz bug, make dataflow graphviz modules public)
 - #88136 (Move private_unused.rs test to impl-trait)

Failed merges:

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

2 years agoAuto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid
bors [Thu, 19 Aug 2021 01:05:03 +0000 (01:05 +0000)]
Auto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid

Fix anchors display in rustdoc

Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background).

![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png)
![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png)
![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png)

r? `@camelid`

2 years agorustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible
Vadim Petrochenkov [Sat, 14 Aug 2021 17:51:49 +0000 (20:51 +0300)]
rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible

2 years agoadd tests
Ellen [Wed, 18 Aug 2021 20:15:33 +0000 (21:15 +0100)]
add tests

2 years agoRollup merge of #88136 - spastorino:fix-test-directory, r=oli-obk
Guillaume Gomez [Wed, 18 Aug 2021 17:55:06 +0000 (19:55 +0200)]
Rollup merge of #88136 - spastorino:fix-test-directory, r=oli-obk

Move private_unused.rs test to impl-trait

This test was added to fix this issue #55124 which is about impl traits but not related with type alias impl traits.

r? `@oli-obk`

`@bors` rollup=always

2 years agoRollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morse
Guillaume Gomez [Wed, 18 Aug 2021 17:55:04 +0000 (19:55 +0200)]
Rollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morse

Fix dataflow graphviz bug, make dataflow graphviz modules public

I'm working on a rustc plugin that uses the dataflow framework for MIR analysis. I've found the graphviz utilities extremely helpful for debugging. However, I had to fork the compiler to expose them since they're currently private. I would appreciate if they could be made public so I can build against a nightly instead of a custom fork. Specifically, this PR:

* Makes public the `rustc_mir::dataflow::framework::graphviz` module.
* Makes public the `rustc_mir::util::pretty::write_mir_fn` function.

Here's a concrete example of how I'm using the graphviz module: https://github.com/willcrichton/flowistry/blob/97b843b8b06b4004fbb79b5fcfca3e33c7143bc0/src/slicing/mod.rs#L186-L203

Additionally, this PR fixes a small bug in the diff code that incorrectly shows the updated object as the old object.

r? `@ecstatic-morse`

2 years agoRollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhpratt
Guillaume Gomez [Wed, 18 Aug 2021 17:55:03 +0000 (19:55 +0200)]
Rollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhpratt

Add background-color on clickable definitions in source code

Someone suggested to add a decoration on clickable elements in the source code pages:

![Screenshot from 2021-08-17 14-49-39](https://user-images.githubusercontent.com/3050060/129728911-def74f9e-50e2-40d2-b512-e23f1b3d0409.png)
![Screenshot from 2021-08-17 14-49-47](https://user-images.githubusercontent.com/3050060/129728925-14aec500-82ff-4336-955a-4173c769deeb.png)
![Screenshot from 2021-08-17 14-49-52](https://user-images.githubusercontent.com/3050060/129728927-a8a89d7a-e837-4ff5-b094-35be23629d14.png)

The idea is to not disturb the reading while telling the reader "you can click on this one", which is why it's not a text decoration.

What do you think `@rust-lang/rustdoc` ?

r? `@Nemo157`

2 years agoRollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se
Guillaume Gomez [Wed, 18 Aug 2021 17:55:02 +0000 (19:55 +0200)]
Rollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se

Fix environment variable getter docs

`@RalfJung` pointed out a number of errors and suboptimal choices I made in my documentation for #86183. This PR should (hopefully) fix the problems they've identified.

2 years agoRollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8
Guillaume Gomez [Wed, 18 Aug 2021 17:55:00 +0000 (19:55 +0200)]
Rollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8

Take into account jobs number for rustdoc GUI tests

Fixes #88054.

r? `@Mark-Simulacrum`

2 years agoRollup merge of #88036 - nbdd0121:const3, r=petrochenkov
Guillaume Gomez [Wed, 18 Aug 2021 17:54:59 +0000 (19:54 +0200)]
Rollup merge of #88036 - nbdd0121:const3, r=petrochenkov

Fix dead code warning when inline const is used in pattern

Fixes #78171

2 years agoRollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se
Guillaume Gomez [Wed, 18 Aug 2021 17:54:57 +0000 (19:54 +0200)]
Rollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se

Make `BuildHasher` object safe

Resolves #87991

2 years agoRollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton
Guillaume Gomez [Wed, 18 Aug 2021 17:54:56 +0000 (19:54 +0200)]
Rollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton

Change WASI's `RawFd` from `u32` to `c_int` (`i32`).

WASI previously used `u32` as its `RawFd` type, since its "file descriptors"
are unsigned table indices, and there's no fundamental reason why WASI can't
have more than 2^31 handles.

However, this creates myriad little incompability problems with code
that also supports Unix platforms, where `RawFd` is `c_int`. While WASI
isn't a Unix, it often shares code with Unix, and this difference made
such shared code inconvenient. #87329 is the most recent example of such
code.

So, switch WASI to use `c_int`, which is `i32`. This will mean that code
intending to support WASI should ideally avoid assuming that negative file
descriptors are invalid, even though POSIX itself says that file descriptors
are never negative.

This is a breaking change, but `RawFd` is considerd an experimental
feature in [the documentation].

[the documentation]: https://doc.rust-lang.org/stable/std/os/wasi/io/type.RawFd.html

r? `@alexcrichton`

2 years agoRollup merge of #87983 - estebank:smaller-lt-spans, r=oli-obk
Guillaume Gomez [Wed, 18 Aug 2021 17:54:55 +0000 (19:54 +0200)]
Rollup merge of #87983 - estebank:smaller-lt-spans, r=oli-obk

Use more accurate spans when proposing adding lifetime to item

2 years agoRollup merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid
Guillaume Gomez [Wed, 18 Aug 2021 17:54:54 +0000 (19:54 +0200)]
Rollup merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid

Fix anchors display in rustdoc

Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background).

![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png)
![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png)
![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png)

r? `@camelid`

2 years agoAuto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis
bors [Wed, 18 Aug 2021 15:54:59 +0000 (15:54 +0000)]
Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis

Matthew's work on improving NLL's "higher-ranked subtype error"s

This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374.

These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code.

The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode.

I've only updated the branch and made it compile, removed a warning or two.

r? `@nikomatsakis`

(Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)

2 years agoreview comment: use newtype to deduplicate logic
Esteban Kuber [Wed, 18 Aug 2021 12:00:07 +0000 (12:00 +0000)]
review comment: use newtype to deduplicate logic

2 years agoAuto merge of #88127 - ehuss:update-cargo, r=ehuss
bors [Wed, 18 Aug 2021 13:24:17 +0000 (13:24 +0000)]
Auto merge of #88127 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in b51439fd8b505d4800a257acfecf3c69f81e35cf..e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc
2021-08-09 18:40:05 +0000 to 2021-08-17 22:58:47 +0000
- Support using rustbot to ping the Windows group (rust-lang/cargo#9802)
- Show information about abnormal `fix` errors. (rust-lang/cargo#9799)
- Bump jobserver. (rust-lang/cargo#9798)
- Render build-std web links as hyperlinks (rust-lang/cargo#9795)
- Teach cargo to failfast on recursive/corecursive aliases (rust-lang/cargo#9791)
- Fix value-after-table error with profiles. (rust-lang/cargo#9789)
- Fix plugin registrar change. (rust-lang/cargo#9790)
- Ability to specify the output name for a bin target different from the crate name (rust-lang/cargo#9627)

2 years agoMove private_unused.rs test to impl-trait
Santiago Pastorino [Wed, 18 Aug 2021 12:11:43 +0000 (09:11 -0300)]
Move private_unused.rs test to impl-trait

2 years agoreview comment: reduce duplication
Esteban Kuber [Wed, 18 Aug 2021 11:14:33 +0000 (11:14 +0000)]
review comment: reduce duplication

2 years agoFix anchors display in rustdoc
Guillaume Gomez [Fri, 6 Aug 2021 14:47:35 +0000 (16:47 +0200)]
Fix anchors display in rustdoc

2 years agoAuto merge of #87781 - est31:remove_box, r=oli-obk
bors [Wed, 18 Aug 2021 10:43:27 +0000 (10:43 +0000)]
Auto merge of #87781 - est31:remove_box, r=oli-obk

Remove box syntax from compiler and tools

Removes box syntax from the compiler and tools. In #49733, the future of box syntax is uncertain and the use in the compiler was listed as one of the reasons to keep it. Removal of box syntax [might affect the code generated](https://github.com/rust-lang/rust/pull/49646#issuecomment-379219615) and slow down the compiler so I'd recommend doing a perf run on this.

2 years agoUse more accurate spans when proposing adding lifetime to item
Esteban Kuber [Thu, 12 Aug 2021 18:54:29 +0000 (18:54 +0000)]
Use more accurate spans when proposing adding lifetime to item

2 years agoAuto merge of #87985 - nbdd0121:asm, r=Amanieu
bors [Wed, 18 Aug 2021 08:14:16 +0000 (08:14 +0000)]
Auto merge of #87985 - nbdd0121:asm, r=Amanieu

Forbid `!` from being used in `asm!` output

Fixes #87802

r? `@Amanieu`

2 years agoadd fixme about the `type_op_normalize` query in NLL HRTB diagnostics
Rémy Rakic [Wed, 18 Aug 2021 07:49:32 +0000 (09:49 +0200)]
add fixme about the `type_op_normalize` query in NLL HRTB diagnostics

2 years agoremove box_syntax uses from cranelift and tools
Marcel Hellwig [Fri, 6 Aug 2021 15:14:27 +0000 (17:14 +0200)]
remove box_syntax uses from cranelift and tools

2 years agoRemove box syntax from rustc_lint
est31 [Thu, 5 Aug 2021 03:39:52 +0000 (05:39 +0200)]
Remove box syntax from rustc_lint

2 years agoRemove box syntax from rustc_mir
est31 [Thu, 5 Aug 2021 03:36:38 +0000 (05:36 +0200)]
Remove box syntax from rustc_mir

2 years agoRemove box syntax from rustc_middle
est31 [Thu, 5 Aug 2021 03:14:53 +0000 (05:14 +0200)]
Remove box syntax from rustc_middle

2 years agoRemove box syntax from rustc_parse
est31 [Thu, 5 Aug 2021 02:58:59 +0000 (04:58 +0200)]
Remove box syntax from rustc_parse

2 years agoRemove box syntax from rustc_serialize
est31 [Thu, 5 Aug 2021 02:53:51 +0000 (04:53 +0200)]
Remove box syntax from rustc_serialize

2 years agoRemove box syntax from rustc_typeck
est31 [Thu, 5 Aug 2021 02:50:39 +0000 (04:50 +0200)]
Remove box syntax from rustc_typeck

2 years agoRemove box syntax from rustc_infer
est31 [Thu, 5 Aug 2021 02:43:06 +0000 (04:43 +0200)]
Remove box syntax from rustc_infer

2 years agoRemove box syntax from rustc_builtin_macros
est31 [Thu, 5 Aug 2021 01:53:21 +0000 (03:53 +0200)]
Remove box syntax from rustc_builtin_macros

2 years agoRemove box syntax from rustc_ast
est31 [Thu, 5 Aug 2021 01:48:54 +0000 (03:48 +0200)]
Remove box syntax from rustc_ast

2 years agoRemove box syntax from rustc_mir_build
est31 [Thu, 5 Aug 2021 01:16:19 +0000 (03:16 +0200)]
Remove box syntax from rustc_mir_build

2 years agoAuto merge of #87738 - lqd:polonius-master, r=nikomatsakis
bors [Wed, 18 Aug 2021 05:50:55 +0000 (05:50 +0000)]
Auto merge of #87738 - lqd:polonius-master, r=nikomatsakis

Update `polonius-engine` to 0.13.0

This PR updates the use of `polonius-engine` to the recently released 0.13.0:
- this version renamed a lot of relations to match the current terminology
- "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again
- some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc.

In particular:
- a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs
- others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name
- a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius
- some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical.
- in a few cases Polonius gets a chance to emit more errors than NLLs

A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60):
- `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation
- `src/test/ui/numbers-arithmetic/num-wrapping.rs`
- `src/test/ui/issues/issue-72933-match-stack-overflow.rs`
- `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs`
- `src/test/ui/repr/repr-no-niche.rs`

In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors:
- `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static
- `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error

We'll keep talking about this at the next sprint as well.

cc `@rust-lang/wg-polonius` r? `@nikomatsakis`

2 years agoFix bug in fmt_diff_with
Will Crichton [Wed, 18 Aug 2021 03:55:15 +0000 (20:55 -0700)]
Fix bug in fmt_diff_with

2 years agoAuto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514
bors [Wed, 18 Aug 2021 03:21:12 +0000 (03:21 +0000)]
Auto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514

Add "doc(test(...))" attribute checks

Fixes #82672.

r? `@camelid`

2 years agoAuto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut
bors [Wed, 18 Aug 2021 01:00:17 +0000 (01:00 +0000)]
Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut

Stabilize `arbitrary_enum_discriminant`

Closes #60553.

----

## Stabilization Report

_copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_

### Summary

Enables a user to specify *explicit* discriminants on arbitrary enums.

Previously, this was hard to achieve:

```rust
#[repr(u8)]
enum Foo {
    A(u8) = 0,
    B(i8) = 1,
    C(bool) = 42,
}
```

Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants.

In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums.

### Test cases

Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete).

### Edge cases

The feature is well defined and does not have many edge cases.
One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved.

### Previous PRs

The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639.

### Resolution of unresolved questions

The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271.

----

(someone please add `needs-fcp`)

2 years agoUpdate cargo
Eric Huss [Wed, 18 Aug 2021 00:38:07 +0000 (17:38 -0700)]
Update cargo

2 years agoExpose graphviz modules
Will Crichton [Tue, 17 Aug 2021 23:12:11 +0000 (16:12 -0700)]
Expose graphviz modules

2 years agoAuto merge of #86808 - fee1-dead:constify-1, r=oli-obk
bors [Tue, 17 Aug 2021 22:30:09 +0000 (22:30 +0000)]
Auto merge of #86808 - fee1-dead:constify-1, r=oli-obk

constified implementations of `Default`

2 years agoAuto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakis
bors [Tue, 17 Aug 2021 19:08:31 +0000 (19:08 +0000)]
Auto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakis

Enable compiler consumers to obtain mir::Body with Polonius facts.

This PR adds a function (``get_body_with_borrowck_facts``) that can be used by compiler consumers to obtain ``mir::Body`` with accompanying borrow checker information.

The most important borrow checker information that [our verifier called Prusti](https://github.com/viperproject/prusti-dev) needs is lifetime constraints. I have not found a reasonable way to compute the lifetime constraints on the Prusti side. In the compiler, the constraints are computed during the borrow checking phase and then dropped. This PR adds an additional parameter to the `do_mir_borrowck` function that tells it to return the computed information instead of dropping it.

The additionally returned information by `do_mir_borrowck` contains a ``mir::Body`` with non-erased lifetime regions and Polonius facts. I have decided to reuse the Polonius facts because this way I needed fewer changes to the compiler and Polonius facts contains other useful information that we otherwise would need to recompute.

Just FYI: up to now, Prusti was obtaining this information by [parsing the compiler logs](https://github.com/viperproject/prusti-dev/blob/b58ced8dfd14ef30582b503d517167ccd771eaff/prusti-interface/src/environment/borrowck/regions.rs#L25-L39). This is not only a hacky approach, but we also reached its limits.

r? `@nikomatsakis`

2 years agoAuto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank
bors [Tue, 17 Aug 2021 16:43:40 +0000 (16:43 +0000)]
Auto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank

Improve non_fmt_panics suggestion based on trait impls.

This improves the non_fmt_panics lint suggestions by checking first which trait (Display or Debug) are actually implemented on the type.

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

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

Before:

```
help: add a "{}" format string to Display the message
  |
2 |     panic!("{}", Some(1));
  |            +++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

After:

```
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
  |
2 |     panic!("{:?}", Some(1));
  |            +++++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

r? `@estebank`

2 years agoAdd background-color on clickable definitions in source code
Guillaume Gomez [Tue, 17 Aug 2021 12:50:21 +0000 (14:50 +0200)]
Add background-color on clickable definitions in source code

2 years agoAuto merge of #88056 - erikdesjardins:revertzst, r=oli-obk
bors [Tue, 17 Aug 2021 14:02:55 +0000 (14:02 +0000)]
Auto merge of #88056 - erikdesjardins:revertzst, r=oli-obk

Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"

This reverts commit 8007b506ac5da629f223b755f5a5391edd5f6d01, reversing changes made to e55c13e1099b78b1a485202fabc9c1b10b1f1d15.

Fixes #88043

r? `@oli-obk`

2 years agoFix obtain-borrowck failure on Windows.
Vytautas Astrauskas [Tue, 17 Aug 2021 11:06:27 +0000 (13:06 +0200)]
Fix obtain-borrowck failure on Windows.