]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #88149 - Mark-Simulacrum:prep-never-type, r=jackh726
bors [Sat, 21 Aug 2021 01:29:12 +0000 (01:29 +0000)]
Auto merge of #88149 - Mark-Simulacrum:prep-never-type, r=jackh726

Refactor fallback code to prepare for never type

This PR contains cherry-picks of some of `@nikomatsakis's` work from #79366, and shouldn't (AFAICT) represent any change in behavior. However, the refactoring is good regardless of the never type work being landed, and will reduce the size of those eventual PR(s) (and rebase pain).

I am not personally an expert on this code, and the commits are essentially 100% `@nikomatsakis's,` but they do seem reasonable to me by my understanding. Happy to edit with review, of course. Commits are best reviewed in sequence rather than all together.

r? `@jackh726` perhaps?

2 years agoAuto merge of #88087 - jesyspa:issue-87935-box, r=jackh726
bors [Fri, 20 Aug 2021 23:04:57 +0000 (23:04 +0000)]
Auto merge of #88087 - jesyspa:issue-87935-box, r=jackh726

Check that a box expression's type is Sized

This resolves [issue 87935](https://github.com/rust-lang/rust/issues/87935).

This makes E0161 (move from an unsized rvalue) much less common.  I've replaced the test to use [this case](https://github.com/rust-lang/rust/blob/master/src/test/ui/object-safety/object-safety-by-value-self-use.rs), when a boxed `dyn` trait is passed by value, but that isn't an error when `unsized_locals` is enabled.  I think it may be possible to get rid of E0161 entirely by checking that case earlier, but I'm not sure if that's desirable?

2 years agomove `fallback_if_possible` and friends to fallback.rs
Niko Matsakis [Sun, 22 Nov 2020 11:10:50 +0000 (06:10 -0500)]
move `fallback_if_possible` and friends to fallback.rs

Along the way, simplify and document the logic more clearly.

2 years agocreate `Coercion` obligations given 2 unbound type variables
Niko Matsakis [Sat, 21 Nov 2020 20:47:14 +0000 (15:47 -0500)]
create `Coercion` obligations given 2 unbound type variables

Motivation: in upcoming commits, we are going to create a graph of the
coercion relationships between variables. We want to
distinguish *coercion* specifically from other sorts of subtyping, as
it indicates values flowing from one place to another via assignment.

2 years agomove the `sub-unify` check and extend the documentation a bit
Niko Matsakis [Sat, 21 Nov 2020 20:33:36 +0000 (15:33 -0500)]
move the `sub-unify` check and extend the documentation a bit

I didn't like the sub-unify code executing when a predicate was
ENQUEUED, that felt fragile. I would have preferred to move the
sub-unify code so that it only occurred during generalization, but
that impacted diagnostics, so having it also occur when we process
subtype predicates felt pretty reasonable. (I guess we only need one
or the other, but I kind of prefer both, since the generalizer
ultimately feels like the *right* place to guarantee the properties we
want.)

2 years agoAuto merge of #83093 - the8472:smaller-instant-hammer, r=Amanieu
bors [Fri, 20 Aug 2021 19:06:46 +0000 (19:06 +0000)]
Auto merge of #83093 - the8472:smaller-instant-hammer, r=Amanieu

where available use AtomicU{64,128} instead of mutex for Instant backsliding protection

This decreases the overhead of backsliding protection on x86 systems with unreliable TSC, e.g. windows. And on aarch64 systems where 128bit atomics are available.

The following benchmarks were taken on x86_64 linux though by overriding `actually_monotonic()`, the numbers may look different on other platforms

```
# actually_monotonic() == true
test time::tests::instant_contention_01_threads                   ... bench:          44 ns/iter (+/- 0)
test time::tests::instant_contention_02_threads                   ... bench:          44 ns/iter (+/- 0)
test time::tests::instant_contention_04_threads                   ... bench:          44 ns/iter (+/- 0)
test time::tests::instant_contention_08_threads                   ... bench:          44 ns/iter (+/- 0)
test time::tests::instant_contention_16_threads                   ... bench:          44 ns/iter (+/- 0)

# 1x AtomicU64
test time::tests::instant_contention_01_threads                   ... bench:          65 ns/iter (+/- 0)
test time::tests::instant_contention_02_threads                   ... bench:         157 ns/iter (+/- 20)
test time::tests::instant_contention_04_threads                   ... bench:         281 ns/iter (+/- 53)
test time::tests::instant_contention_08_threads                   ... bench:         555 ns/iter (+/- 77)
test time::tests::instant_contention_16_threads                   ... bench:         883 ns/iter (+/- 107)

# mutex
test time::tests::instant_contention_01_threads                   ... bench:          60 ns/iter (+/- 2)
test time::tests::instant_contention_02_threads                   ... bench:         770 ns/iter (+/- 231)
test time::tests::instant_contention_04_threads                   ... bench:       1,347 ns/iter (+/- 45)
test time::tests::instant_contention_08_threads                   ... bench:       2,693 ns/iter (+/- 114)
test time::tests::instant_contention_16_threads                   ... bench:       5,244 ns/iter (+/- 487)
```

Since I don't have an arm machine with 128bit atomics I wasn't able to benchmark the AtomicU128 implementation.

2 years agofix tests on wasm targets that have 32bit time_t and don't have threads
The8472 [Wed, 18 Aug 2021 20:44:10 +0000 (22:44 +0200)]
fix tests on wasm targets that have 32bit time_t and don't have threads

2 years agoAuto merge of #88176 - erikdesjardins:rezst, r=oli-obk
bors [Fri, 20 Aug 2021 16:25:34 +0000 (16:25 +0000)]
Auto merge of #88176 - erikdesjardins:rezst, r=oli-obk

Reenable RemoveZsts

Now that the underlying issue has been fixed by #88124, we can reland #83417.

r? `@oli-obk`

2 years agoUpdate old box expression tests and add a new one.
Anton Golov [Fri, 20 Aug 2021 14:26:24 +0000 (16:26 +0200)]
Update old box expression tests and add a new one.

New tests also check that we're not triggering this error
over-zealously.

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 #87686 - matthiaskrgr:clippy_august_21_perf, r=jackh726
bors [Fri, 20 Aug 2021 13:41:42 +0000 (13:41 +0000)]
Auto merge of #87686 - matthiaskrgr:clippy_august_21_perf, r=jackh726

clippy::perf fixes

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 agoRevert "Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk""
Erik Desjardins [Fri, 20 Aug 2021 02:28:32 +0000 (22:28 -0400)]
Revert "Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk""

This reverts commit 8e11199a153218c13a419df37a9bb675181cccb7.

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 agointroduce a Coerce predicate
Niko Matsakis [Sat, 21 Nov 2020 12:06:16 +0000 (07:06 -0500)]
introduce a Coerce predicate

2 years agocleanup: extract a helper for coercion from inference variables
Niko Matsakis [Sat, 21 Nov 2020 10:45:13 +0000 (05:45 -0500)]
cleanup: extract a helper for coercion from inference variables

2 years agoshallow resolve target type in coercion
Niko Matsakis [Fri, 20 Nov 2020 10:52:27 +0000 (05:52 -0500)]
shallow resolve target type in coercion

We used to avoid doing this because we didn't want to make coercion depend on
the state of inference. For better or worse, we have moved away from this
position over time. Therefore, I am going to go ahead and resolve the `b`
target type early on so that it is done uniformly.

(The older technique for managing this was always something of a hack
regardless; if we really wanted to avoid integrating coercion and inference we
needed to be more disciplined about it.)

2 years agointroduce a `Diverging` enum instead of a bool
Niko Matsakis [Fri, 20 Nov 2020 10:40:33 +0000 (05:40 -0500)]
introduce a `Diverging` enum instead of a bool

2 years agofactor fallback code into its own module
Niko Matsakis [Thu, 19 Nov 2020 23:24:03 +0000 (18:24 -0500)]
factor fallback code into its own module

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