]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoRollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov
Matthias Krüger [Tue, 11 Oct 2022 16:59:45 +0000 (18:59 +0200)]
Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov

Check uniqueness of impl items by trait item when applicable.

When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items.  This means that a plain item and one generated by a macro 2.0 do not collide.

This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls.

This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice.

There should be no stable breakage, since macros 2.0 are still unstable.

r? ``@petrochenkov``
cc ``@RalfJung``

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

20 months agorustdoc: remove unneeded `.content` selector from link colors
Michael Howell [Tue, 11 Oct 2022 16:22:40 +0000 (09:22 -0700)]
rustdoc: remove unneeded `.content` selector from link colors

Since 98f05a0282625a5fda6e90ebf3b05a4bd7608f65 and
b5963f07e611cf2a09a310eb74c1a93adfaeb9de removed color classes from sidebar
items, there's no need for the selectors to be so specific any more.

This commit does have to change `h1.fqn a` to just be `h1 a`, so that the
header link color selector is less specific than the typed link at the end.
Since #89506 made docblocks start at `h2`, the main page link header should
be the only h1 in the page now.

20 months agorustdoc: remove unused classes from sidebar
Michael Howell [Tue, 11 Oct 2022 15:50:41 +0000 (08:50 -0700)]
rustdoc: remove unused classes from sidebar

Since 98f05a0282625a5fda6e90ebf3b05a4bd7608f65 removed separate colors
from the currently-selected item, there's no need to have item classes on
sidebar links.

20 months agoAuto merge of #102894 - RalfJung:compiler_builtins, r=Amanieu
bors [Tue, 11 Oct 2022 14:04:59 +0000 (14:04 +0000)]
Auto merge of #102894 - RalfJung:compiler_builtins, r=Amanieu

update compiler_builtins

r? `@Amanieu`

20 months agoAuto merge of #102915 - JohnTitor:rollup-5ht99y1, r=JohnTitor
bors [Tue, 11 Oct 2022 11:03:12 +0000 (11:03 +0000)]
Auto merge of #102915 - JohnTitor:rollup-5ht99y1, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #102258 (Remove unused variable in float formatting.)
 - #102277 (Consistently write `RwLock`)
 - #102412 (Never panic in `thread::park` and `thread::park_timeout`)
 - #102589 (scoped threads: pass closure through MaybeUninit to avoid invalid dangling references)
 - #102625 (fix backtrace small typo)
 - #102859 (Move lifetime resolution module to rustc_hir_analysis.)
 - #102898 (rustdoc: remove unneeded `<div>` wrapper from sidebar DOM)

Failed merges:

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

20 months agoRollup merge of #102898 - notriddle:notriddle/sidebar-block, r=GuillaumeGomez
Yuki Okushi [Tue, 11 Oct 2022 09:37:55 +0000 (18:37 +0900)]
Rollup merge of #102898 - notriddle:notriddle/sidebar-block, r=GuillaumeGomez

rustdoc: remove unneeded `<div>` wrapper from sidebar DOM

When this was added, the sidebar had a bit more complex style. It can be removed, now.

Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-block/std/index.html

20 months agoRollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Yuki Okushi [Tue, 11 Oct 2022 09:37:55 +0000 (18:37 +0900)]
Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk

Move lifetime resolution module to rustc_hir_analysis.

Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`.  It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.

20 months agoRollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se
Yuki Okushi [Tue, 11 Oct 2022 09:37:54 +0000 (18:37 +0900)]
Rollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se

fix backtrace small typo

20 months agoRollup merge of #102589 - RalfJung:scoped-threads-dangling, r=m-ou-se
Yuki Okushi [Tue, 11 Oct 2022 09:37:54 +0000 (18:37 +0900)]
Rollup merge of #102589 - RalfJung:scoped-threads-dangling, r=m-ou-se

scoped threads: pass closure through MaybeUninit to avoid invalid dangling references

The `main` function defined here looks roughly like this, if it were written as a more explicit stand-alone function:
```rust
// Not showing all the `'lifetime` tracking, the point is that
// this closure might live shorter than `thread`.
fn thread(control: ..., closure: impl FnOnce() + 'lifetime) {
    closure();
    control.signal_done();
    // A lot of time can pass here.
}
```
Note that `thread` continues to run even after `signal_done`! Now consider what happens if the `closure` captures a reference of lifetime `'lifetime`:
- The type of `closure` is a struct (the implicit unnameable closure type) with a `&'lifetime mut T` field. References passed to a function are marked with `dereferenceable`, which is LLVM speak for *this reference will remain live for the entire duration of this function*.
- The closure runs, `signal_done` runs. Then -- potentially -- this thread gets scheduled away and the main thread runs, seeing the signal and returning to the user. Now `'lifetime` ends and the memory the reference points to might be deallocated.
- Now we have UB! The reference that as passed to `thread` with the promise of remaining live for the entire duration of the function, actually got deallocated while the function still runs. Oops.

Long-term I think we should be able to use `ManuallyDrop` to fix this without `unsafe`, or maybe a new `MaybeDangling` type. I am working on an RFC for that. But in the mean time it'd be nice to fix this so that Miri with `-Zmiri-retag-fields` (which is needed for "full enforcement" of all the LLVM flags we generate) stops erroring on scoped threads.

Fixes https://github.com/rust-lang/rust/issues/101983
r? `@m-ou-se`

20 months agoRollup merge of #102412 - joboet:dont_panic, r=m-ou-se
Yuki Okushi [Tue, 11 Oct 2022 09:37:53 +0000 (18:37 +0900)]
Rollup merge of #102412 - joboet:dont_panic, r=m-ou-se

Never panic in `thread::park` and `thread::park_timeout`

fixes #102398

`@rustbot` label +T-libs +T-libs-api

20 months agoRollup merge of #102277 - mgeisler:rwlock, r=m-ou-se
Yuki Okushi [Tue, 11 Oct 2022 09:37:52 +0000 (18:37 +0900)]
Rollup merge of #102277 - mgeisler:rwlock, r=m-ou-se

Consistently write `RwLock`

Before the documentation sometimes referred to an "rwlock" and sometimes to "`RwLock`".

20 months agoRollup merge of #102258 - cjgillot:core-kappa, r=m-ou-se
Yuki Okushi [Tue, 11 Oct 2022 09:37:52 +0000 (18:37 +0900)]
Rollup merge of #102258 - cjgillot:core-kappa, r=m-ou-se

Remove unused variable in float formatting.

20 months agoAuto merge of #102755 - pcc:data-local-tmp, r=Mark-Simulacrum
bors [Tue, 11 Oct 2022 08:09:41 +0000 (08:09 +0000)]
Auto merge of #102755 - pcc:data-local-tmp, r=Mark-Simulacrum

tools/remote-test-{server,client}: Use /data/local/tmp on Android

The /data/tmp directory does not exist, at least not on recent versions of Android, which currently leads to test failures on that platform. I checked a virtual device running AOSP master and a Nexus 5 running Android Marshmallow and on both devices the /data/tmp directory does not exist and /data/local/tmp does, so let's switch to /data/local/tmp.

20 months ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 11 Oct 2022 07:37:35 +0000 (10:37 +0300)]
:arrow_up: rust-analyzer

20 months agoReport duplicate definitions in trait impls during resolution.
Camille GILLOT [Wed, 10 Aug 2022 19:31:26 +0000 (21:31 +0200)]
Report duplicate definitions in trait impls during resolution.

20 months agorustc_hir: Less error-prone methods for accessing `PartialRes` resolution
Vadim Petrochenkov [Mon, 10 Oct 2022 15:21:35 +0000 (19:21 +0400)]
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution

20 months agoAuto merge of #102724 - pcc:scs-fix-test, r=Mark-Simulacrum
bors [Tue, 11 Oct 2022 04:27:13 +0000 (04:27 +0000)]
Auto merge of #102724 - pcc:scs-fix-test, r=Mark-Simulacrum

Fix the sanitizer_scs_attr_check.rs test

The test is failing when targeting aarch64 Android. The intent appears to have been to look for a function attributes comment (or the absence of one) on the line preceding the function declaration. But this isn't quite possible with FileCheck and the test as written was looking for a line with `no_scs` after a line with `scs`, which doesn't appear in the output. Instead, match on the function attributes comment on the line following the demangled function name comment.

20 months agoRemove outdated comment
Michael Howell [Tue, 11 Oct 2022 00:53:27 +0000 (17:53 -0700)]
Remove outdated comment

20 months agoAuto merge of #102896 - matthiaskrgr:rollup-jg5xawz, r=matthiaskrgr
bors [Tue, 11 Oct 2022 00:36:26 +0000 (00:36 +0000)]
Auto merge of #102896 - matthiaskrgr:rollup-jg5xawz, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #101360 (Point out incompatible closure bounds)
 - #101789 (`let`'s not needed in struct field definitions)
 - #102846 (update to syn-1.0.102)
 - #102871 (rustdoc: clean up overly complex `.trait-impl` CSS selectors)
 - #102876 (suggest candidates for unresolved import)
 - #102888 (Improve rustdoc-gui search-color test)

Failed merges:

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

20 months agoDo not alias for fs
Ariel Davis [Tue, 11 Oct 2022 00:05:59 +0000 (17:05 -0700)]
Do not alias for fs

20 months agoAuto merge of #101720 - GuillaumeGomez:warn-INVALID_HTML_TAGS, r=notriddle
bors [Mon, 10 Oct 2022 21:41:02 +0000 (21:41 +0000)]
Auto merge of #101720 - GuillaumeGomez:warn-INVALID_HTML_TAGS, r=notriddle

Change default level of INVALID_HTML_TAGS to warning and stabilize it

Fixes of #67799.

cc `@Nemo157`
r? `@notriddle`

20 months agoCheck representability in adt_sized_constraint
Cameron Steffen [Mon, 10 Oct 2022 16:22:41 +0000 (11:22 -0500)]
Check representability in adt_sized_constraint

20 months agoRollup merge of #102888 - GuillaumeGomez:improve-search-color-check, r=notriddle
Matthias Krüger [Mon, 10 Oct 2022 18:47:34 +0000 (20:47 +0200)]
Rollup merge of #102888 - GuillaumeGomez:improve-search-color-check, r=notriddle

Improve rustdoc-gui search-color test

Thanks to the add of "functions" in `browser-ui-test`, we can start to reduce the size of the scripts. It'll be very useful for all color checks.

r? `@notriddle`

20 months agoRollup merge of #102876 - SparrowLii:import-candidate, r=fee1-dead
Matthias Krüger [Mon, 10 Oct 2022 18:47:34 +0000 (20:47 +0200)]
Rollup merge of #102876 - SparrowLii:import-candidate, r=fee1-dead

suggest candidates for unresolved import

Currently we prompt suggestion of candidates(help notes of `use xxx::yyy`) for names which cannot be resolved, but we don't do that for import statements themselves that couldn't be resolved. It seems reasonable to add candidate help information for these statements as well.
Fixes #102711

20 months agoRollup merge of #102871 - notriddle:notriddle/trait-impl-anchor, r=GuillaumeGomez
Matthias Krüger [Mon, 10 Oct 2022 18:47:33 +0000 (20:47 +0200)]
Rollup merge of #102871 - notriddle:notriddle/trait-impl-anchor, r=GuillaumeGomez

rustdoc: clean up overly complex `.trait-impl` CSS selectors

When added in 45964368f4a2e31c94e9bcf1cef933c087d21544, these multi-class selectors were present in the initial commit, but no reason was given why the shorter selector wouldn't work.

20 months agoRollup merge of #102846 - zertosh:update-syn, r=dtolnay
Matthias Krüger [Mon, 10 Oct 2022 18:47:33 +0000 (20:47 +0200)]
Rollup merge of #102846 - zertosh:update-syn, r=dtolnay

update to syn-1.0.102

This update removes the only `.gitignore` found in `rustc-src`:

    vendor/syn/tests/.gitignore
    vendor/syn-1.0.91/tests/.gitignore
    vendor/syn-1.0.95/tests/.gitignore

To check-in `rustc-src` for hermetic builds in environments with
restrictive `.gitignore` policies, one has to remove these
`tests/.gitignore` and patch the respective
`.cargo-checksum.json`.`syn` >1.0.101 includes dtolnay/syn@3c49303bed7a,
which removes its `tests/.gitignore`. Now the `syn` crates.io package
has no `.gitignore`.

[`rustc-src`'s `vendor`][] is produced from the root `Cargo.toml`,
`src/tools/rust-analyzer/Cargo.toml`,
`compiler/rustc_codegen_cranelift/Cargo.toml`, and
`src/bootstrap/Cargo.toml`. `rustc_codegen_cranelift` does not use
`syn`.

[`rustc-src`'s `vendor`]:
  https://github.com/rust-lang/rust/blob/c0784109daa0/src/bootstrap/dist.rs#L934-L940

This was produced with:

    cargo update --package syn --precise 1.0.102 \

    cargo update --package syn --precise 1.0.102 \
        --manifest-path src/tools/rust-analyzer/Cargo.toml

    cargo update --package syn --precise 1.0.102 \
        --manifest-path src/bootstrap/Cargo.toml

20 months agoRollup merge of #101789 - gimbles:let, r=estebank
Matthias Krüger [Mon, 10 Oct 2022 18:47:32 +0000 (20:47 +0200)]
Rollup merge of #101789 - gimbles:let, r=estebank

`let`'s not needed in struct field definitions

Fixes #101683

20 months agoRollup merge of #101360 - compiler-errors:multiple-closure-bounds, r=petrochenkov
Matthias Krüger [Mon, 10 Oct 2022 18:47:31 +0000 (20:47 +0200)]
Rollup merge of #101360 - compiler-errors:multiple-closure-bounds, r=petrochenkov

Point out incompatible closure bounds

Fixes #100295

20 months agoFix unclosed HTML tag in clippy doc
Guillaume Gomez [Mon, 10 Oct 2022 18:45:04 +0000 (20:45 +0200)]
Fix unclosed HTML tag in clippy doc

20 months agoAuto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrum
bors [Mon, 10 Oct 2022 18:42:40 +0000 (18:42 +0000)]
Auto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrum

Do the `calloc` optimization for `Option<bool>`

Inspired by <https://old.reddit.com/r/rust/comments/xtiqj8/why_is_this_functional_version_faster_than_my_for/iqqy37b/>.

20 months agorustdoc: remove unneeded `<div>` wrapper from sidebar DOM
Michael Howell [Mon, 10 Oct 2022 18:37:19 +0000 (11:37 -0700)]
rustdoc: remove unneeded `<div>` wrapper from sidebar DOM

When this was added, the sidebar had a bit more complex style. It can be
removed, now.

20 months agoupdate compiler_builtins
Ralf Jung [Mon, 10 Oct 2022 18:13:45 +0000 (20:13 +0200)]
update compiler_builtins

20 months agofix #102878
Takayuki Maeda [Mon, 10 Oct 2022 17:43:36 +0000 (02:43 +0900)]
fix #102878

20 months agoMove lifetime resolution module to rustc_hir_analysis.
Camille GILLOT [Sun, 9 Oct 2022 20:26:39 +0000 (20:26 +0000)]
Move lifetime resolution module to rustc_hir_analysis.

20 months agoFix unclosed HTML tag in rustfmt doc
Guillaume Gomez [Mon, 10 Oct 2022 16:29:17 +0000 (18:29 +0200)]
Fix unclosed HTML tag in rustfmt doc

20 months agoFix compiler docs
Guillaume Gomez [Sun, 9 Oct 2022 14:15:23 +0000 (16:15 +0200)]
Fix compiler docs

20 months agoFix doc lint error
Guillaume Gomez [Sat, 8 Oct 2022 12:42:38 +0000 (14:42 +0200)]
Fix doc lint error

20 months agoStabilize rustdoc CHECK_INVALID_HTML_TAGS check
Guillaume Gomez [Mon, 12 Sep 2022 10:07:43 +0000 (12:07 +0200)]
Stabilize rustdoc CHECK_INVALID_HTML_TAGS check

20 months agoUpdate rustdoc tests
Guillaume Gomez [Tue, 13 Sep 2022 10:01:07 +0000 (12:01 +0200)]
Update rustdoc tests

20 months agoChange default lint level of INVALID_HTML_TAGS to warning
Guillaume Gomez [Mon, 12 Sep 2022 13:02:45 +0000 (15:02 +0200)]
Change default lint level of INVALID_HTML_TAGS to warning

20 months agomake up your mind, rustfmt
Nathan Stocks [Mon, 10 Oct 2022 16:06:44 +0000 (10:06 -0600)]
make up your mind, rustfmt

20 months agoImplement `env_lock` with `RwLock`
Andrew Brown [Thu, 29 Sep 2022 18:17:15 +0000 (11:17 -0700)]
Implement `env_lock` with `RwLock`

Copying the approach of the Unix target, this change uses the standard
`RwLock` to protect against concurrent access of libc's environment.
This locking is only enabled when WebAssembly's `atomics` feature is
also enabled.

20 months agoSimplify result color checks
Guillaume Gomez [Mon, 10 Oct 2022 15:59:51 +0000 (17:59 +0200)]
Simplify result color checks

20 months agoUpdate browser-ui-test version to 0.12.2
Guillaume Gomez [Mon, 10 Oct 2022 13:09:38 +0000 (15:09 +0200)]
Update browser-ui-test version to 0.12.2

20 months agoAllow compiling the `wasm32-wasi` std library with atomics
Andrew Brown [Tue, 27 Sep 2022 18:50:47 +0000 (11:50 -0700)]
Allow compiling the `wasm32-wasi` std library with atomics

The issue #102157 demonstrates how currently the `-Z build-std` option
will fail when re-compiling the standard library with `RUSTFLAGS` like
`RUSTFLAGS="-C target-feature=+atomics,+bulk-memory -C
link-args=--shared-memory"`. This change attempts to resolve those build
issues by depending on the the WebAssembly `futex` module and providing
an implementation for `env_lock`. Fixes #102157.

20 months agoremove out-of-date fixme
Nathan Stocks [Mon, 10 Oct 2022 15:52:53 +0000 (09:52 -0600)]
remove out-of-date fixme

20 months agoFix stabilization of `feature(half_open_range_patterns)`
Urgau [Mon, 10 Oct 2022 13:45:05 +0000 (15:45 +0200)]
Fix stabilization of `feature(half_open_range_patterns)`

20 months agomacros: simplify field ordering in diag derive
David Wood [Mon, 3 Oct 2022 15:10:34 +0000 (16:10 +0100)]
macros: simplify field ordering in diag derive

Following the approach taken in earlier commits to separate formatting
initialization from use in the subdiagnostic derive, simplify the
diagnostic derive by removing the field-ordering logic that previously
solved this problem.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agomacros: separate suggestion fmt'ing and emission
David Wood [Mon, 3 Oct 2022 13:28:02 +0000 (14:28 +0100)]
macros: separate suggestion fmt'ing and emission

Diagnostic derives have previously had to take special care when
ordering the generated code so that fields were not used after a move.

This is unlikely for most fields because a field is either annotated
with a subdiagnostic attribute and is thus likely a `Span` and copiable,
or is a argument, in which case it is only used once by `set_arg`
anyway.

However, format strings for code in suggestions can result in fields
being used after being moved if not ordered carefully. As a result, the
derive currently puts `set_arg` calls last (just before emission), such
as:

```rust
let diag = { /* create diagnostic */ };

diag.span_suggestion_with_style(
    span,
    fluent::crate::slug,
    format!("{}", __binding_0),
    Applicability::Unknown,
    SuggestionStyle::ShowAlways
);
/* + other subdiagnostic additions */

diag.set_arg("foo", __binding_0);
/* + other `set_arg` calls */

diag.emit();
```

For eager translation, this doesn't work, as the message being
translated eagerly can assume that all arguments are available - so
arguments _must_ be set first.

Format strings for suggestion code are now separated into two parts - an
initialization line that performs the formatting into a variable, and a
usage in the subdiagnostic addition.

By separating these parts, the initialization can happen before
arguments are set, preserving the desired order so that code compiles,
while still enabling arguments to be set before subdiagnostics are
added.

```rust
let diag = { /* create diagnostic */ };

let __code_0 = format!("{}", __binding_0);
/* + other formatting */

diag.set_arg("foo", __binding_0);
/* + other `set_arg` calls */

diag.span_suggestion_with_style(
    span,
    fluent::crate::slug,
    __code_0,
    Applicability::Unknown,
    SuggestionStyle::ShowAlways
);
/* + other subdiagnostic additions */

diag.emit();
```

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agoquery_system: finish migration
David Wood [Mon, 3 Oct 2022 13:26:29 +0000 (14:26 +0100)]
query_system: finish migration

Using eager translation, migrate the remaining repeated cycle stack
diagnostic.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agomacros: `#[subdiagnostic(eager)]`
David Wood [Mon, 3 Oct 2022 13:24:17 +0000 (14:24 +0100)]
macros: `#[subdiagnostic(eager)]`

Add support for `eager` argument to the `subdiagnostic` attribute which
generates a call to `eager_subdiagnostic`.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agoerrors: `DiagnosticMessage::Eager`
David Wood [Mon, 3 Oct 2022 13:14:51 +0000 (14:14 +0100)]
errors: `DiagnosticMessage::Eager`

Add variant of `DiagnosticMessage` for eagerly translated messages
(messages in the target language which don't need translated by the
emitter during emission). Also adds `eager_subdiagnostic` function which
is intended to be invoked by the diagnostic derive for subdiagnostic
fields which are marked as needing eager translation.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agoerrors: `AddToDiagnostic::add_to_diagnostic_with`
David Wood [Mon, 3 Oct 2022 13:09:05 +0000 (14:09 +0100)]
errors: `AddToDiagnostic::add_to_diagnostic_with`

`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous
`AddToDiagnostic::add_to_diagnostic` but takes a function that can be
used by the caller to modify diagnostic messages originating from the
subdiagnostic (such as performing translation eagerly).

`add_to_diagnostic` now just calls `add_to_diagnostic_with` with an
empty closure.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agoerrors: use `HashMap` to store diagnostic args
David Wood [Mon, 3 Oct 2022 13:02:49 +0000 (14:02 +0100)]
errors: use `HashMap` to store diagnostic args

Eager translation will enable subdiagnostics to be translated multiple
times with different arguments - this requires the ability to replace
the value of one argument with a new value, which is better suited to a
`HashMap` than the previous storage, a `Vec`.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agomacros: tidy up lint changes
David Wood [Mon, 3 Oct 2022 14:34:00 +0000 (15:34 +0100)]
macros: tidy up lint changes

Small tweaks to changes made in a previous PR, unrelated to eager
translation.

Signed-off-by: David Wood <david.wood@huawei.com>
20 months agoAuto merge of #96711 - emilio:inline-slice-clone, r=nikic
bors [Mon, 10 Oct 2022 12:09:21 +0000 (12:09 +0000)]
Auto merge of #96711 - emilio:inline-slice-clone, r=nikic

slice: #[inline] a couple iterator methods.

The one I care about and actually saw in the wild not getting inlined is
clone(). We ended up doing a whole function call for something that just
copies two pointers.

I ended up marking as_slice / as_ref as well because make_slice is
inline(always) itself, and is also the kind of think that can kill
performance in hot loops if you expect it to get inlined. But happy to
undo those.

20 months ago`let` is not allowed in struct field definitions
gimbles [Mon, 10 Oct 2022 11:23:13 +0000 (16:53 +0530)]
`let` is not allowed in struct field definitions

Co-authored-by: jyn514 <jyn514@gmail.com>
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
20 months agoAuto merge of #102875 - Dylan-DPC:rollup-zwcq8h9, r=Dylan-DPC
bors [Mon, 10 Oct 2022 09:12:06 +0000 (09:12 +0000)]
Auto merge of #102875 - Dylan-DPC:rollup-zwcq8h9, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #99696 (Uplift `clippy::for_loops_over_fallibles` lint into rustc)
 - #102055 (Move some tests to more reasonable directories)
 - #102786 (Remove tuple candidate, nothing special about it)
 - #102794 (Make tests capture the error printed by a Result return)
 - #102853 (Skip chained OpaqueCast when building captures.)
 - #102868 (Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`)

Failed merges:

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

20 months agoRollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Dylan DPC [Mon, 10 Oct 2022 08:13:43 +0000 (13:43 +0530)]
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki

Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247

20 months agoRollup merge of #102853 - cjgillot:skip-opaque-cast, r=jackh726
Dylan DPC [Mon, 10 Oct 2022 08:13:42 +0000 (13:43 +0530)]
Rollup merge of #102853 - cjgillot:skip-opaque-cast, r=jackh726

Skip chained OpaqueCast when building captures.

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

20 months agoRollup merge of #102794 - dtolnay:termination, r=thomcc
Dylan DPC [Mon, 10 Oct 2022 08:13:41 +0000 (13:43 +0530)]
Rollup merge of #102794 - dtolnay:termination, r=thomcc

Make tests capture the error printed by a Result return

An error returned by tests previously would get written directly to stderr, instead of to the capture buffer set up by the test harness. This PR makes it write to the capture buffer so that it can be integrated as part of the test output by build tools such as `buck test`, since being able to read the error message returned by a test is pretty critical to debugging why the test failed.

<br>

**Before:**

```rust
// tests/test.rs

#[test]
fn test() -> Result<(), &'static str> {
    println!("STDOUT");
    eprintln!("STDERR");
    Err("RESULT")
}
```

```console
$ cargo build --test test
$ target/debug/deps/test-???????????????? -Z unstable-options --format=json
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "test" }
Error: "RESULT"
{ "type": "test", "name": "test", "event": "failed", "stdout": "STDOUT\nSTDERR\n" }
{ "type": "suite", "event": "failed", "passed": 0, "failed": 1, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.00040313 }
```

**After:**

```console
$ target/debug/deps/test-???????????????? -Z unstable-options --format=json
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "test" }
{ "type": "test", "name": "test", "event": "failed", "stdout": "STDOUT\nSTDERR\nError: \"RESULT\"" }
{ "type": "suite", "event": "failed", "passed": 0, "failed": 1, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000261894 }
```

20 months agoRollup merge of #102786 - compiler-errors:no-tuple-candidate, r=lcnr
Dylan DPC [Mon, 10 Oct 2022 08:13:41 +0000 (13:43 +0530)]
Rollup merge of #102786 - compiler-errors:no-tuple-candidate, r=lcnr

Remove tuple candidate, nothing special about it

r? `@lcnr` you mentioned this during the talk you gave i think

20 months agoRollup merge of #102055 - c410-f3r:moar-errors, r=petrochenkov
Dylan DPC [Mon, 10 Oct 2022 08:13:40 +0000 (13:43 +0530)]
Rollup merge of #102055 - c410-f3r:moar-errors, r=petrochenkov

Move some tests to more reasonable directories

r? ``@petrochenkov``

20 months agoRollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead
Dylan DPC [Mon, 10 Oct 2022 08:13:40 +0000 (13:43 +0530)]
Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead

Uplift `clippy::for_loops_over_fallibles` lint into rustc

This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this:
```rust
for _ in Some(1) {}
for _ in Ok::<_, ()>(1) {}
```
i.e. directly iterating over `Option` and `Result` using `for` loop.

There are a number of suggestions that this PR adds (on top of what clippy suggested):
1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later)
   ```rust
    for _ in iter.next() {}
    // turns into
    for _ in iter.by_ref() {}
    ```
2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels
   ```rust
   for _ in rx.recv() {}
   // turns into
   while let Some(_) = rx.recv() {}
   ```
3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?`
   ```rust
   for _ in f() {}
   // turns into
   for _ in f()? {}
   ```
4. To preserve the original behavior and clear intent, we can suggest using `if let`
   ```rust
   for _ in f() {}
   // turns into
   if let Some(_) = f() {}
   ```
(P.S. `Some` and `Ok` are interchangeable depending on the type)

I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)!

Resolves #99272

[`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles

20 months agorustdoc: clean up overly complex `.trait-impl` CSS selectors
Michael Howell [Mon, 10 Oct 2022 06:19:50 +0000 (23:19 -0700)]
rustdoc: clean up overly complex `.trait-impl` CSS selectors

When added in 45964368f4a2e31c94e9bcf1cef933c087d21544, these multi-class
selectors were present in the initial commit, but no reason was given why
the shorter selector wouldn't work.

20 months agoAuto merge of #94381 - Kobzol:llvm-bolt, r=Mark-Simulacrum
bors [Mon, 10 Oct 2022 06:18:58 +0000 (06:18 +0000)]
Auto merge of #94381 - Kobzol:llvm-bolt, r=Mark-Simulacrum

Use BOLT in CI to optimize LLVM

This PR adds an optimization step in the Linux `dist` CI pipeline that uses [BOLT](https://github.com/llvm/llvm-project/tree/main/bolt) to optimize the `libLLVM.so` library built by boostrap.

Steps:
- [x] Use LLVM 15 as a bootstrap compiler and use it to build BOLT
- [x] Compile LLVM with support for relocations (`-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-q"`)
- [x] Gather profile data using instrumented LLVM
- [x] Apply profile to LLVM that has already been PGOfied
- [x] Run with BOLT profiling on more benchmarks
- [x] Decide on the order of optimization (PGO -> BOLT?)
- [x] Decide how we should get `bolt` (currently we use the host `bolt`)
- [x] Clean up

The latest perf results can be found [here](https://github.com/rust-lang/rust/pull/94381#issuecomment-1258269440). The current CI build time with BOLT applied is around 1h 55 minutes.

20 months agoPoint out incompatible closure bounds
Michael Goulet [Sat, 3 Sep 2022 04:57:21 +0000 (04:57 +0000)]
Point out incompatible closure bounds

20 months agoAdd basename and dirname aliases
Ariel Davis [Mon, 10 Oct 2022 04:44:44 +0000 (21:44 -0700)]
Add basename and dirname aliases

20 months agoAuto merge of #102867 - JohnTitor:rollup-qnwsajt, r=JohnTitor
bors [Mon, 10 Oct 2022 03:20:03 +0000 (03:20 +0000)]
Auto merge of #102867 - JohnTitor:rollup-qnwsajt, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #102275 (Stabilize `half_open_range_patterns`)
 - #102323 (Trying to suggest additional lifetime parameter)
 - #102345 (Recover from impl Trait in type param bound)
 - #102845 (Elaborate trait ref to compute object safety.)
 - #102860 (Add missing documentation for FileNameDisplayPreference variants)
 - #102862 (From<Alignment> for usize & NonZeroUsize)

Failed merges:

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

20 months agosuggest candidates for unresolved import
SparrowLii [Mon, 10 Oct 2022 03:14:32 +0000 (11:14 +0800)]
suggest candidates for unresolved import

20 months agoRename AssocItemKind::TyAlias to AssocItemKind::Type
Michael Goulet [Mon, 10 Oct 2022 02:05:24 +0000 (02:05 +0000)]
Rename AssocItemKind::TyAlias to AssocItemKind::Type

20 months agoRollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc
Yuki Okushi [Mon, 10 Oct 2022 01:23:06 +0000 (10:23 +0900)]
Rollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc

From<Alignment> for usize & NonZeroUsize

Since you mentioned these two in https://github.com/rust-lang/rust/pull/102072#issuecomment-1272390033,
r? ``@thomcc``

Tracking Issue: https://github.com/rust-lang/rust/issues/102070

20 months agoRollup merge of #102860 - GuillaumeGomez:missing-docs-FileNameDisplayPreference,...
Yuki Okushi [Mon, 10 Oct 2022 01:23:05 +0000 (10:23 +0900)]
Rollup merge of #102860 - GuillaumeGomez:missing-docs-FileNameDisplayPreference, r=nagisa

Add missing documentation for FileNameDisplayPreference variants

Took me a while to find the information when I needed it so hopefully it should save some time for the next ones.

r? ``@thomcc``

20 months agoRollup merge of #102845 - cjgillot:gat-object, r=fee1-dead
Yuki Okushi [Mon, 10 Oct 2022 01:23:05 +0000 (10:23 +0900)]
Rollup merge of #102845 - cjgillot:gat-object, r=fee1-dead

Elaborate trait ref to compute object safety.

instead of building them manually from supertraits and associated items.

This allows to have the correct substs for GATs.

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

20 months agoRollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
Yuki Okushi [Mon, 10 Oct 2022 01:23:04 +0000 (10:23 +0900)]
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank

Recover from impl Trait in type param bound

Fixes #102182
r? ``@estebank``

20 months agoRollup merge of #102323 - Stoozy:master, r=cjgillot
Yuki Okushi [Mon, 10 Oct 2022 01:23:04 +0000 (10:23 +0900)]
Rollup merge of #102323 - Stoozy:master, r=cjgillot

Trying to suggest additional lifetime parameter

``@cjgillot`` This is what I have so far for #100615

20 months agoRollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillot
Yuki Okushi [Mon, 10 Oct 2022 01:23:03 +0000 (10:23 +0900)]
Rollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillot

Stabilize `half_open_range_patterns`

This PR stabilize `feature(half_open_range_patterns)`:
```
Allows using `..=X` as a pattern.
```

And adds a new `feature(half_open_range_patterns_in_slices)` for the slice part, https://github.com/rust-lang/rust/pull/102275#issuecomment-1267422806.

The FCP was completed in https://github.com/rust-lang/rust/issues/67264.

20 months agoFrom<Alignment> for usize & NonZeroUsize
Scott McMurray [Sun, 9 Oct 2022 22:12:43 +0000 (15:12 -0700)]
From<Alignment> for usize & NonZeroUsize

20 months agoAdd missing documentation for FileNameDisplayPreference variants
Guillaume Gomez [Sun, 9 Oct 2022 20:49:23 +0000 (22:49 +0200)]
Add missing documentation for FileNameDisplayPreference variants

20 months agoAuto merge of #89123 - the8472:push_in_capacity, r=amanieu
bors [Sun, 9 Oct 2022 21:02:33 +0000 (21:02 +0000)]
Auto merge of #89123 - the8472:push_in_capacity, r=amanieu

add Vec::push_within_capacity - fallible, does not allocate

This method can serve several purposes. It

* is fallible
* guarantees that items in Vec aren't moved
* allows loops that do `reserve` and `push` separately to avoid pulling in the allocation machinery a second time in the `push` part which should make things easier on the optimizer
* eases the path towards `ArrayVec` a bit since - compared to `push()` - there are fewer questions around how it should be implemented

I haven't named it `try_push` because that should probably occupy a middle ground that will still try to reserve and only return an error in the unlikely OOM case.

resolves #84649

20 months agoAuto merge of #102850 - JohnTitor:rollup-lze1w03, r=JohnTitor
bors [Sun, 9 Oct 2022 18:15:26 +0000 (18:15 +0000)]
Auto merge of #102850 - JohnTitor:rollup-lze1w03, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #101118 (fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD)
 - #102072 (Add `ptr::Alignment` type)
 - #102799 (rustdoc: remove hover gap in file picker)
 - #102820 (Show let-else suggestion on stable.)
 - #102829 (rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`)
 - #102831 (Don't use unnormalized type in `Ty::fn_sig` call in rustdoc `clean_middle_ty`)
 - #102834 (Remove unnecessary `lift`/`lift_to_tcx` calls from rustdoc)
 - #102838 (remove cfg(bootstrap) from Miri)

Failed merges:

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

20 months agoupdate to syn-1.0.102
Andres Suarez [Sun, 9 Oct 2022 03:25:40 +0000 (23:25 -0400)]
update to syn-1.0.102

20 months agoopenbsd: don't reallocate a guard page on the stack.
Sébastien Marie [Sun, 9 Oct 2022 16:45:04 +0000 (16:45 +0000)]
openbsd: don't reallocate a guard page on the stack.

the kernel currently enforce that a stack is immutable. calling mmap(2) or
mprotect(2) to change it will result in EPERM, which generate a panic!().

so just do like for Linux, and trust the kernel to do the right thing.

20 months agoSkip chained OpaqueCast when building captures.
Camille GILLOT [Sun, 9 Oct 2022 16:15:16 +0000 (16:15 +0000)]
Skip chained OpaqueCast when building captures.

20 months agoRollup merge of #102838 - RalfJung:miri-bootstrap, r=oli-obk
Yuki Okushi [Sun, 9 Oct 2022 15:09:43 +0000 (00:09 +0900)]
Rollup merge of #102838 - RalfJung:miri-bootstrap, r=oli-obk

remove cfg(bootstrap) from Miri

Looks like this was forgotten in the bootstrap bump.

r? `@oli-obk`

20 months agoRollup merge of #102834 - compiler-errors:unnecessary-lift, r=jyn514
Yuki Okushi [Sun, 9 Oct 2022 15:09:43 +0000 (00:09 +0900)]
Rollup merge of #102834 - compiler-errors:unnecessary-lift, r=jyn514

Remove unnecessary `lift`/`lift_to_tcx` calls from rustdoc

Not sure why they were here in the first place

20 months agoRollup merge of #102831 - compiler-errors:rustdoc-norm-oops, r=jyn514
Yuki Okushi [Sun, 9 Oct 2022 15:09:42 +0000 (00:09 +0900)]
Rollup merge of #102831 - compiler-errors:rustdoc-norm-oops, r=jyn514

Don't use unnormalized type in `Ty::fn_sig` call in rustdoc `clean_middle_ty`

Self-explanatory

Fixes #102828

20 months agoRollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
Yuki Okushi [Sun, 9 Oct 2022 15:09:42 +0000 (00:09 +0900)]
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki

rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.

20 months agoRollup merge of #102820 - ehuss:let-else-nightly-suggestion, r=petrochenkov
Yuki Okushi [Sun, 9 Oct 2022 15:09:41 +0000 (00:09 +0900)]
Rollup merge of #102820 - ehuss:let-else-nightly-suggestion, r=petrochenkov

Show let-else suggestion on stable.

The E0005 error message has a suggestion to use let-else. Now that let-else is stabilized, I think this message should be included on non-nightly toolchains. I suspect this was just an oversight from #93628.  [`E0005.stderr`](https://github.com/ehuss/rust/blob/be1c7aad723126b2ea65543b4ceed54167b841a2/src/test/ui/error-codes/E0005.stderr#L22-L25) contains an example of what this suggestion looks like.

20 months agoRollup merge of #102799 - rol1510:issue-100421-fix, r=notriddle
Yuki Okushi [Sun, 9 Oct 2022 15:09:41 +0000 (00:09 +0900)]
Rollup merge of #102799 - rol1510:issue-100421-fix, r=notriddle

rustdoc: remove hover gap in file picker

Fixes #100421

Before:
<img width="385" alt="image" src="https://user-images.githubusercontent.com/29011024/194677087-fda2db3e-126d-47cf-8152-c554e3c25a54.png">

After:
<img width="388" alt="image" src="https://user-images.githubusercontent.com/29011024/194676774-7a50ace9-4060-492e-849a-ad85d9132630.png">

longe module names also wrap nicely:
<img width="389" alt="image" src="https://user-images.githubusercontent.com/29011024/194678516-f2497b3a-8d50-439b-9d69-3fa9fb43b84d.png">

Also if you zoom out very far, the arrows did move to the left, in relation to the text below. This is now also fixed.
<img width="818" alt="image" src="https://user-images.githubusercontent.com/29011024/194677652-cfdf129d-f5db-4f26-ac3c-3d0853e89619.png">

CSS doesn't have a lot of controll over the `::marker` element, so now the `::after` element is used to draw the arrows.

Now the whole line is clickable wihtout gaps.

20 months agoRollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc
Yuki Okushi [Sun, 9 Oct 2022 15:09:40 +0000 (00:09 +0900)]
Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc

Add `ptr::Alignment` type

Essentially no new code here, just exposing the previously-`pub(crate)` `ValidAlign` type under the name from the ACP.

ACP: https://github.com/rust-lang/libs-team/issues/108
Tracking Issue: https://github.com/rust-lang/rust/issues/102070

r? ``@ghost``

20 months agoRollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum
Yuki Okushi [Sun, 9 Oct 2022 15:09:39 +0000 (00:09 +0900)]
Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum

fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD

supporting this flag.

20 months agoAuto merge of #93668 - SUPERCILEX:path_alloc, r=joshtriplett
bors [Sun, 9 Oct 2022 15:07:10 +0000 (15:07 +0000)]
Auto merge of #93668 - SUPERCILEX:path_alloc, r=joshtriplett

Reduce CString allocations in std as much as possible

Currently, every operation involving paths in `fs` allocates memory to hold the path before sending it through the syscall. This PR instead uses a stack allocation (chosen size is somewhat arbitrary) when the path is short before falling back to heap allocations for long paths.

Benchmarks show that the stack allocation is ~2x faster for short paths:

```
test sys::unix::fd::tests::bench_heap_path_alloc                  ... bench:          34 ns/iter (+/- 2)
test sys::unix::fd::tests::bench_stack_path_alloc                 ... bench:          15 ns/iter (+/- 1)
```

For long paths, I couldn't find any measurable difference.

---

I'd be surprised if I was the first to think of this, so I didn't fully flush out the PR. If this change is desirable, I'll make use of `run_with_cstr` across all platforms in every fs method (currently just unix open for testing). I also added an `impl From<FromBytesWithNulError>` which is presumably a no-no (or at least needs to be done in another PR).

---

Also see https://github.com/nix-rust/nix/pull/1655 with a bunch of discussion where I'm doing something similar.

20 months agoElaborate trait ref to compute object safety.
Camille GILLOT [Sun, 9 Oct 2022 13:34:42 +0000 (13:34 +0000)]
Elaborate trait ref to compute object safety.

20 months agoadopt to building infcx
Maybe Waffle [Fri, 7 Oct 2022 18:21:32 +0000 (18:21 +0000)]
adopt to building infcx

20 months agodeprecate `clippy::for_loops_over_fallibles`
Maybe Waffle [Fri, 7 Oct 2022 17:08:29 +0000 (17:08 +0000)]
deprecate `clippy::for_loops_over_fallibles`

20 months agoadopt to new rustc lint api
Maybe Waffle [Fri, 7 Oct 2022 16:52:41 +0000 (16:52 +0000)]
adopt to new rustc lint api

20 months agofixup lint name
Maybe Waffle [Fri, 7 Oct 2022 15:59:39 +0000 (15:59 +0000)]
fixup lint name

20 months agoFix clippy tests that trigger `for_loop_over_fallibles` lint
Maybe Waffle [Thu, 25 Aug 2022 10:03:13 +0000 (14:03 +0400)]
Fix clippy tests that trigger `for_loop_over_fallibles` lint

20 months agofix `for_loop_over_fallibles` lint docs
Maybe Waffle [Thu, 18 Aug 2022 07:43:10 +0000 (11:43 +0400)]
fix `for_loop_over_fallibles` lint docs