Commit graph

153647 commits

Author SHA1 Message Date
Santiago Pastorino
eb16ae723d
Use of impl trait in an impl as the valoe for an associated type in a dyn 2021-08-20 17:33:21 -03:00
Santiago Pastorino
cfcc8517cb
Add TAIT struct test 2021-08-20 16:26:13 -03:00
bors
a0035916e0 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.
2021-08-20 19:06:46 +00:00
The8472
cd82b4246e fix tests on wasm targets that have 32bit time_t and don't have threads 2021-08-20 20:34:23 +02:00
bors
914a1e2c51 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`
2021-08-20 16:25:34 +00:00
Anton Golov
c75a93023a Update old box expression tests and add a new one.
New tests also check that we're not triggering this error
over-zealously.
2021-08-20 16:26:24 +02:00
Anton Golov
b8fff95961 Require a box expression's type to be Sized 2021-08-20 16:25:52 +02:00
Santiago Pastorino
593fd7c6b1
test TAIT in different positions 2021-08-20 11:15:48 -03:00
Anton Golov
ba83b39d4e 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).
2021-08-20 15:59:42 +02:00
bors
d77dcbc599 Auto merge of #87686 - matthiaskrgr:clippy_august_21_perf, r=jackh726
clippy::perf fixes
2021-08-20 13:41:42 +00:00
Santiago Pastorino
49a31a2b3e
We meant to use a trait instead of lifetime here 2021-08-20 10:36:24 -03:00
bors
521734787e 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`
2021-08-20 11:00:55 +00:00
Mukund Lakshman
f19ba35bce Add support for including non-backport commits. 2021-08-20 11:58:20 +01:00
Mukund Lakshman
adc8cd3e62 Add cherry-pick.sh convenience script. 2021-08-20 11:58:18 +01:00
Frank Steffahn
30f7b8915b Mailmap entry for myself 2021-08-20 12:11:45 +02:00
bors
9ccf661694 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.
2021-08-20 07:30:28 +00:00
bors
bcfd3f7e88 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)
```
2021-08-20 05:00:45 +00:00
Erik Desjardins
6ea536d99b Revert "Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk""
This reverts commit 8e11199a15.
2021-08-19 22:28:32 -04:00
bors
7611fe438d 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`
2021-08-20 02:19:58 +00:00
bors
ebedfedcd8 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.
2021-08-19 23:33:22 +00:00
Noah Lev
ba9093e827
Clarify some wording in Rust 2021 lint docs 2021-08-19 16:18:11 -07:00
Dan Gohman
b4dfa198bf Fix doc test failures on Windows. 2021-08-19 16:15:29 -07:00
Mukund Lakshman
700b64e100 CI: Verify commits in beta & stable are in upstream branches.
Closes #74721
2021-08-19 22:49:52 +01:00
Santiago Pastorino
2644a159c7
Test that type alias impl trait happens in a submodule 2021-08-19 18:44:53 -03:00
Niko Matsakis
947c0de028 introduce a Coerce predicate 2021-08-19 17:28:24 -04:00
Niko Matsakis
5a8edc0b76 cleanup: extract a helper for coercion from inference variables 2021-08-19 17:28:24 -04:00
Niko Matsakis
5eca626e40 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.)
2021-08-19 17:28:24 -04:00
Niko Matsakis
7e0ae7d89b introduce a Diverging enum instead of a bool 2021-08-19 17:28:24 -04:00
Niko Matsakis
c1b4824800 factor fallback code into its own module 2021-08-19 17:28:24 -04:00
Joe Ardent
52a988344b Update release note for 1.55.0.
Added a line about new formatting option, `{lib}`, for `cargo
tree` (https://github.com/rust-lang/cargo/pull/9663).
2021-08-19 13:54:26 -07:00
bors
6d64f7f695 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
2021-08-19 20:31:05 +00:00
Dan Gohman
e555003e6d Factor out a common RawFd/AsRawFd/etc for Unix and WASI. 2021-08-19 13:27:19 -07:00
Ellen
c2b61fbafe move code to InferCtxt method 2021-08-19 21:04:09 +01:00
Dan Gohman
0377a63352 Fix syntax for non-doc comments, and use crate:: instead of std::. 2021-08-19 12:23:04 -07:00
Cameron Steffen
ada92825c9 Fix clippy let expressions fallout 2021-08-19 14:17:05 -05:00
Dan Gohman
187ee5c824 Add I/O safety trait impls for process::Stdio and process::Child. 2021-08-19 12:02:41 -07:00
Dan Gohman
6f872880b4 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.
2021-08-19 12:02:41 -07:00
Dan Gohman
9b99f8c454 Remove the #![feature(io_safety)] from lib.rs. 2021-08-19 12:02:40 -07:00
Dan Gohman
a7d9ab5835 Fix an unused import warning. 2021-08-19 12:02:40 -07:00
Dan Gohman
cada5fb336 Update PidFd for the new I/O safety APIs. 2021-08-19 12:02:40 -07:00
Dan Gohman
1ae1eeec25 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>
2021-08-19 12:02:40 -07:00
Dan Gohman
18a9f4628a Don't encourage migration until io_safety is stablized. 2021-08-19 12:02:40 -07:00
Dan Gohman
1dbd6d60f0 Factor out Unix and WASI fd code into a common module. 2021-08-19 12:02:40 -07:00
Dan Gohman
71dab738ac Synchronize minor differences between Unix and WASI implementations. 2021-08-19 12:02:40 -07:00
Dan Gohman
907f00be30 Add more comments about the INVALID_HANDLE_VALUE situation. 2021-08-19 12:02:40 -07:00
Dan Gohman
ab08639e59 Add comments about impls for File, TcpStream, ChildStdin, etc. 2021-08-19 12:02:40 -07:00
Dan Gohman
68964a7d68 Fix copypasta of "Unix" within the WASI directory. 2021-08-19 12:02:40 -07:00
Dan Gohman
1b35f7405a Reword the description of dup2/dup3. 2021-08-19 12:02:40 -07:00
Dan Gohman
6d7211738d Add Safety comments to the As* for Owned* implementations. 2021-08-19 12:02:40 -07:00
Dan Gohman
6486f89cbc Add Owned*, Borrowed*, and As* to the preludes. 2021-08-19 12:02:39 -07:00