]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoVec::dedup optimization - add benches
Soveu [Tue, 16 Mar 2021 13:41:26 +0000 (14:41 +0100)]
Vec::dedup optimization - add benches

3 years agoMerge branch 'master' into dedup
Soveu [Mon, 15 Mar 2021 20:51:38 +0000 (21:51 +0100)]
Merge branch 'master' into dedup

3 years agoVec::dedup optimization - add test for panic
Soveu [Mon, 15 Mar 2021 20:26:22 +0000 (21:26 +0100)]
Vec::dedup optimization - add test for panic

3 years agoVec::dedup optimization - finishing polishes
Soveu [Mon, 15 Mar 2021 19:36:29 +0000 (20:36 +0100)]
Vec::dedup optimization - finishing polishes

3 years agoVec::dedup optimization - add tests
Soveu [Mon, 15 Mar 2021 19:24:35 +0000 (20:24 +0100)]
Vec::dedup optimization - add tests

3 years agoAuto merge of #83149 - Dylan-DPC:rollup-ov70c5v, r=Dylan-DPC
bors [Mon, 15 Mar 2021 15:24:54 +0000 (15:24 +0000)]
Auto merge of #83149 - Dylan-DPC:rollup-ov70c5v, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #82989 (Custom error on literal names from other languages)
 - #83054 (Validate rustc_layout_scalar_valid_range_{start,end} attributes)
 - #83098 (Find more invalid doc attributes)
 - #83108 (Remove unused `opt_local_def_id_to_hir_id` function)
 - #83110 (Fix typos in `library/core/src/ptr/mod.rs` and `library/std/src/sys_common/thread_local_dtor.rs`)
 - #83113 (Minor refactoring in try_index_step)
 - #83127 (Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`)
 - #83132 (Don't encode file information for span with a dummy location)
 - #83141 (:arrow_up: rust-analyzer)
 - #83144 (Introduce `rustc_interface::interface::Config::parse_sess_created` callback)

Failed merges:

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

3 years agoRollup merge of #83144 - hyd-dev:parse-sess-created, r=oli-obk
Dylan DPC [Mon, 15 Mar 2021 15:23:00 +0000 (16:23 +0100)]
Rollup merge of #83144 - hyd-dev:parse-sess-created, r=oli-obk

Introduce `rustc_interface::interface::Config::parse_sess_created` callback

Resolves #82900.

cc `@oli-obk`

3 years agoRollup merge of #83141 - lnicola:rust-analyzer-2021-03-15, r=jonas-schievink
Dylan DPC [Mon, 15 Mar 2021 15:22:59 +0000 (16:22 +0100)]
Rollup merge of #83141 - lnicola:rust-analyzer-2021-03-15, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank
Dylan DPC [Mon, 15 Mar 2021 15:22:58 +0000 (16:22 +0100)]
Rollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank

Don't encode file information for span with a dummy location

Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.

3 years agoRollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov
Dylan DPC [Mon, 15 Mar 2021 15:22:57 +0000 (16:22 +0100)]
Rollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov

Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`

Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.

3 years agoRollup merge of #83113 - osa1:refactor_try_index_step, r=jonas-schievink
Dylan DPC [Mon, 15 Mar 2021 15:22:56 +0000 (16:22 +0100)]
Rollup merge of #83113 - osa1:refactor_try_index_step, r=jonas-schievink

Minor refactoring in try_index_step

Merges `if-let` and `if x.is_some() { ... }` blocks

3 years agoRollup merge of #83110 - hyksm:fix-typo, r=jonas-schievink
Dylan DPC [Mon, 15 Mar 2021 15:22:55 +0000 (16:22 +0100)]
Rollup merge of #83110 - hyksm:fix-typo, r=jonas-schievink

Fix typos in `library/core/src/ptr/mod.rs` and `library/std/src/sys_common/thread_local_dtor.rs`

adress -> address

3 years agoRollup merge of #83108 - jyn514:remove-unused, r=estebank
Dylan DPC [Mon, 15 Mar 2021 15:22:53 +0000 (16:22 +0100)]
Rollup merge of #83108 - jyn514:remove-unused, r=estebank

Remove unused `opt_local_def_id_to_hir_id` function

Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.

3 years agoRollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco
Dylan DPC [Mon, 15 Mar 2021 15:22:52 +0000 (16:22 +0100)]
Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco

Find more invalid doc attributes

- Lint on `#[doc(123)]`, `#[doc("hello")]`, etc.
- Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]`
- Add hyphen to "crate level"
- Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string

3 years agoRollup merge of #83054 - tmiasko:rustc_layout_scalar_valid_range, r=davidtwco
Dylan DPC [Mon, 15 Mar 2021 15:22:51 +0000 (16:22 +0100)]
Rollup merge of #83054 - tmiasko:rustc_layout_scalar_valid_range, r=davidtwco

Validate rustc_layout_scalar_valid_range_{start,end} attributes

Fixes #82251, fixes #82981.

3 years agoRollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor
Dylan DPC [Mon, 15 Mar 2021 15:22:50 +0000 (16:22 +0100)]
Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor

Custom error on literal names from other languages

This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.

3 years agoFix `src/test/run-make-fulldeps/issue-19371`
hyd-dev [Mon, 15 Mar 2021 13:16:39 +0000 (21:16 +0800)]
Fix `src/test/run-make-fulldeps/issue-19371`

3 years agoChange the `.unwrap` to `.expect` with a helpful message
hyd-dev [Mon, 15 Mar 2021 12:44:48 +0000 (20:44 +0800)]
Change the `.unwrap` to `.expect` with a helpful message

3 years agoCustom error on literal names from other languages
Smitty [Mon, 15 Mar 2021 12:11:02 +0000 (08:11 -0400)]
Custom error on literal names from other languages

This detects all Java literal types and all single word C data types,
and suggests the corresponding Rust literal type.

3 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 15 Mar 2021 11:55:56 +0000 (13:55 +0200)]
:arrow_up: rust-analyzer

3 years agoAuto merge of #83118 - erikdesjardins:removezst, r=oli-obk
bors [Mon, 15 Mar 2021 11:30:33 +0000 (11:30 +0000)]
Auto merge of #83118 - erikdesjardins:removezst, r=oli-obk

Rebase and fixup #80493: Remove MIR assignments to ZST types

closes #80493

cc `@simonvandel`

r? `@oli-obk`

3 years agoUse `rustc_interface::interface::Config::parse_sess_created` in Clippy
hyd-dev [Mon, 15 Mar 2021 10:24:28 +0000 (18:24 +0800)]
Use `rustc_interface::interface::Config::parse_sess_created` in Clippy

3 years agoAdd `rustc_interface::interface::Config::parse_sess_created`
hyd-dev [Mon, 15 Mar 2021 09:57:53 +0000 (17:57 +0800)]
Add `rustc_interface::interface::Config::parse_sess_created`

3 years agoAuto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum
bors [Mon, 15 Mar 2021 08:49:25 +0000 (08:49 +0000)]
Auto merge of #82999 - cuviper:rustc-rayon-0.3.1, r=Mark-Simulacrum

Update to rustc-rayon 0.3.1

This pulls in rust-lang/rustc-rayon#8 to fix #81425. (h/t `@ammaraskar)`

That revealed weak constraints on `rustc_arena::DropArena`, because its
`DropType` was holding type-erased raw pointers to generic `T`. We can
implement `Send` for `DropType` (under `cfg(parallel_compiler)`) by
requiring all `T: Send` before they're type-erased.

3 years agoAuto merge of #83074 - Aaron1011:new-sort-fix, r=jackh726
bors [Mon, 15 Mar 2021 06:20:24 +0000 (06:20 +0000)]
Auto merge of #83074 - Aaron1011:new-sort-fix, r=jackh726

Avoid sorting predicates by `DefId`

Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.

3 years agoBump recursion_limit in a few places
Aaron Hill [Sun, 14 Mar 2021 18:12:04 +0000 (14:12 -0400)]
Bump recursion_limit in a few places

This is needed to get rustdoc to succeed on `dist-x86_64-linux-alt`

3 years agoIntroduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`
Aaron Hill [Sun, 14 Mar 2021 20:55:59 +0000 (16:55 -0400)]
Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`

Now that future-incompat-report support has landed in nightly Cargo, we
can start to make progress towards removing the various proc-macro
back-compat hacks that have accumulated in the compiler.

This PR introduces a new lint `proc_macro_back_compat`, which results in
a future-incompat-report entry being generated. All proc-macro
back-compat warnings will be grouped under this lint. Note that this
lint will never actually become a hard error - instead, we will remove
the special cases for various macros, which will cause older versions of
those crates to emit some other error.

I've added code to fire this lint for the `time-macros-impl` case. This
is the easiest case out of all of our current back-compat hacks - the
crate was renamed to `time-macros`, so seeing a filename with
`time-macros-impl` guarantees that an older version of the parent `time`
crate is in use.

When Cargo's future-incompat-report feature gets stabilized, affected
users will start to see future-incompat warnings when they build their
crates.

3 years agoDon't encode file information for span with a dummy location
Aaron Hill [Sun, 14 Mar 2021 23:03:16 +0000 (19:03 -0400)]
Don't encode file information for span with a dummy location

Fixes #83112

The location information for a dummy span isn't real, so don't encode
it. This brings the incr comp cache code into line with the Span
`StableHash` impl, which doesn't hash the location information for dummy
spans.

Previously, we would attempt to load the 'original' file from a dummy
span - if the file id changed (e.g. due to being moved on disk), we would get an
ICE, since the Span was still valid due to its hash being unchanged.

3 years agoremove unnecessary condition
Erik Desjardins [Mon, 15 Mar 2021 00:21:20 +0000 (20:21 -0400)]
remove unnecessary condition

`_local` isn't visited in `_local = <rhs>` statements in the situation
we care about

3 years agoUse pretty-printer instead of `span_to_snippet`
Camelid [Sun, 14 Mar 2021 21:39:13 +0000 (14:39 -0700)]
Use pretty-printer instead of `span_to_snippet`

3 years agoAuto merge of #83062 - JohnTitor:improve-reassign-err, r=davidtwco
bors [Sun, 14 Mar 2021 21:10:50 +0000 (21:10 +0000)]
Auto merge of #83062 - JohnTitor:improve-reassign-err, r=davidtwco

Improve the wording for the `can't reassign` error

Follow-up for https://github.com/rust-lang/rust/pull/71976#discussion_r448186151.
Fixes #66736

3 years agoTweak diagnostics
Camelid [Sun, 14 Mar 2021 21:00:02 +0000 (14:00 -0700)]
Tweak diagnostics

- Tweak lint message
- Display multi-segment paths correctly

3 years agobless tests (32-bit)
Erik Desjardins [Sun, 14 Mar 2021 17:53:16 +0000 (13:53 -0400)]
bless tests (32-bit)

3 years agoAuto merge of #82399 - petrochenkov:modin2, r=Aaron1011
bors [Sun, 14 Mar 2021 17:36:06 +0000 (17:36 +0000)]
Auto merge of #82399 - petrochenkov:modin2, r=Aaron1011

expand: Resolve and expand inner attributes on out-of-line modules

Fixes https://github.com/rust-lang/rust/issues/81661
r? `@Aaron1011`

3 years agoexpand: Resolve and expand inner attributes on out-of-line modules
Vadim Petrochenkov [Sun, 21 Feb 2021 13:32:38 +0000 (16:32 +0300)]
expand: Resolve and expand inner attributes on out-of-line modules

3 years agoAuto merge of #83082 - cjgillot:defkey-ii, r=oli-obk
bors [Sun, 14 Mar 2021 14:16:21 +0000 (14:16 +0000)]
Auto merge of #83082 - cjgillot:defkey-ii, r=oli-obk

Iterate on crate_inherent_impls for metadata.

Split from #80347

r? `@oli-obk`

3 years agoRemove duplicate asserts, replace eq assert with assert_eq
Ömer Sinan Ağacan [Sun, 14 Mar 2021 14:06:18 +0000 (17:06 +0300)]
Remove duplicate asserts, replace eq assert with assert_eq

3 years agoMinor refactoring in try_index_step
Ömer Sinan Ağacan [Sun, 14 Mar 2021 13:00:02 +0000 (16:00 +0300)]
Minor refactoring in try_index_step

Merges `if-let` and `if x.is_some() { ... }` blocks

3 years agoAuto merge of #83044 - kubo39:set-llvm-code-model, r=nikic
bors [Sun, 14 Mar 2021 11:46:57 +0000 (11:46 +0000)]
Auto merge of #83044 - kubo39:set-llvm-code-model, r=nikic

Add support for storing code model to LLVM module IR

This patch avoids undefined behavior by linking different object files.
Also this would it could be propagated properly to LTO.

See https://reviews.llvm.org/D52322 and https://reviews.llvm.org/D52323.

This patch is based on https://github.com/rust-lang/rust/pull/74002

3 years agoAuto merge of #83094 - GuillaumeGomez:crates-js-location, r=Nemo157
bors [Sun, 14 Mar 2021 09:16:23 +0000 (09:16 +0000)]
Auto merge of #83094 - GuillaumeGomez:crates-js-location, r=Nemo157

crates.js should use root_path and not static_root_path

r? `@Nemo157`

3 years agoFix a typo in thread_local_dtor.rs
Motoki Ikeda [Sun, 14 Mar 2021 07:39:29 +0000 (16:39 +0900)]
Fix a typo in thread_local_dtor.rs

3 years agoFix a typo in `swap_nonoverlapping_bytes`
Motoki Ikeda [Fri, 12 Mar 2021 15:51:26 +0000 (00:51 +0900)]
Fix a typo in `swap_nonoverlapping_bytes`

3 years agoRemove unused `opt_local_def_id_to_hir_id` function
Joshua Nelson [Sun, 14 Mar 2021 06:37:13 +0000 (01:37 -0500)]
Remove unused `opt_local_def_id_to_hir_id` function

Found while investigating #82933 - all LocalDefIds are expected to have
HirIds, there's no point in pretending otherwise.

3 years agoAuto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157
bors [Sun, 14 Mar 2021 06:35:19 +0000 (06:35 +0000)]
Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157

Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used)

When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example).

r? `@jyn514`

3 years agoAuto merge of #83105 - JohnTitor:rollup-tqpm8pb, r=JohnTitor
bors [Sun, 14 Mar 2021 04:09:02 +0000 (04:09 +0000)]
Auto merge of #83105 - JohnTitor:rollup-tqpm8pb, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #81465 (Add documentation about formatting `Duration` values)
 - #82121 (Implement Extend and FromIterator for OsString)
 - #82617 (Document `everybody_loops`)
 - #82789 (Get with field index from pattern slice instead of directly indexing)
 - #82798 (Rename `rustdoc` to `rustdoc::all`)
 - #82804 (std: Fix a bug on the wasm32-wasi target opening files)
 - #82943 (Demonstrate best practice for feeding stdin of a child processes)
 - #83066 (Add `reverse` search alias for Iterator::rev())
 - #83070 (Update cargo)
 - #83081 (Fix panic message of `assert_failed_inner`)

Failed merges:

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

3 years agoRollup merge of #83081 - hyd-dev:assert-message, r=m-ou-se
Yuki Okushi [Sun, 14 Mar 2021 04:07:37 +0000 (13:07 +0900)]
Rollup merge of #83081 - hyd-dev:assert-message, r=m-ou-se

Fix panic message of `assert_failed_inner`

cc https://github.com/rust-lang/rust/pull/79100#discussion_r593731020

r? ``@m-ou-se``

3 years agoRollup merge of #83070 - ehuss:update-cargo, r=ehuss
Yuki Okushi [Sun, 14 Mar 2021 04:07:36 +0000 (13:07 +0900)]
Rollup merge of #83070 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in 970bc67c3775781b9708c8a36893576b9459c64a..32da9eaa5de5be241cf8096ca6b749a157194f77
2021-03-07 18:09:40 +0000 to 2021-03-13 01:18:40 +0000
- Fix logic for determining prefer-dynamic for a dylib. (rust-lang/cargo#9252)
- Fix issue with filtering exclusive target dependencies. (rust-lang/cargo#9255)
- Update pkgid-spec docs. (rust-lang/cargo#9249)
- Wordsmith the edition documentation a bit more (rust-lang/cargo#9233)
- Package ID specification urls must contain a host (rust-lang/cargo#9188)
- Add documentation for JSON message_path. (rust-lang/cargo#9247)
- Fix filter_platform to run on targets other than x86. (rust-lang/cargo#9246)

3 years agoRollup merge of #83066 - Seppel3210:master, r=joshtriplett
Yuki Okushi [Sun, 14 Mar 2021 04:07:35 +0000 (13:07 +0900)]
Rollup merge of #83066 - Seppel3210:master, r=joshtriplett

Add `reverse` search alias for Iterator::rev()

When searching for "reverse" in rustdoc you can't find the rev method on Iterator so here is a search alias for that.

3 years agoRollup merge of #82943 - kornelski:threadstdio, r=joshtriplett
Yuki Okushi [Sun, 14 Mar 2021 04:07:34 +0000 (13:07 +0900)]
Rollup merge of #82943 - kornelski:threadstdio, r=joshtriplett

Demonstrate best practice for feeding stdin of a child processes

Documentation change.

It's possible to create a deadlock with stdin/stdout I/O on a single thread:

* the child process may fill its stdout buffer, and have to wait for the parent process to read it,
* but the parent process may be waiting until its stdin write finishes before reading the stdout.

Therefore, the parent process should use separate threads for writing and reading.

These examples are not deadlocking in practice, because they use short strings, but I think it's better to demonstrate code that works even for long writes. The problem is non-obvious and tricky to debug (it seems that even libstd has a similar issue: #45572).

This also demonstrates how to use stdio with threads: it's not obvious that `.take()` can be used to avoid fighting with the borrow checker.

I've checked that the modified examples run fine.

3 years agoRollup merge of #82804 - alexcrichton:fix-wasi, r=pnkfelix
Yuki Okushi [Sun, 14 Mar 2021 04:07:33 +0000 (13:07 +0900)]
Rollup merge of #82804 - alexcrichton:fix-wasi, r=pnkfelix

std: Fix a bug on the wasm32-wasi target opening files

This commit fixes an issue pointed out in #82758 where LTO changed the
behavior of a program. It turns out that LTO was not at fault here, it
simply uncovered an existing bug. The bindings to
`__wasilibc_find_relpath` assumed that the relative portion of the path
returned was always contained within thee input `buf` we passed in. This
isn't actually the case, however, and sometimes the relative portion of
the path may reference a sub-portion of the input string itself.

The fix here is to use the relative path pointer coming out of
`__wasilibc_find_relpath` as the source of truth. The `buf` used for
local storage is discarded in this function and the relative path is
copied out unconditionally. We might be able to get away with some
`Cow`-like business or such to avoid the extra allocation, but for now
this is probably the easiest patch to fix the original issue.

3 years agoRollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomez
Yuki Okushi [Sun, 14 Mar 2021 04:07:32 +0000 (13:07 +0900)]
Rollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomez

Rename `rustdoc` to `rustdoc::all`

When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like

```
warning: unknown lint: `rustdoc`
```

The lint group still worked when rustdoc ran, since rustdoc added the group itself.

This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints.

Follow-up to #80527.
r? ``@Manishearth``

3 years agoRollup merge of #82789 - csmoe:issue-82772, r=estebank
Yuki Okushi [Sun, 14 Mar 2021 04:07:31 +0000 (13:07 +0900)]
Rollup merge of #82789 - csmoe:issue-82772, r=estebank

Get with field index from pattern slice instead of directly indexing

Closes #82772
r? ``@estebank``

https://github.com/rust-lang/rust/pull/82789#issuecomment-796921977
> ``@estebank`` So the real cause is we only generate single pattern for Box here
https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1130-L1132
But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds.
https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1346

3 years agoRollup merge of #82617 - camelid:everybody_loops-docs, r=jyn514
Yuki Okushi [Sun, 14 Mar 2021 04:07:30 +0000 (13:07 +0900)]
Rollup merge of #82617 - camelid:everybody_loops-docs, r=jyn514

Document `everybody_loops`

cc `@jyn514`

3 years agoRollup merge of #82121 - lopopolo:pathbuf-osstring-extend, r=joshtriplett
Yuki Okushi [Sun, 14 Mar 2021 04:07:28 +0000 (13:07 +0900)]
Rollup merge of #82121 - lopopolo:pathbuf-osstring-extend, r=joshtriplett

Implement Extend and FromIterator for OsString

Add the following trait impls:

- `impl Extend<OsString> for OsString`
- `impl<'a> Extend<&'a OsStr> for OsString`
- `impl FromIterator<OsString> for OsString`
- `impl<'a> FromIterator<&'a OsStr> for OsString`

Because `OsString` is a platform string with no particular semantics, concatenating them together seems acceptable.

I came across a use case for these trait impls in https://github.com/artichoke/artichoke/pull/1089:

Artichoke is a Ruby interpreter. Its CLI accepts multiple `-e` switches for executing inline Ruby code, like:

```console
$ cargo -q run --bin artichoke -- -e '2.times {' -e 'puts "foo: #{__LINE__}"' -e '}'
foo: 2
foo: 2
```

I use `clap` for command line argument parsing, which collects these `-e` commands into a `Vec<OsString>`. To pass these commands to the interpreter for `Eval`, I need to join them together. Combining these impls with `Iterator::intersperse` https://github.com/rust-lang/rust/issues/79524 would enable me to build a single bit of Ruby code.

Currently, I'm doing something like:

```rust
let mut commands = commands.into_iter();
let mut buf = if let Some(command) = commands.next() {
    command
} else {
    return Ok(Ok(()));
};
for command in commands {
    buf.push("\n");
    buf.push(command);
}
```

If there's interest, I'd also like to add impls for `Cow<'a, OsStr>`, which would avoid allocating the `"\n"` `OsString` in the concatenate + intersperse use case.

3 years agoRollup merge of #81465 - joshtriplett:duration-formatting-documentation, r=m-ou-se
Yuki Okushi [Sun, 14 Mar 2021 04:07:27 +0000 (13:07 +0900)]
Rollup merge of #81465 - joshtriplett:duration-formatting-documentation, r=m-ou-se

Add documentation about formatting `Duration` values

Explain why Duration has a Debug impl but not a Display impl, and
mention the use of Unicode.

3 years agobless tests
Erik Desjardins [Sun, 14 Mar 2021 04:04:38 +0000 (23:04 -0500)]
bless tests

3 years agoUpdate `rustdoc-ui` versions of the `doc-attr` test
Camelid [Sun, 14 Mar 2021 00:36:38 +0000 (16:36 -0800)]
Update `rustdoc-ui` versions of the `doc-attr` test

It seems there are two copies of it: one in `src/test/ui/attributes/`
and one in `src/test/rustdoc-ui/`. I'm guessing this is to test that the
lint is emitted both when you run the compiler and when you run rustdoc.

3 years agoAdd hyphen to "crate level"
Camelid [Sat, 13 Mar 2021 22:32:06 +0000 (14:32 -0800)]
Add hyphen to "crate level"

"crate level attribute" -> "crate-level attribute"

3 years agoDo not emit alloca for ZST local even if it is uninitialized
Simon Vandel Sillesen [Sun, 3 Jan 2021 14:45:15 +0000 (15:45 +0100)]
Do not emit alloca for ZST local even if it is uninitialized

3 years agoMove ZST check inside UsedLocals
Simon Vandel Sillesen [Sun, 3 Jan 2021 13:51:24 +0000 (14:51 +0100)]
Move ZST check inside UsedLocals

3 years agoExtend SimplifyLocals to remove ZST writes
Simon Vandel Sillesen [Tue, 29 Dec 2020 22:32:31 +0000 (23:32 +0100)]
Extend SimplifyLocals to remove ZST writes

3 years agoAdd another test case
Camelid [Fri, 12 Mar 2021 20:27:52 +0000 (12:27 -0800)]
Add another test case

3 years agoReport error for each invalid nested attribute
Camelid [Thu, 11 Mar 2021 23:41:51 +0000 (15:41 -0800)]
Report error for each invalid nested attribute

3 years agoDocument `everybody_loops`
Camelid [Sun, 28 Feb 2021 03:36:37 +0000 (19:36 -0800)]
Document `everybody_loops`

3 years agoLint non-meta doc attributes
Camelid [Sat, 13 Mar 2021 21:25:27 +0000 (13:25 -0800)]
Lint non-meta doc attributes

E.g., `#[doc(123)]`.

3 years agoRefactor `check_doc_attrs` body
Camelid [Sat, 13 Mar 2021 21:13:27 +0000 (13:13 -0800)]
Refactor `check_doc_attrs` body

This change makes it easier to follow the control flow.

I also moved the end-of-line comments attached to some symbols to before
the symbol listing. This allows rustfmt to format the code; otherwise no
formatting occurs (see rust-lang/rustfmt#4750).

3 years agoAdd documentation about formatting `Duration` values
Josh Triplett [Thu, 28 Jan 2021 08:51:31 +0000 (00:51 -0800)]
Add documentation about formatting `Duration` values

Explain why Duration has a Debug impl but not a Display impl, and
mention the use of Unicode.

3 years agoAuto merge of #83064 - cjgillot:fhash, r=jackh726
bors [Sat, 13 Mar 2021 20:21:40 +0000 (20:21 +0000)]
Auto merge of #83064 - cjgillot:fhash, r=jackh726

Tweaks to stable hashing

3 years agocrates.js should use root_path and not static_root_path
Guillaume Gomez [Sat, 13 Mar 2021 20:21:03 +0000 (21:21 +0100)]
crates.js should use root_path and not static_root_path

3 years agoAvoid sorting predicates by `DefId`
Aaron Hill [Fri, 12 Mar 2021 22:53:02 +0000 (17:53 -0500)]
Avoid sorting predicates by `DefId`

Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.

3 years agoAuto merge of #83007 - Aaron1011:incr-verify-default, r=Mark-Simulacrum
bors [Sat, 13 Mar 2021 17:52:22 +0000 (17:52 +0000)]
Auto merge of #83007 - Aaron1011:incr-verify-default, r=Mark-Simulacrum

Turn `-Z incremental-verify-ich` on by default

Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.

3 years agoAlways run `incremental_verify_ich` when re-computing query results
Aaron Hill [Thu, 11 Mar 2021 06:12:07 +0000 (01:12 -0500)]
Always run `incremental_verify_ich` when re-computing query results

Issue #82920 showed that the kind of bugs caught by this flag have
soundness implications.

This causes performance regressions of up to 15.2% during incremental
compilation, but this is necessary to catch miscompilations caused by
bugs in query implementations.

3 years agoUse only x86_64 flag
Hiroki Noda [Fri, 12 Mar 2021 10:46:17 +0000 (19:46 +0900)]
Use only x86_64 flag

3 years agoAuto merge of #83069 - tgnottingham:simplify-query-cache-iter, r=cjgillot
bors [Sat, 13 Mar 2021 15:11:25 +0000 (15:11 +0000)]
Auto merge of #83069 - tgnottingham:simplify-query-cache-iter, r=cjgillot

rustc_query_system: simplify QueryCache::iter

Minor cleanup to reduce a small amount of complexity and code bloat.
Reduces the number of mono items in rustc_query_impl by 15%.

3 years agoIterate on crate_inherent_impls for metadata.
Camille GILLOT [Sat, 13 Mar 2021 13:17:55 +0000 (14:17 +0100)]
Iterate on crate_inherent_impls for metadata.

3 years agoAuto merge of #82891 - cjgillot:monoparent, r=petrochenkov
bors [Sat, 13 Mar 2021 12:28:04 +0000 (12:28 +0000)]
Auto merge of #82891 - cjgillot:monoparent, r=petrochenkov

Make def_key and HIR parenting consistent.

r? `@petrochenkov`

3 years agoAdd regression tests
hyd-dev [Sat, 13 Mar 2021 11:14:57 +0000 (19:14 +0800)]
Add regression tests

3 years agoFix panic message of `assert_failed_inner`
hyd-dev [Sat, 13 Mar 2021 10:50:43 +0000 (18:50 +0800)]
Fix panic message of `assert_failed_inner`

3 years agoAuto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis
bors [Sat, 13 Mar 2021 09:47:07 +0000 (09:47 +0000)]
Auto merge of #82878 - sexxi-goose:repr_packed, r=nikomatsakis

2229: Handle capturing a reference into a repr packed struct

RFC 1240 states that it is unsafe to capture references into a
packed-struct. This PR ensures that when a closure captures a precise
path, we aren't violating this safety constraint.

To acheive so we restrict the capture precision to the struct itself.

An interesting edge case where we decided to restrict precision:
```rust
struct Foo(String);

let foo: Foo;
let c = || {
    println!("{}", foo.0);
    let x = foo.0;
}
```

Given how closures get desugared today, foo.0 will be moved into the
closure, making the `println!`, safe. However this can be very subtle
and also will be unsafe if the closure gets inline.

Closes: https://github.com/rust-lang/project-rfc-2229/issues/33
r? `@nikomatsakis`

3 years agoAdd `reverse` search alias for Iterator::rev()
Sebastian Widua [Sat, 13 Mar 2021 00:09:53 +0000 (01:09 +0100)]
Add `reverse` search alias for Iterator::rev()

3 years agoAuto merge of #82760 - WaffleLapkin:unleak_extend_from_within, r=kennytm
bors [Sat, 13 Mar 2021 07:06:01 +0000 (07:06 +0000)]
Auto merge of #82760 - WaffleLapkin:unleak_extend_from_within, r=kennytm

Fix leak in Vec::extend_from_within

Fixes #82533

3 years agoAuto merge of #82436 - osa1:issue80258, r=nikomatsakis
bors [Sat, 13 Mar 2021 04:38:39 +0000 (04:38 +0000)]
Auto merge of #82436 - osa1:issue80258, r=nikomatsakis

Allow calling *const methods on *mut values

This allows `*const` methods to be called on `*mut` values.

TODOs:

- [x] ~~Remove debug logs~~ Done.
- [x] ~~I haven't tested, but I think this currently won't work when the `self` value has type like `&&&&& *mut X` because I don't do any autoderefs when probing. To fix this the new code in `rustc_typeck::check::method::probe` needs to reuse `pick_method` somehow as I think that's the function that autoderefs.~~ This works, because autoderefs are done before calling `pick_core`, in `method_autoderef_steps`, called by `probe_op`.
- [x] ~~I should probably move the new `Pick` to `pick_autorefd_method`. If not, I should move it to its own function.~~ Done.
- [ ] ~~Test this with a `Pick` with `to_ptr = true` and `unsize = true`.~~ I think this case cannot happen, because we don't have any array methods with `*mut [X]` receiver. I should confirm that this is true and document this. I've placed two assertions about this.
- [x] ~~Maybe give `(Mutability, bool)` a name and fields~~ I now have a `to_const_ptr` field in `Pick`.
- [x] ~~Changes in `adjust_self_ty` is quite hacky. The problem is we can't deref a pointer, and even if we don't have an adjustment to get the address of a value, so to go from `*mut` to `*const` we need a special case.~~ There's still a special case for `to_const_ptr`, but I'm not sure if we can avoid this.
- [ ] Figure out how `reached_raw_pointer` stuff is used. I suspect only for error messages.

Fixes #80258

3 years agoUpdate cargo
Eric Huss [Sat, 13 Mar 2021 02:10:17 +0000 (18:10 -0800)]
Update cargo

3 years agoAuto merge of #83067 - JohnTitor:rollup-0wo338i, r=JohnTitor
bors [Sat, 13 Mar 2021 02:08:33 +0000 (02:08 +0000)]
Auto merge of #83067 - JohnTitor:rollup-0wo338i, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #82984 (Simplify ast block lowering)
 - #83012 (Update Clippy)
 - #83020 (Emit the enum range assumption if the range only contains one element)
 - #83037 (Support merge_functions option in NewPM since LLVM >= 12)
 - #83052 (updated vulnerable deps)
 - #83059 (Allow configuring `rustdoc --disable-minification` in config.toml)

Failed merges:

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

3 years agorustc_query_system: simplify QueryCache::iter
Tyson Nottingham [Thu, 11 Mar 2021 19:22:47 +0000 (11:22 -0800)]
rustc_query_system: simplify QueryCache::iter

Minor cleanup to reduce a small amount of complexity and code bloat.
Reduces the number of mono items in rustc_query_impl by 15%.

3 years agoRollup merge of #83059 - notriddle:config-toml-disable-minification, r=Mark-Simulacrum
Yuki Okushi [Sat, 13 Mar 2021 00:44:47 +0000 (09:44 +0900)]
Rollup merge of #83059 - notriddle:config-toml-disable-minification, r=Mark-Simulacrum

Allow configuring `rustdoc --disable-minification` in config.toml

This way, you can debug rustdoc's JavaScript and CSS file with normal F12 Dev Tools and you'll have useful line numbers to work with.

3 years agoRollup merge of #83052 - klensy:dep-update, r=Mark-Simulacrum
Yuki Okushi [Sat, 13 Mar 2021 00:44:46 +0000 (09:44 +0900)]
Rollup merge of #83052 - klensy:dep-update, r=Mark-Simulacrum

updated vulnerable deps

* Updated signal-hook-registry 1.2.1 to 1.2.2, as it drops dependency on vulnerable arc-swap 0.4.7 https://rustsec.org/advisories/RUSTSEC-2020-0091
* Updated generic-array 0.12.3 to 0.12.4, vuln https://rustsec.org/advisories/RUSTSEC-2020-0146
* Updated sized-chunks 0.6.2 to 0.6.4, vuln https://rustsec.org/advisories/RUSTSEC-2020-0041 fixed in 0.6.3, in 0.6.4 fixed some UB https://github.com/bodil/sized-chunks/blob/master/CHANGELOG.md#064---2021-02-17

3 years agoRollup merge of #83037 - kubo39:merge-functions-in-llvm-new-pass-manager, r=nikic
Yuki Okushi [Sat, 13 Mar 2021 00:44:45 +0000 (09:44 +0900)]
Rollup merge of #83037 - kubo39:merge-functions-in-llvm-new-pass-manager, r=nikic

Support merge_functions option in NewPM since LLVM >= 12

now we can pass this flag since https://reviews.llvm.org/D93002 has been merged.

3 years agoRollup merge of #83020 - hi-rustin:rustin-patch-enum, r=lcnr
Yuki Okushi [Sat, 13 Mar 2021 00:44:44 +0000 (09:44 +0900)]
Rollup merge of #83020 - hi-rustin:rustin-patch-enum, r=lcnr

Emit the enum range assumption if the range only contains one element

close https://github.com/rust-lang/rust/issues/82871

3 years agoRollup merge of #83012 - flip1995:clippyup, r=Manishearth
Yuki Okushi [Sat, 13 Mar 2021 00:44:43 +0000 (09:44 +0900)]
Rollup merge of #83012 - flip1995:clippyup, r=Manishearth

Update Clippy

Bi-weekly Clippy sync.

r? ``@Manishearth``

3 years agoRollup merge of #82984 - camsteffen:lower-block, r=cjgillot
Yuki Okushi [Sat, 13 Mar 2021 00:44:42 +0000 (09:44 +0900)]
Rollup merge of #82984 - camsteffen:lower-block, r=cjgillot

Simplify ast block lowering

3 years agoAuto merge of #83022 - m-ou-se:mem-replace-no-swap, r=nagisa
bors [Fri, 12 Mar 2021 23:27:23 +0000 (23:27 +0000)]
Auto merge of #83022 - m-ou-se:mem-replace-no-swap, r=nagisa

Don't implement mem::replace with mem::swap.

`swap` is a complicated operation, so this changes the implementation of `replace` to use `read` and `write` instead.

See https://github.com/rust-lang/rust/pull/83019.

I wrote there:

> Implementing the simpler operation (replace) with the much more complicated operation (swap) doesn't make a whole lot of sense. `replace` is just read+write, and the primitive for moving out of a `&mut`. `swap` is for doing that to *two* `&mut` at the same time, which is both more niche and more complicated (as shown by `swap_nonoverlapping_bytes`).

This could be especially interesting for `Option<VeryLargeStruct>::take()`, since swapping such a large structure with `swap_nonoverlapping_bytes` is going to be much less efficient than `ptr::write()`'ing a `None`.

But also for small values where `swap` just reads/writes using temporary variable, this makes a `replace` or `take` operation simpler:
![image](https://user-images.githubusercontent.com/783247/110839393-c7e6bd80-82a3-11eb-97b7-28acb14deffd.png)

3 years agoMake docs-minification default to true
Michael Howell [Fri, 12 Mar 2021 22:03:54 +0000 (15:03 -0700)]
Make docs-minification default to true

3 years agoMake def_key and HIR parenting consistent.
Camille GILLOT [Sat, 13 Feb 2021 19:41:02 +0000 (20:41 +0100)]
Make def_key and HIR parenting consistent.

3 years agoImprove the wording for the `can't reassign` error
Yuki Okushi [Fri, 12 Mar 2021 20:56:30 +0000 (05:56 +0900)]
Improve the wording for the `can't reassign` error

3 years agoAdd a `disable-minification` option for rustdoc
Michael Howell [Fri, 12 Mar 2021 18:41:46 +0000 (11:41 -0700)]
Add a `disable-minification` option for rustdoc

This way, you can debug rustdoc's JavaScript and CSS file
with normal F12 Dev Tools and you'll have useful line numbers
to work with.

3 years agoAuto merge of #83024 - Xanewok:update-rls, r=Dylan-DPC
bors [Fri, 12 Mar 2021 16:57:11 +0000 (16:57 +0000)]
Auto merge of #83024 - Xanewok:update-rls, r=Dylan-DPC

Update RLS

Fixes #82932

r? `@ghost`

3 years agoClippy: HACK! Fix bootstrap error
flip1995 [Fri, 12 Mar 2021 14:32:04 +0000 (15:32 +0100)]
Clippy: HACK! Fix bootstrap error

This will be removed in the next sync, once beta is at 1.52. Until then
this hack avoids to put `cfg(bootstrap)` into Clippy.

3 years agoUpdate Cargo.lock
flip1995 [Fri, 12 Mar 2021 14:31:11 +0000 (15:31 +0100)]
Update Cargo.lock

3 years agoMerge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
flip1995 [Fri, 12 Mar 2021 14:30:50 +0000 (15:30 +0100)]
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup