]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix more “a”/“an” typos
Frank Steffahn [Sun, 22 Aug 2021 15:27:18 +0000 (17:27 +0200)]
Fix more “a”/“an” typos

2 years agoRevert a change of “an --extern” (can be read with “dash dash”)
Frank Steffahn [Sun, 22 Aug 2021 14:37:47 +0000 (16:37 +0200)]
Revert a change of “an --extern” (can be read with “dash dash”)

2 years agoFix more “a”/“an” typos
Frank Steffahn [Sun, 22 Aug 2021 14:20:58 +0000 (16:20 +0200)]
Fix more “a”/“an” typos

2 years agoFix typos “a”→“an”
Frank Steffahn [Sun, 22 Aug 2021 12:46:15 +0000 (14:46 +0200)]
Fix typos “a”→“an”

2 years agoAuto merge of #85166 - mbhall88:file-prefix, r=dtolnay
bors [Sun, 22 Aug 2021 05:19:48 +0000 (05:19 +0000)]
Auto merge of #85166 - mbhall88:file-prefix, r=dtolnay

add file_prefix method to std::path

This is an initial implementation of `std::path::Path::file_prefix`. It is effectively a "left" variant of the existing [`file_stem`](https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem) method. An illustration of the difference is

```rust
use std::path::Path;

let path = Path::new("foo.tar.gz");
assert_eq!(path.file_stem(), Some("foo.tar"));
assert_eq!(path.file_prefix(), Some("foo"));
```

In my own development, I generally find I almost always want the prefix, rather than the stem, so I thought it might be best to suggest it's addition to libstd.

Of course, as this is my first contribution, I expect there is probably more work that needs to be done. Additionally, if the libstd team feel this isn't appropriate then so be it.

There has been some [discussion about this on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/file_lstem/near/238076313) and a user there suggested I open a PR to see whether someone in the libstd team thinks it is worth pursuing.

2 years agoAuto merge of #88217 - jackh726:rollup-3k74o2m, r=jackh726
bors [Sun, 22 Aug 2021 02:16:35 +0000 (02:16 +0000)]
Auto merge of #88217 - jackh726:rollup-3k74o2m, r=jackh726

Rollup of 13 pull requests

Successful merges:

 - #87604 (CI: Verify commits in beta & stable are in upstream branches.)
 - #88057 (Update RELEASES to clarify attribute macro values.)
 - #88072 (Allow the iOS toolchain to be built on Linux)
 - #88170 (Update release note for 1.55.0.)
 - #88172 (Test that type alias impl trait happens in a submodule)
 - #88179 (Mailmap entry for myself)
 - #88182 (We meant to use a trait instead of lifetime here)
 - #88183 (test TAIT in different positions)
 - #88189 (Add TAIT struct test)
 - #88192 (Use of impl trait in an impl as the value for an associated type in a dyn)
 - #88194 (Test use of impl Trait in an impl as the value for an associated type in an impl trait)
 - #88197 (Test tait use in a fn type)
 - #88201 (Test that incomplete inference for TAITs fail)

Failed merges:

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

2 years agoRollup merge of #88201 - spastorino:tait-incomplete-inference-test, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:39 +0000 (20:56 -0400)]
Rollup merge of #88201 - spastorino:tait-incomplete-inference-test, r=oli-obk

Test that incomplete inference for TAITs fail

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88197 - spastorino:tait-test-fn-type, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:38 +0000 (20:56 -0400)]
Rollup merge of #88197 - spastorino:tait-test-fn-type, r=oli-obk

Test tait use in a fn type

r? `@oli-obk`

I thought this was going to work but doesn't, quickly checked with Niko and he told me that we ruled this out for now. I'm not exactly sure why and how but here we have a test with a FIXME :)

Related to #86727

2 years agoRollup merge of #88194 - spastorino:test-tait-assoc-impl-trait, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:37 +0000 (20:56 -0400)]
Rollup merge of #88194 - spastorino:test-tait-assoc-impl-trait, r=oli-obk

Test use of impl Trait in an impl as the value for an associated type in an impl trait

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88192 - spastorino:add-tait-test-for-assoc-dyn, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:36 +0000 (20:56 -0400)]
Rollup merge of #88192 - spastorino:add-tait-test-for-assoc-dyn, r=oli-obk

Use of impl trait in an impl as the value for an associated type in a dyn

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88189 - spastorino:add-tait-struct-test, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:35 +0000 (20:56 -0400)]
Rollup merge of #88189 - spastorino:add-tait-struct-test, r=oli-obk

Add TAIT struct test

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88183 - spastorino:add-tait-in-different-tuple-position, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:34 +0000 (20:56 -0400)]
Rollup merge of #88183 - spastorino:add-tait-in-different-tuple-position, r=oli-obk

test TAIT in different positions

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88182 - spastorino:use-trait-in-tait-tests, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:33 +0000 (20:56 -0400)]
Rollup merge of #88182 - spastorino:use-trait-in-tait-tests, r=oli-obk

We meant to use a trait instead of lifetime here

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88179 - steffahn:mailmap, r=Mark-Simulacrum
Jack Huey [Sun, 22 Aug 2021 00:56:32 +0000 (20:56 -0400)]
Rollup merge of #88179 - steffahn:mailmap, r=Mark-Simulacrum

Mailmap entry for myself

2 years agoRollup merge of #88172 - spastorino:tait-defining-use-submodule-test, r=oli-obk
Jack Huey [Sun, 22 Aug 2021 00:56:31 +0000 (20:56 -0400)]
Rollup merge of #88172 - spastorino:tait-defining-use-submodule-test, r=oli-obk

Test that type alias impl trait happens in a submodule

r? `@oli-obk`

Related to #86727

2 years agoRollup merge of #88170 - nebkor:release-note-1.55, r=Mark-Simulacrum
Jack Huey [Sun, 22 Aug 2021 00:56:29 +0000 (20:56 -0400)]
Rollup merge of #88170 - nebkor:release-note-1.55, r=Mark-Simulacrum

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).

2 years agoRollup merge of #88072 - kit-981:feature/build-ios-toolchain-on-linux, r=Mark-Simulacrum
Jack Huey [Sun, 22 Aug 2021 00:56:29 +0000 (20:56 -0400)]
Rollup merge of #88072 - kit-981:feature/build-ios-toolchain-on-linux, r=Mark-Simulacrum

Allow the iOS toolchain to be built on Linux

The iOS toolchain can be built on Linux with minor changes. The compilation will invoke `xcrun` to find the path to the iPhone SDK but a fake `xcrun` executable can be used.

```
#!/bin/sh
echo "/path/to/sdk"
```

The iOS toolchain can then be built and linked with rustup.

```
$ ./x.py build --stage 2 --host x86_64-unknown-linux-gnu \
    --target aarch64-apple-ios
$ rustup toolchain link stage1 build/x86_64-unknown-linux-gnu/stage1
```

It's possible to take this toolchain and compile an iOS executable with it. This requires the ld64 linker and an iOS SDK. The ld64 linker can be taken from [cctools](https://github.com/tpoechtrager/cctools-port). A project's .cargo/config can then be edited to use the linker for this target.

```
[target.aarch64-apple-ios]
linker = "/path/to/cctools/bin/arm-apple-darwin-ld"
rustflags = [
    "-C",
    """
link-args=
    -F/path/to/sdk/System/Library/Frameworks
    -L/path/to/sdk/usr/lib
    -L/path/to/sdk/usr/lib/system/
    -adhoc_codesign
    """,
]
```

2 years agoRollup merge of #88057 - ehuss:releases-doc-macros, r=Mark-Simulacrum
Jack Huey [Sun, 22 Aug 2021 00:56:28 +0000 (20:56 -0400)]
Rollup merge of #88057 - ehuss:releases-doc-macros, r=Mark-Simulacrum

Update RELEASES to clarify attribute macro values.

As noted in #87681, macros do not work with the `#[path]` attribute.  Since the places where macros *can* be used is very limited, I have changed this to just focus on `#[doc]` which is the only attribute where this is really useful.

2 years agoRollup merge of #87604 - yaymukund:verify-backported-commits, r=Mark-Simulacrum
Jack Huey [Sun, 22 Aug 2021 00:56:27 +0000 (20:56 -0400)]
Rollup merge of #87604 - yaymukund:verify-backported-commits, r=Mark-Simulacrum

CI: Verify commits in beta & stable are in upstream branches.

Closes #74721

I think this does the trick. https://github.com/rust-lang/rust/pull/87597 is an example of it failing as it should.

2 years agoAuto merge of #88075 - Xuanwo:vec_deque_retain, r=dtolnay
bors [Sat, 21 Aug 2021 23:35:54 +0000 (23:35 +0000)]
Auto merge of #88075 - Xuanwo:vec_deque_retain, r=dtolnay

Optimize unnecessary check in VecDeque::retain

This pr is highly inspired by https://github.com/rust-lang/rust/pull/88060 which shared the same idea: we can split the `for` loop into stages so that we can remove unnecessary checks like `del > 0`.

## Benchmarks

Before

```rust
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     290,125 ns/iter (+/- 8,717)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     291,588 ns/iter (+/- 9,621)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     287,426 ns/iter (+/- 9,009)
```

After

```rust
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     243,940 ns/iter (+/- 8,563)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     242,768 ns/iter (+/- 3,903)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     202,926 ns/iter (+/- 6,332)
```

Based on the current benchmark, this PR will improve the perf of `VecDeque::retain` by around 16%. For special cases, the improvement will be up to 30%.

Signed-off-by: Xuanwo <github@xuanwo.io>
2 years agoAuto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis
bors [Sat, 21 Aug 2021 21:14:07 +0000 (21:14 +0000)]
Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis

Trait upcasting coercion (part 3)

By using separate candidates for each possible choice, this fixes type-checking issues in previous commits.

r? `@nikomatsakis`

2 years agoAuto merge of #82776 - jyn514:extern-url-fallback, r=GuillaumeGomez
bors [Sat, 21 Aug 2021 18:32:37 +0000 (18:32 +0000)]
Auto merge of #82776 - jyn514:extern-url-fallback, r=GuillaumeGomez

Give precedence to `html_root_url` over `--extern-html-root-url` by default, but add a way to opt-in to the previous behavior

## What is an HTML root url?

It tells rustdoc where it should link when documentation for a crate is
not available locally; for example, when a crate is a dependency of a
crate documented with `cargo doc --no-deps`.

 ## What is the difference between `html_root_url` and `--extern-html-root-url`?

Both of these tell rustdoc what the HTML root should be set to.
`doc(html_root_url)` is set by the crate author, while
`--extern-html-root-url` is set by the person documenting the crate.
These are often different. For example, docs.rs uses
`--extern-html-root-url https://docs.rs/crate-name/version` to ensure
all crates have documentation, even if `html_root_url` is not set.
Conversely, crates such as Rocket set `doc(html_root_url =
"https://api.rocket.rs")`, because they prefer users to view the
documentation on their own site.

Crates also set `html_root_url` to ensure they have
documentation when building locally when offline. This is unfortunate to
require, because it's more work from the library author. It also makes
it impossible to distinguish between crates that want to be viewed on a
different site (e.g. Rocket) and crates that just want documentation to
be visible offline at all (e.g. Tokio). I have authored a separate
change to the API guidelines to no longer recommend doing this:
rust-lang/api-guidelines#230.

 ## Why change the default?

In the past, docs.rs has been the main user of `--extern-html-root-url`.
However, it's useful for other projects as well. In particular, Cargo
wants to pass it by default when running `--no-deps`
(rust-lang/cargo#8296).

Unfortunately, for these other use cases, the priority order is
inverted. They want to give *precedence* to the URL the crate picks, and
only fall back to the `--extern-html-root` if no `html_root_url` is
present. That allows passing `--extern-html-root` unconditionally,
without having to parse the source code to see what attributes are
present.

For docs.rs, however, we still want to keep the old behavior, so that
all links on docs.rs stay on the site.

2 years agoAuto merge of #88134 - rylev:force-warn-improvements, r=nikomatsakis
bors [Sat, 21 Aug 2021 15:51:50 +0000 (15:51 +0000)]
Auto merge of #88134 - rylev:force-warn-improvements, r=nikomatsakis

Force warn improvements

As part of stablization of the `--force-warn` option (#86516) I've made the following changes:
* Error when the `warnings` lint group is based to the `--force-warn` option
* Tests have been updated to make it easier to understand the semantics of `--force-warn`

r? `@nikomatsakis`

2 years agoAuto merge of #88128 - cuviper:needs-asm-support, r=Mark-Simulacrum
bors [Sat, 21 Aug 2021 12:57:00 +0000 (12:57 +0000)]
Auto merge of #88128 - cuviper:needs-asm-support, r=Mark-Simulacrum

Add needs-asm-support to more tests

These were found as test failures on s390x for RHEL and Fedora.

2 years agoAuto merge of #87570 - nikic:llvm-13, r=nagisa
bors [Sat, 21 Aug 2021 09:25:28 +0000 (09:25 +0000)]
Auto merge of #87570 - nikic:llvm-13, r=nagisa

Upgrade to LLVM 13

Work in progress update to LLVM 13. Main changes:

 * InlineAsm diagnostics reported using SrcMgr diagnostic kind are now handled. Previously these used a separate diag handler.
 * Codegen tests are updated for additional attributes.
 * Some data layouts have changed.
 * Switch `#[used]` attribute from `llvm.used` to `llvm.compiler.used` to avoid SHF_GNU_RETAIN flag introduced in https://reviews.llvm.org/D97448, which appears to trigger a bug in older versions of gold.
 * Set `LLVM_INCLUDE_TESTS=OFF` to avoid Python 3.6 requirement.

Upstream issues:

 * ~~https://bugs.llvm.org/show_bug.cgi?id=51210 (InlineAsm diagnostic reporting for module asm)~~ Fixed by https://github.com/llvm/llvm-project/commit/1558bb80c01b695ce12642527cbfccf16cf54ece.
 * ~~https://bugs.llvm.org/show_bug.cgi?id=51476 (Miscompile on AArch64 due to incorrect comparison elimination)~~ Fixed by https://github.com/llvm/llvm-project/commit/81b106584f2baf33e09be2362c35c1bf2f6bfe94.
 * https://bugs.llvm.org/show_bug.cgi?id=51207 (Can't set custom section flags anymore). Problematic change reverted in our fork, https://reviews.llvm.org/D107216 posted for upstream revert.
 * https://bugs.llvm.org/show_bug.cgi?id=51211 (Regression in codegen for #83623). This is an optimization regression that we may likely have to eat for this release. The fix for #83623 was based on an incorrect premise, and this needs to be properly addressed in the MergeICmps pass.

The [compile-time impact](https://perf.rust-lang.org/compare.html?start=ef9549b6c0efb7525c9b012148689c8d070f9bc0&end=0983094463497eec22d550dad25576a894687002) is mixed, but quite positive as LLVM upgrades go.

The LLVM 13 final release is scheduled for Sep 21st. The current nightly is scheduled for stable release on Oct 21st.

r? `@ghost`

2 years agoAlways use llvm.used for coverage symbols
Nikita Popov [Fri, 20 Aug 2021 19:13:18 +0000 (21:13 +0200)]
Always use llvm.used for coverage symbols

This follows what clang does in CoverageMappingGen. Using just
llvm.compiler.used is insufficient at least for MSVC targets.

2 years agoAuto merge of #88073 - lnicola:rust-analyzer-2021-08-16, r=lnicola
bors [Sat, 21 Aug 2021 04:20:33 +0000 (04:20 +0000)]
Auto merge of #88073 - lnicola:rust-analyzer-2021-08-16, r=lnicola

:arrow_up: rust-analyzer

2 years agoTest that incomplete inference for TAITs fail
Santiago Pastorino [Sat, 21 Aug 2021 01:50:13 +0000 (22:50 -0300)]
Test that incomplete inference for TAITs fail

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 agoTest use of impl Trait in an impl as the value for an associated type in an impl...
Santiago Pastorino [Fri, 20 Aug 2021 21:06:31 +0000 (18:06 -0300)]
Test use of impl Trait in an impl as the value for an associated type in an impl trait

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 agoTest tait use in a fn type
Santiago Pastorino [Fri, 20 Aug 2021 21:32:57 +0000 (18:32 -0300)]
Test tait use in a fn type

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 agoUse of impl trait in an impl as the valoe for an associated type in a dyn
Santiago Pastorino [Fri, 20 Aug 2021 20:33:21 +0000 (17:33 -0300)]
Use of impl trait in an impl as the valoe for an associated type in a dyn

2 years agoAdd TAIT struct test
Santiago Pastorino [Fri, 20 Aug 2021 19:24:05 +0000 (16:24 -0300)]
Add TAIT struct test

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 agotest TAIT in different positions
Santiago Pastorino [Fri, 20 Aug 2021 14:15:48 +0000 (11:15 -0300)]
test TAIT in different positions

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 agoWe meant to use a trait instead of lifetime here
Santiago Pastorino [Fri, 20 Aug 2021 13:36:24 +0000 (10:36 -0300)]
We meant to use a trait instead of lifetime here

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 agoAdd support for including non-backport commits.
Mukund Lakshman [Fri, 20 Aug 2021 00:15:35 +0000 (01:15 +0100)]
Add support for including non-backport commits.

2 years agoAdd cherry-pick.sh convenience script.
Mukund Lakshman [Thu, 19 Aug 2021 20:58:17 +0000 (21:58 +0100)]
Add cherry-pick.sh convenience script.

2 years agoMailmap entry for myself
Frank Steffahn [Fri, 20 Aug 2021 10:11:45 +0000 (12:11 +0200)]
Mailmap entry for myself

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 agoCI: Verify commits in beta & stable are in upstream branches.
Mukund Lakshman [Thu, 29 Jul 2021 17:00:13 +0000 (18:00 +0100)]
CI: Verify commits in beta & stable are in upstream branches.

Closes #74721

2 years agoTest that type alias impl trait happens in a submodule
Santiago Pastorino [Thu, 19 Aug 2021 21:18:34 +0000 (18:18 -0300)]
Test that type alias impl trait happens in a submodule

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 agoUpdate release note for 1.55.0.
Joe Ardent [Thu, 19 Aug 2021 20:54:26 +0000 (13:54 -0700)]
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).

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 agoAdd assertion to ensure the query doesn't get called before type infererence is done.
Charles Lew [Thu, 19 Aug 2021 18:37:00 +0000 (02:37 +0800)]
Add assertion to ensure the query doesn't get called before type infererence is done.

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?