]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoIntroduced `Cursor::next_with_spacing_ref`.
Nicholas Nethercote [Thu, 21 Apr 2022 03:49:40 +0000 (13:49 +1000)]
Introduced `Cursor::next_with_spacing_ref`.

This lets us clone just the parts within a `TokenTree` that need
cloning, rather than the entire thing. This is a surprisingly large
performance win, up to 4% on `async-std-1.10.0`.

2 years agoProduce `CloseDelim` and pop the stack at the same time.
Nicholas Nethercote [Thu, 21 Apr 2022 02:26:58 +0000 (12:26 +1000)]
Produce `CloseDelim` and pop the stack at the same time.

This makes `CloseDelim` handling more like `OpenDelim` handling, which
produces `OpenDelim` and pushes the stack at the same time. It requires
some adjustment to `parse_token_tree` now that we don't remain within
the frame after getting the `CloseDelim`.

2 years agoAvoid some tuple destructuring.
Nicholas Nethercote [Wed, 20 Apr 2022 06:34:33 +0000 (16:34 +1000)]
Avoid some tuple destructuring.

Surprisingly, this is a non-trivial performance win.

2 years agoRemove `Eof` sanity check in `Parser::inlined_bump_with`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:52:54 +0000 (14:52 +1000)]
Remove `Eof` sanity check in `Parser::inlined_bump_with`.

A Google search of the error message fails to return any relevant
resuts, suggesting this has never occurred in practice. And removeing it
reduces instruction counts by up to 2% on some benchmarks.

2 years agoInline `Parser::nonterminal_may_begin_with`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:13:49 +0000 (14:13 +1000)]
Inline `Parser::nonterminal_may_begin_with`.

2 years agoInline `Parser::parse_nonterminal`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:08:59 +0000 (14:08 +1000)]
Inline `Parser::parse_nonterminal`.

2 years agoOnly record `fallback_span` when necessary.
Nicholas Nethercote [Wed, 20 Apr 2022 04:04:22 +0000 (14:04 +1000)]
Only record `fallback_span` when necessary.

2 years agoInline `Cursor::next_with_spacing`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:43:25 +0000 (12:43 +1000)]
Inline `Cursor::next_with_spacing`.

2 years agoRemove the loop from `Parser::bump()`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:22:42 +0000 (12:22 +1000)]
Remove the loop from `Parser::bump()`.

The loop is there to handle a `NoDelim` open/close token. This commit
changes `TokenCursor::inlined_next` so it never returns such a token.
This is a performance win because the conditional test in `bump()` is
removed.

If the parser needs changing in the future to handle `NoDelim` tokens,
then `inlined_next()` can easily be changed to return them.

2 years agoRemove `TokenCursorFrame::open_delim`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:22:03 +0000 (12:22 +1000)]
Remove `TokenCursorFrame::open_delim`.

Because it's now always true.

2 years agoUse `true` for `open_delim`/`close_delim` in one spot.
Nicholas Nethercote [Wed, 20 Apr 2022 01:49:15 +0000 (11:49 +1000)]
Use `true` for `open_delim`/`close_delim` in one spot.

The `DelimToken` here is `NoDelim`, which means the returned delim
tokens will just be ignored by `Parser::bump()`. This commit changes
things so the delim tokens won't be returned.

2 years agoAdd a size assertion for `Parser`.
Nicholas Nethercote [Tue, 19 Apr 2022 23:31:34 +0000 (09:31 +1000)]
Add a size assertion for `Parser`.

2 years agoMove desugaring code into its own function.
Nicholas Nethercote [Tue, 19 Apr 2022 07:01:26 +0000 (17:01 +1000)]
Move desugaring code into its own function.

It's not hot, so shouldn't be within the always inlined part.

2 years agoHandle `Delimited` opening immediately.
Nicholas Nethercote [Tue, 19 Apr 2022 03:53:05 +0000 (13:53 +1000)]
Handle `Delimited` opening immediately.

Instead of letting the next iteration of the loop handle it.

2 years agoAdd {open,close}_delim arguments to `TokenCursorFrame::new()`.
Nicholas Nethercote [Tue, 19 Apr 2022 03:51:12 +0000 (13:51 +1000)]
Add {open,close}_delim arguments to `TokenCursorFrame::new()`.

This will facilitate the change in the next commit.

`boolean` arguments aren't great, but the function is only used in three
places within this one file.

2 years agoRearrange `TokenCursor::inlined_next()`.
Nicholas Nethercote [Tue, 19 Apr 2022 03:41:02 +0000 (13:41 +1000)]
Rearrange `TokenCursor::inlined_next()`.

In particular, avoid wrapping a token within `TokenTree::Token` and then
immediately matching it and returning the token within. Just return the
token immediately.

2 years agoMerge `TokenCursor::{next,next_desugared}`.
Nicholas Nethercote [Tue, 19 Apr 2022 01:36:13 +0000 (11:36 +1000)]
Merge `TokenCursor::{next,next_desugared}`.

And likewise for the inlined variants.

I did this for simplicity, but interesting it was a performance win as
well.

2 years agoInline and remove `Parser::next_tok()`.
Nicholas Nethercote [Thu, 14 Apr 2022 01:13:20 +0000 (11:13 +1000)]
Inline and remove `Parser::next_tok()`.

It has a single call site.

2 years agoInline and remove `TokenTree::{open_tt,close_tt}`.
Nicholas Nethercote [Wed, 13 Apr 2022 06:18:01 +0000 (16:18 +1000)]
Inline and remove `TokenTree::{open_tt,close_tt}`.

They both have a single call site.

2 years agoTweak `Cursor::next_with_spacing`.
Nicholas Nethercote [Tue, 19 Apr 2022 04:15:30 +0000 (14:15 +1000)]
Tweak `Cursor::next_with_spacing`.

This makes it more like `CursorRef::next_with_spacing`. There is no
performance effect, just a consistency improvement.

2 years agoAuto merge of #96178 - Dylan-DPC:rollup-6z8pcob, r=Dylan-DPC
bors [Mon, 18 Apr 2022 18:29:46 +0000 (18:29 +0000)]
Auto merge of #96178 - Dylan-DPC:rollup-6z8pcob, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #96032 (Update books)
 - #96136 (Reword clarification on lifetime for ptr->ref safety docs)
 - #96143 (Fix snapshot --bless not working anymore in htmldocck)
 - #96148 (Use revisions instead of nll compare mode for `/self/` ui tests)
 - #96156 (Replace u8to64_le macro with u64::from_le_bytes)

Failed merges:

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

2 years agoRollup merge of #96156 - est31:use_from_le_bytes, r=Dylan-DPC
Dylan DPC [Mon, 18 Apr 2022 16:22:07 +0000 (18:22 +0200)]
Rollup merge of #96156 - est31:use_from_le_bytes, r=Dylan-DPC

Replace u8to64_le macro with u64::from_le_bytes

The macro was a reimplementation of the function.

2 years agoRollup merge of #96148 - marmeladema:nll-revisions-self, r=jackh726
Dylan DPC [Mon, 18 Apr 2022 16:22:06 +0000 (18:22 +0200)]
Rollup merge of #96148 - marmeladema:nll-revisions-self, r=jackh726

Use revisions instead of nll compare mode for `/self/` ui tests

r? ``@jackh726``

2 years agoRollup merge of #96143 - Urgau:rustdoc-fix-snapshot-bless, r=GuillaumeGomez
Dylan DPC [Mon, 18 Apr 2022 16:22:05 +0000 (18:22 +0200)]
Rollup merge of #96143 - Urgau:rustdoc-fix-snapshot-bless, r=GuillaumeGomez

Fix snapshot --bless not working anymore in htmldocck

I broke it in https://github.com/rust-lang/rust/pull/95933

r? ```@GuillaumeGomez```

2 years agoRollup merge of #96136 - thomcc:lifetime-wording, r=RalfJung
Dylan DPC [Mon, 18 Apr 2022 16:22:04 +0000 (18:22 +0200)]
Rollup merge of #96136 - thomcc:lifetime-wording, r=RalfJung

Reword clarification on lifetime for ptr->ref safety docs

I believe the current wording of the safety comment is somewhat misleading, and that this is more accurate. Suggested by `@CAD97` in this thread on the topic https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Lifetime.20of.20reference.20pointer.20docs.20issue

Just to check that this is correct, CC `@RalfJung.`

I suppose it's open for interpretation as to whether or not this is more clear. I think it is.

2 years agoRollup merge of #96032 - ehuss:update-books, r=ehuss
Dylan DPC [Mon, 18 Apr 2022 16:22:04 +0000 (18:22 +0200)]
Rollup merge of #96032 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in 11f1165e8a2f5840467e748c8108dc53c948ee9a..c7d8467ca9158da58ef295ae65dbf00a308752d9
2022-03-19 16:02:00 -0400 to 2022-04-06 14:26:54 +0900
- Change "writers" to "readers" for Deref. (rust-lang/nomicon#346)

## reference

7 commits in c97d14fa6fed0baa9255432b8a93cb70614f80e3..b5f6c2362baf932db9440fbfcb509b309237ee85
2022-03-19 18:18:10 -0700 to 2022-04-10 19:19:51 -0700
- Fix typo: `?` should be inside `<sup>` tags (rust-lang/reference#1190)
- Update aarch64 to use neon as fp (rust-lang/reference#1184)
- Boolean literal expressions (rust-lang/reference#1189)
- Document that unary negation of a signed integer literal cannot cause an overflow error (rust-lang/reference#1188)
- Document compatibility between declarative and procedural macro tokens (rust-lang/reference#1169)
- Document native library modifier syntax and the `whole-archive` modifier specifically (rust-lang/reference#1170)
- Numeric literal expressions and literal suffixes (rust-lang/reference#1177)

## book

8 commits in ea90bbaf53ba64ef4e2da9ac2352b298aec6bec8..765318b844569a642ceef7bf1adab9639cbf6af3
2022-03-28 21:59:34 -0400 to 2022-04-12 21:14:47 -0400
- Propagate nostarch edits to src
- Propagate updated test example code to nostarch snapshot
- Edits to nostarch edits
- edits from nostarch
- Fix error message for the example code
- update ch13-02 to reflect changes in rust-lang/book#2797
- Update to 1.59
- Edits to chapter 2 after tech review

## rust-by-example

4 commits in ec954f35eedf592cd173b21c05a7f80a65b61d8a..c2a98d9fc5d29c481d42052fbeccfde15ed03116
2022-03-22 11:09:06 -0300 to 2022-04-08 06:44:18 -0300
- Code highlight a variable (rust-lang/rust-by-example#1530)
- Add a comment to note that warnings may not be shown in a browser in the Variable Bindings section (rust-lang/rust-by-example#1529)
- Make all new types have UpperCamelCase names in code example in the Aliasing section (rust-lang/rust-by-example#1528)
- Replace `C` with C/C++ (rust-lang/rust-by-example#1527)

## rustc-dev-guide

6 commits in 155126b1d2e2cb01ddb1d7ba9489b90d7cd173ad..eeb5a83c15b6ae60df3e4f19207376b22c6fbc4c
2022-03-22 14:34:21 +0100 to 2022-04-11 23:29:48 +0900
- method-lookup.md improvements (rust-lang/rustc-dev-guide#1296)
- Consolidate crates.io convention section (rust-lang/rustc-dev-guide#1326)
- Update examples with 1.61.0-nightly (latest version) (rust-lang/rustc-dev-guide#1330)
- r-a: Use `python3 x.py` instead of `./x.py` (rust-lang/rustc-dev-guide#1335)
- Update miri.md: correct a minor typo (rust-lang/rustc-dev-guide#1334)
- Add example how lints can be feature gated

2 years agoAuto merge of #95906 - jyn514:enforce-valid-paths, r=Mark-Simulacrum
bors [Mon, 18 Apr 2022 16:06:44 +0000 (16:06 +0000)]
Auto merge of #95906 - jyn514:enforce-valid-paths, r=Mark-Simulacrum

Require all paths passed to `ShouldRun::paths` to exist on disk

This has two benefits:
1. There is a clearer mental model of how bootstrap works. Steps correspond to paths on disk unless it's strictly impossible for them to do so (e.g. dist components).
2. Bootstrap has better checks for internal consistency. This caught several issues:
  - `src/sanitizers` doesn't exist; I changed it to just be a `sanitizers` alias.
  - `src/tools/lld` doesn't exist; I removed it, since `lld` alone already works.
  - `src/llvm` doesn't exist; removed it since `llvm` and `src/llvm-project` both work.
  - `src/lldb_batchmode.py` doesn't exist, it was moved to `src/etc`.
  - `install` was still using `src/librustc` instead of `compiler/rustc`.
  - None of the tools in `dist` / `install` allowed using `src/tools/X` to build them. This might be intentional - I can change them to aliases if you like.

Builds on https://github.com/rust-lang/rust/pull/95901 and should not be merged before.

2 years agoAuto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieu
bors [Mon, 18 Apr 2022 12:15:39 +0000 (12:15 +0000)]
Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieu

Use a single ReentrantMutex implementation on all platforms.

This replaces all platform specific ReentrantMutex implementations by the one I added in #95727 for Linux, since that one does not depend on any platform specific details.

r? `@Amanieu`

2 years agoRemove forgotten reexport of ReentrantMutex in sys::unsupported.
Mara Bos [Mon, 18 Apr 2022 11:10:36 +0000 (13:10 +0200)]
Remove forgotten reexport of ReentrantMutex in sys::unsupported.

2 years agoAuto merge of #96080 - nikic:ranlib, r=Mark-Simulacrum
bors [Mon, 18 Apr 2022 09:58:22 +0000 (09:58 +0000)]
Auto merge of #96080 - nikic:ranlib, r=Mark-Simulacrum

Respect ranlib specified for target during LLVM build

The ranlib specified for the target was never actually transferred
into the builder configuration. In the dist-x86_64-linux build we
ended up using ranlib instead of llvm-ranlib.

Found this investigating a build failure in #94214.

2 years agoAuto merge of #96113 - mixi:libressl-3.4.x, r=Mark-Simulacrum
bors [Mon, 18 Apr 2022 07:24:55 +0000 (07:24 +0000)]
Auto merge of #96113 - mixi:libressl-3.4.x, r=Mark-Simulacrum

Add support for LibreSSL 3.4.x

This updates the `openssl` and `openssl-sys` crates to support building
the toolchain with system libraries up to LibreSSL 3.4.x.

LibreSSL 3.4.0 has been supported since `openssl-sys` version 0.9.67,
LibreSSL 3.4.x since `openssl-sys` 0.9.72.

2 years agoAuto merge of #96000 - jyn514:faster-doctests, r=Mark-Simulacrum
bors [Mon, 18 Apr 2022 04:15:26 +0000 (04:15 +0000)]
Auto merge of #96000 - jyn514:faster-doctests, r=Mark-Simulacrum

Make `x test --stage 2 compiler/rustc_XXX` faster to run

Previously, bootstrap unconditionally rebuilt the stage 2 compiler,
even if it had previously built stage 1. This changes it to reuse stage 1 if possible.
In particular, it no longer runs the following step:
```
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) -> x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu))
```

2 years agoAuto merge of #95695 - the8472:vec-codegen-tests, r=Mark-Simulacrum
bors [Mon, 18 Apr 2022 02:04:12 +0000 (02:04 +0000)]
Auto merge of #95695 - the8472:vec-codegen-tests, r=Mark-Simulacrum

Add codegen tests for additional cases where noop iterators get optimized away

Optimizations have improved over time and now LLVM manages to optimize more in-place-collect noop-iterators to O(1) functions. This updates the codegen test to match.

Many but not all cases reported in #79308 work now.

2 years agoAuto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitor
bors [Sun, 17 Apr 2022 22:54:55 +0000 (22:54 +0000)]
Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitor

fix error handling for pthread_sigmask(3)

Errors from `pthread_sigmask(3)` were handled using `cvt()`, which expects a return value of `-1` on error and uses `errno`.
However, `pthread_sigmask(3)` returns `0` on success and an error number otherwise.

Fix it by replacing `cvt()` with `cvt_nz()`.

2 years agoReplace u8to64_le macro with u64::from_le_bytes
est31 [Sun, 17 Apr 2022 20:51:13 +0000 (22:51 +0200)]
Replace u8to64_le macro with u64::from_le_bytes

The macro was a reimplementation of the function.

2 years agoAuto merge of #96139 - erikdesjardins:revertinl2, r=Mark-Simulacrum
bors [Sun, 17 Apr 2022 20:32:08 +0000 (20:32 +0000)]
Auto merge of #96139 - erikdesjardins:revertinl2, r=Mark-Simulacrum

Revert: Make TLS __getit #[inline(always)] on non-Windows

re #96132

r? `@Mark-Simulacrum`

2 years agoAuto merge of #96091 - GuillaumeGomez:duplicated-blanket-impls, r=notriddle
bors [Sun, 17 Apr 2022 18:14:16 +0000 (18:14 +0000)]
Auto merge of #96091 - GuillaumeGomez:duplicated-blanket-impls, r=notriddle

Fix rustdoc duplicated blanket impls

Fixes #96036.

I think it'll not be great performance-wise but I couldn't find another way to prevent that unfortunately...

r? `@notriddle`

2 years agoAdd regression test for rustdoc duplicated blanket impls
Guillaume Gomez [Fri, 15 Apr 2022 19:53:02 +0000 (21:53 +0200)]
Add regression test for rustdoc duplicated blanket impls

2 years agoFix rustdoc duplicated blanket impls issue
Guillaume Gomez [Fri, 15 Apr 2022 19:52:43 +0000 (21:52 +0200)]
Fix rustdoc duplicated blanket impls issue

2 years agoUse revisions instead of nll compare mode for `/self/` ui tests
marmeladema [Sun, 17 Apr 2022 13:39:25 +0000 (15:39 +0200)]
Use revisions instead of nll compare mode for `/self/` ui tests

2 years agoAuto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov
bors [Sun, 17 Apr 2022 12:56:19 +0000 (12:56 +0000)]
Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov

Report undeclared lifetimes during late resolution.

First step in https://github.com/rust-lang/rust/pull/91557

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`

2 years agoFix --bless not working anymore in htmldocck
Loïc BRANSTETT [Sun, 17 Apr 2022 10:36:33 +0000 (12:36 +0200)]
Fix --bless not working anymore in htmldocck

2 years agoBless nll test.
Camille GILLOT [Sun, 17 Apr 2022 10:41:49 +0000 (12:41 +0200)]
Bless nll test.

2 years agoAuto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillot
bors [Sun, 17 Apr 2022 10:31:52 +0000 (10:31 +0000)]
Auto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillot

Remove last vestiges of skippng ident span hashing

This removes a comment that no longer applies, and properly hashes
the full ident for path segments.

2 years agoBless clippy.
Camille GILLOT [Fri, 1 Apr 2022 17:18:10 +0000 (19:18 +0200)]
Bless clippy.

2 years agoLint elided lifetimes in path on the AST.
Camille GILLOT [Thu, 10 Mar 2022 22:12:35 +0000 (23:12 +0100)]
Lint elided lifetimes in path on the AST.

2 years agoBless tests.
Camille GILLOT [Sun, 6 Mar 2022 14:44:48 +0000 (15:44 +0100)]
Bless tests.

2 years agoReport undeclared lifetimes on AST.
Camille GILLOT [Sun, 6 Mar 2022 11:02:13 +0000 (12:02 +0100)]
Report undeclared lifetimes on AST.

2 years agoRemove is_in_fn_syntax.
Camille GILLOT [Fri, 11 Mar 2022 11:01:20 +0000 (12:01 +0100)]
Remove is_in_fn_syntax.

2 years agoVisit generics inside visit_fn.
Camille GILLOT [Fri, 19 Nov 2021 21:03:43 +0000 (22:03 +0100)]
Visit generics inside visit_fn.

2 years agoCount number of lifetime parameters in a separate pass.
Camille GILLOT [Thu, 18 Nov 2021 18:59:26 +0000 (19:59 +0100)]
Count number of lifetime parameters in a separate pass.

2 years agoAuto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot
bors [Sun, 17 Apr 2022 08:06:53 +0000 (08:06 +0000)]
Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot

Refactor HIR item-like traversal (part 1)

Issue  #95004

- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel;

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
cc `@cjgillot`

2 years agomove import to fix warning with emscripten target
Ralf Sager [Sun, 17 Apr 2022 07:42:15 +0000 (09:42 +0200)]
move import to fix warning with emscripten target

2 years agoRevert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"
Erik Desjardins [Sun, 17 Apr 2022 06:15:45 +0000 (02:15 -0400)]
Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"

This reverts commit 035a717ee8bf548868fb50b5c7ca562fc4a657a7, reversing
changes made to 761e8884858759b21f3374ad610494e68c087a38.

2 years agoAuto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko
bors [Sun, 17 Apr 2022 05:26:08 +0000 (05:26 +0000)]
Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko

Implement `core::ptr::Unique` on top of `NonNull`

Removes the use `rustc_layout_scalar_valid_range_start` and some `unsafe` blocks.

2 years agoReword clarification on lifetime for ptr->ref safety docs
Thom Chiovoloni [Sun, 17 Apr 2022 04:37:42 +0000 (21:37 -0700)]
Reword clarification on lifetime for ptr->ref safety docs

2 years agoAuto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-se
bors [Sun, 17 Apr 2022 03:08:45 +0000 (03:08 +0000)]
Auto merge of #96002 - nnethercote:speed-up-Vec-clear-2, r=m-ou-se

Speed up Vec::clear().

Currently it just calls `truncate(0)`. `truncate()` is (a) not marked as
`#[inline]`, and (b) more general than needed for `clear()`.

This commit changes `clear()` to do the work itself. This modest change
was first proposed in rust-lang#74172, where the reviewer rejected it because
there was insufficient evidence that `Vec::clear()`'s performance
mattered enough to justify the change. Recent changes within rustc have
made `Vec::clear()` hot within `macro_parser.rs`, so the change is now
clearly worthwhile.

Although it doesn't show wins on CI perf runs, this seems to be because they
use PGO. But not all platforms currently use PGO. Also, local builds don't use
PGO, and `truncate` sometimes shows up in an over-represented fashion in local
profiles. So local profiling will be made easier by this change.

Note that this will also benefit `String::clear()`, because it just
calls `Vec::clear()`.

Finally, the commit removes the `vec-clear.rs` codegen test. It was
added in #52908. From before then until now, `Vec::clear()` just called
`Vec::truncate()` with a zero length. The body of Vec::truncate() has
changed a lot since then. Now that `Vec::clear()` is doing actual work
itself, and not just calling `Vec::truncate()`, it's not surprising that
its generated code includes a load and an icmp. I think it's reasonable
to remove this test.

r? `@m-ou-se`

2 years agoAuto merge of #96134 - Dylan-DPC:rollup-ejug3yq, r=Dylan-DPC
bors [Sun, 17 Apr 2022 00:44:53 +0000 (00:44 +0000)]
Auto merge of #96134 - Dylan-DPC:rollup-ejug3yq, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #95346 (Stablize `const_extern_fn` for "Rust" and "C")
 - #95933 (htmldocck: Compare HTML tree instead of plain text html)
 - #96105 (Make the debug output for `TargetSelection` less verbose)
 - #96112 (Strict provenance lint diagnostics improvements)
 - #96119 (update Miri)
 - #96124 (to_digit tweak)

Failed merges:

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

2 years agoRollup merge of #96124 - gilescope:to_digit_speedup4, r=thomcc
Dylan DPC [Sat, 16 Apr 2022 22:07:28 +0000 (00:07 +0200)]
Rollup merge of #96124 - gilescope:to_digit_speedup4, r=thomcc

to_digit tweak

No need to check the assert all the time.

(Checked the TODO and it's not time to get rid of it yet)

2 years agoRollup merge of #96119 - RalfJung:miri, r=RalfJung
Dylan DPC [Sat, 16 Apr 2022 22:07:27 +0000 (00:07 +0200)]
Rollup merge of #96119 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/96115
r? ``@rust-lang/miri``

2 years agoRollup merge of #96112 - niluxv:strict-provenance-lint-improvements, r=nagisa
Dylan DPC [Sat, 16 Apr 2022 22:07:26 +0000 (00:07 +0200)]
Rollup merge of #96112 - niluxv:strict-provenance-lint-improvements, r=nagisa

Strict provenance lint diagnostics improvements

Use `multipart_suggestion` instead of `span_suggestion` and getting a snippet for the expression. Also don't suggest unnecessary parenthesis in `lossy_provenance_casts`.
cc ``@estebank``
``@rustbot`` label A-diagnostics

2 years agoRollup merge of #96105 - jyn514:less-verbose-logging, r=Mark-Simulacrum
Dylan DPC [Sat, 16 Apr 2022 22:07:25 +0000 (00:07 +0200)]
Rollup merge of #96105 - jyn514:less-verbose-logging, r=Mark-Simulacrum

Make the debug output for `TargetSelection` less verbose

In particular, this makes the output of `x build -vv` easier to read.
Before:

```
    c Sysroot { compiler: Compiler { stage: 0, host: TargetSelection { triple: "x86_64-unknown-linux-gnu", file: None } } }
```

After:
```
    c Sysroot { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu } }
```

2 years agoRollup merge of #95933 - Urgau:rustdoc-htmldocck-tree-compare, r=GuillaumeGomez
Dylan DPC [Sat, 16 Apr 2022 22:07:24 +0000 (00:07 +0200)]
Rollup merge of #95933 - Urgau:rustdoc-htmldocck-tree-compare, r=GuillaumeGomez

htmldocck: Compare HTML tree instead of plain text html

This PR improves `htmldocck` by comparing HTML trees instead of plain text html in the case of doing a ```@snapshot``` test.

This fix the [CI issue](https://github.com/rust-lang-ci/rust/runs/5964305020?check_suite_focus=true) encounter in https://github.com/rust-lang/rust/pull/95813 where for some unknown reason one of the attributes is not always at the same place.

The code is largely based on https://github.com/formencode/formencode/blob/3a1ba9de2fdd494dd945510a4568a3afeddb0b2e/formencode/doctest_xml_compare.py#L72-L120 which is behind MIT License. The comparison function is straightforward except for the `text_compare` function which does some weird stuff that we may want to simply reduce to a plain old comparison.

r? ``@GuillaumeGomez``

2 years agoRollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix
Dylan DPC [Sat, 16 Apr 2022 22:07:23 +0000 (00:07 +0200)]
Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix

Stablize `const_extern_fn` for "Rust" and "C"

All other ABIs are left unstable for now.

cc #64926

2 years agoAuto merge of #95899 - petrochenkov:modchild2, r=cjgillot
bors [Sat, 16 Apr 2022 22:04:10 +0000 (22:04 +0000)]
Auto merge of #95899 - petrochenkov:modchild2, r=cjgillot

rustc_metadata: Do not encode unnecessary module children

This should remove the syntax context shift and the special case for `ExternCrate` in decoder in https://github.com/rust-lang/rust/pull/95880.

This PR also shifts some work from decoding to encoding, which is typically useful for performance (but probably not much in this case).
r? `@cjgillot`

2 years agoAuto merge of #96123 - Dylan-DPC:rollup-qjog6n1, r=Dylan-DPC
bors [Sat, 16 Apr 2022 19:15:02 +0000 (19:15 +0000)]
Auto merge of #96123 - Dylan-DPC:rollup-qjog6n1, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #94985 (Parse inner attributes on inline const block)
 - #95006 (Reject `#[thread_local]` attribute on non-static items)
 - #95426 (Include Refs in Valtree Creation)
 - #95908 (Inline `shallow_resolve_ty` into `ShallowResolver`)
 - #96058 (separate flock implementations into separate modules)
 - #96088 (Update mdbook)
 - #96118 (rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability)

Failed merges:

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

2 years agoNo need to check the assert all the time.
Giles Cope [Sat, 16 Apr 2022 18:30:23 +0000 (19:30 +0100)]
No need to check the assert all the time.

2 years agoRequire all paths passed to `ShouldRun::paths` to exist on disk
Joshua Nelson [Sun, 10 Apr 2022 22:09:56 +0000 (17:09 -0500)]
Require all paths passed to `ShouldRun::paths` to exist on disk

This has two benefits:
1. There is a clearer mental model of how bootstrap works. Steps correspond to paths on disk unless it's strictly impossible for them to do so (e.g. dist components).
2. Bootstrap has better checks for internal consistency. This caught several issues:
  - `src/sanitizers` doesn't exist; I changed it to just be a `sanitizers` alias.
  - `src/tools/lld` doesn't exist; I removed it, since `lld` alone already works.
  - `src/llvm` doesn't exist; removed it since `llvm` and `src/llvm-project` both work.
  - `src/lldb_batchmode.py` doesn't exist, it was moved to `src/etc`.
  - `install` was still using `src/librustc` instead of `compiler/rustc`.
  - None of the tools in `dist` / `install` allowed using `src/tools/X` to build them. This might be intentional - I can change them to aliases if you like.

2 years agoRollup merge of #96118 - GuillaumeGomez:cleanup-def-id-item-id, r=notriddle
Dylan DPC [Sat, 16 Apr 2022 17:42:07 +0000 (19:42 +0200)]
Rollup merge of #96118 - GuillaumeGomez:cleanup-def-id-item-id, r=notriddle

rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability

As `@notriddle` mentioned in https://github.com/rust-lang/rust/pull/96091, the field name is inaccurate. This PR fixes it by renaming it accordingly to its real type.

r? `@notriddle`

2 years agoRollup merge of #96088 - ehuss:update-mdbook, r=Mark-Simulacrum
Dylan DPC [Sat, 16 Apr 2022 17:42:06 +0000 (19:42 +0200)]
Rollup merge of #96088 - ehuss:update-mdbook, r=Mark-Simulacrum

Update mdbook

This just brings in a few small fixes, particularly a rendering fix for chapter names with markdown in them (like the https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html page).  There's also a minor fix for the search index for duplicate headings.

Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0418

2 years agoRollup merge of #96058 - euclio:flock-impls, r=nagisa
Dylan DPC [Sat, 16 Apr 2022 17:42:05 +0000 (19:42 +0200)]
Rollup merge of #96058 - euclio:flock-impls, r=nagisa

separate flock implementations into separate modules

The main benefit of doing this is that rustfmt will now format each of these modules.

2 years agoRollup merge of #95908 - compiler-errors:shallow_resolve_ty-inline, r=oli-obk
Dylan DPC [Sat, 16 Apr 2022 17:42:04 +0000 (19:42 +0200)]
Rollup merge of #95908 - compiler-errors:shallow_resolve_ty-inline, r=oli-obk

Inline `shallow_resolve_ty` into `ShallowResolver`

addresses fixme I found in infcx

2 years agoRollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obk
Dylan DPC [Sat, 16 Apr 2022 17:42:03 +0000 (19:42 +0200)]
Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obk

Include Refs in Valtree Creation

This adds references to `const_to_valtree`, which isn't used in the compiler yet, but after the previous changes we made to the thir and mir representations and this change we should be able to finally introduce them in the next PR.

I wasn't able to properly test this code, except indirectly by including a call of `const_to_valtree` in the code that currently creates constants (`turn_into_const_value`).

r? `@lcnr`

cc `@oli-obk` `@RalfJung`

2 years agoRollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiser
Dylan DPC [Sat, 16 Apr 2022 17:42:02 +0000 (19:42 +0200)]
Rollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiser

Reject `#[thread_local]` attribute on non-static items

2 years agoRollup merge of #94985 - dtolnay:constattr, r=pnkfelix
Dylan DPC [Sat, 16 Apr 2022 17:42:00 +0000 (19:42 +0200)]
Rollup merge of #94985 - dtolnay:constattr, r=pnkfelix

Parse inner attributes on inline const block

According to https://github.com/rust-lang/rust/pull/84414#issuecomment-826150936, inner attributes are intended to be supported *"in all containers for statements (or some subset of statements)"*.

This PR adds inner attribute parsing and pretty-printing for inline const blocks (https://github.com/rust-lang/rust/issues/76001), which contain statements just like an unsafe block or a loop body.

```rust
let _ = const {
    #![allow(...)]

    let x = ();
    x
};
```

2 years agoAuto merge of #95993 - jyn514:fix-stage0-doctests, r=Mark-Simulacrum
bors [Sat, 16 Apr 2022 16:50:37 +0000 (16:50 +0000)]
Auto merge of #95993 - jyn514:fix-stage0-doctests, r=Mark-Simulacrum

Fix `x test --doc --stage 0 library/std`

I managed to break this in https://github.com/rust-lang/rust/pull/95449.
I am not quite sure why this is the correct fix, but it doesn't break `doc --stage 0`
and is strictly closer to the previous behavior.

Previously, rustdoc would error with strange issues because of the mismatched sysroot:
```
error[E0460]: found possibly newer version of crate `std` which `rustc_span` depends on
  --> /home/jnelson/rust-lang/rust/compiler/rustc_lint_defs/src/lib.rs:14:5
   |
14 | use rustc_span::{sym, symbol::Ident, Span, Symbol};
   |     ^^^^^^^^^^
   |
   = note: perhaps that crate needs to be recompiled?
   = note: the following crate versions were found:
           crate `std`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ff9290e971253a38.rlib
           crate `std`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ff9290e971253a38.so
           crate `rustc_span`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_span-ed11dce30c1766f9.rlib
```

2 years agohtmldocck: Compare HTML tree instead of plain text html
Loïc BRANSTETT [Mon, 11 Apr 2022 10:28:56 +0000 (12:28 +0200)]
htmldocck: Compare HTML tree instead of plain text html

2 years agoAuto merge of #96117 - Dylan-DPC:rollup-5traczf, r=Dylan-DPC
bors [Sat, 16 Apr 2022 14:24:14 +0000 (14:24 +0000)]
Auto merge of #96117 - Dylan-DPC:rollup-5traczf, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #95887 (resolve: Create dummy bindings for all unresolved imports)
 - #96023 (couple of clippy::perf fixes)
 - #96035 (Update GitHub Actions actions/checkout Version v2 -> v3)
 - #96038 (docs: add link from zip to unzip)
 - #96047 (:arrow_up: rust-analyzer)
 - #96059 (clarify doc(cfg) wording)
 - #96081 (Make some `usize`-typed masks definitions agnostic to the size of `usize`)

Failed merges:

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

2 years agoupdate Miri
Ralf Jung [Sat, 16 Apr 2022 13:11:31 +0000 (09:11 -0400)]
update Miri

2 years agoRename `def_id` into `item_id` when the type is `ItemId` for readability
Guillaume Gomez [Sat, 16 Apr 2022 12:28:09 +0000 (14:28 +0200)]
Rename `def_id` into `item_id` when the type is `ItemId` for readability

2 years agoRollup merge of #96081 - eduardosm:masks_usize_size_agnostic, r=yaahc
Dylan DPC [Sat, 16 Apr 2022 12:26:01 +0000 (14:26 +0200)]
Rollup merge of #96081 - eduardosm:masks_usize_size_agnostic, r=yaahc

Make some `usize`-typed masks definitions agnostic to the size of `usize`

Some masks where defined as
```rust
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
```
where it was assumed that `usize` is never wider than 64, which is currently true.

To make those constants valid in a hypothetical 128-bit target, these constants have been redefined in an `usize`-width-agnostic way
```rust
const NONASCII_MASK: usize = usize::from_ne_bytes([0x80; size_of::<usize>()]);
```

There are already some cases where Rust anticipates the possibility of supporting 128-bit targets, such as not implementing `From<usize>` for `u64`.

2 years agoRollup merge of #96059 - euclio:doc-cfg, r=manishearth,guillaumegomez
Dylan DPC [Sat, 16 Apr 2022 12:26:00 +0000 (14:26 +0200)]
Rollup merge of #96059 - euclio:doc-cfg, r=manishearth,guillaumegomez

clarify doc(cfg) wording

The current "This is supported" wording implies that it's possible to
still use the item on other configurations, but in an unsupported way.
Changing this to "Available" removes this ambiguity.

2 years agoRollup merge of #96047 - lnicola:rust-analyzer-2022-04-14, r=lnicola
Dylan DPC [Sat, 16 Apr 2022 12:25:59 +0000 (14:25 +0200)]
Rollup merge of #96047 - lnicola:rust-analyzer-2022-04-14, r=lnicola

:arrow_up: rust-analyzer

r? ``@ghost``

2 years agoRollup merge of #96038 - beyarkay:patch-1, r=m-ou-se
Dylan DPC [Sat, 16 Apr 2022 12:25:58 +0000 (14:25 +0200)]
Rollup merge of #96038 - beyarkay:patch-1, r=m-ou-se

docs: add link from zip to unzip

The docs for `Iterator::unzip` explain that it is kind of an inverse operation to `Iterator::zip` and guide the reader to the `zip` docs, but the `zip` docs don't let the user know that they can undo the `zip` operation with `unzip`. This change modifies the docs to help the user find `unzip`.

2 years agoRollup merge of #96035 - Gumichocopengin8:feature/update-github-action-version, r...
Dylan DPC [Sat, 16 Apr 2022 12:25:57 +0000 (14:25 +0200)]
Rollup merge of #96035 - Gumichocopengin8:feature/update-github-action-version, r=pietroalbini

Update GitHub Actions actions/checkout Version v2 -> v3

Update `actions/checkout@v2` to `actions/checkout@v3` because of Node12 will be out of life after Aril 30, 2022 [[Reference](https://nodejs.org/en/about/releases/)].
`actions/xxxx@v3` use Node16 whose support lasts until April 30, 2024.

2 years agoRollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr
Dylan DPC [Sat, 16 Apr 2022 12:25:56 +0000 (14:25 +0200)]
Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr

couple of clippy::perf fixes

2 years agoRollup merge of #95887 - petrochenkov:doclink5, r=cjgillot
Dylan DPC [Sat, 16 Apr 2022 12:25:55 +0000 (14:25 +0200)]
Rollup merge of #95887 - petrochenkov:doclink5, r=cjgillot

resolve: Create dummy bindings for all unresolved imports

Apparently such bindings weren't previously created for all unresolved imports, causing issues like https://github.com/rust-lang/rust/issues/95879.
In this PR I'm trying to create such dummy bindings in a more centralized way by calling `import_dummy_binding` once for all imports in `finalize_imports`.

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

2 years agoAuto merge of #95689 - lqd:self-profiler, r=wesleywiser
bors [Sat, 16 Apr 2022 11:43:28 +0000 (11:43 +0000)]
Auto merge of #95689 - lqd:self-profiler, r=wesleywiser

Allow self-profiler to only record potentially costly arguments when argument recording is turned on

As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns/near/277304909) with `@wesleywiser,` I'd like to record proc-macro expansions in the self-profiler, with some detailed data (per-expansion spans for example, to follow #95473).

At the same time, I'd also like to avoid doing expensive things when tracking a generic activity's arguments, if they were not specifically opted into the event filter mask, to allow the self-profiler to be used in hotter contexts.

This PR tries to offer:
- a way to ensure a closure to record arguments will only be called in that situation, so that potentially costly arguments can still be recorded when needed. With the additional requirement that, if possible, it would offer a way to record non-owned data without adding many `generic_activity_with_arg_{...}`-style methods. This lead to the `generic_activity_with_arg_recorder` single entry-point, and the closure parameter would offer the new methods, able to be executed in a context where costly argument could be created without disturbing the profiled piece of code.
- some facilities/patterns allowing to record more rustc specific data in this situation, without making `rustc_data_structures`  where the self-profiler is defined, depend on other rustc crates (causing circular dependencies): in particular, spans. They are quite tricky to turn into strings (if the default `Debug` impl output does not match the context one needs them for), and since I'd also like to avoid the allocation there when arg recording is turned off today, that has turned into another flexibility requirement for the API in this PR (separating the span-specific recording into an extension trait). **edit**: I've removed this from the PR so that it's easier to review, and opened https://github.com/rust-lang/rust/pull/95739.
- allow for extensibility in the future: other ways to record arguments, or additional data attached to them could be added in the future (e.g. recording the argument's name as well as its data).

Some areas where I'd love feedback:
- the API and names: the `EventArgRecorder` and its method for example. As well as the verbosity that comes from the increased flexibility.
- if I should convert the existing `generic_activity_with_arg{s}` to just forward to `generic_activity_with_arg_recorder` + `recorder.record_arg` (or remove them altogether ? Probably not): I've used the new API in the simple case I could find of allocating for an arg that may not be recorded, and the rest don't seem costly.
- [x] whether this API should panic if no arguments were recorded by the user-provided closure (like this PR currently does: it seems like an error to use an API dedicated to record arguments but not call the methods to then do so) or if this should just record a generic activity without arguments ?
- whether the `record_arg` function should be `#[inline(always)]`, like the `generic_activity_*` functions ?

As mentioned, r? `@wesleywiser` following our recent discussion.

2 years agoUse a single ReentrantMutex implementation on all platforms.
Mara Bos [Thu, 14 Apr 2022 09:11:41 +0000 (11:11 +0200)]
Use a single ReentrantMutex implementation on all platforms.

2 years agoAuto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPC
bors [Sat, 16 Apr 2022 09:19:26 +0000 (09:19 +0000)]
Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used)
 - #94605 (Add missing links in platform support docs)
 - #95372 (make unaligned_references lint deny-by-default)
 - #95859 (Improve diagnostics for unterminated nested block comment)
 - #95961 (implement SIMD gather/scatter via vector getelementptr)
 - #96004 (Consider lifetimes when comparing types for equality in MIR validator)
 - #96050 (Remove some now-dead code that was only relevant before deaggregation.)
 - #96070 ([test] Add test cases for untested functions for BTreeMap)
 - #96099 (MaybeUninit array cleanup)

Failed merges:

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

2 years agoAdd support for LibreSSL 3.4.x
Johannes Nixdorf [Sat, 16 Apr 2022 08:50:29 +0000 (10:50 +0200)]
Add support for LibreSSL 3.4.x

This updates the `openssl` and `openssl-sys` crates to support building
the toolchain with system libraries up to LibreSSL 3.4.x.

LibreSSL 3.4.0 has been supported since `openssl-sys` version 0.9.67,
LibreSSL 3.4.x since `openssl-sys` 0.9.72.

2 years agoImprove `fuzzy_provenance_casts` lint diagnostics
niluxv [Sat, 16 Apr 2022 08:18:31 +0000 (10:18 +0200)]
Improve `fuzzy_provenance_casts` lint diagnostics

Use `multipart_suggestion` instead of getting a snippet.

2 years agoImprove `lossy_provenance_casts` lint diagnostics
niluxv [Sat, 16 Apr 2022 08:05:33 +0000 (10:05 +0200)]
Improve `lossy_provenance_casts` lint diagnostics

Use `multipart_suggestion` and don't suggested unnecessary parenthesis.

2 years agoAuto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, r=estebank
bors [Sat, 16 Apr 2022 06:55:28 +0000 (06:55 +0000)]
Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, r=estebank

Better method call error messages

Rebase/continuation of #71827

~Based on #92360~
~Based on #93118~

There's a decent description in #71827 that I won't copy here (for now at least)

In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now.

I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given.

~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~

r? `@estebank` as the original reviewer of #71827

2 years agoImplementation for 65853
Jack Huey [Sat, 22 Jan 2022 04:50:54 +0000 (23:50 -0500)]
Implementation for 65853

This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.

The algorithm is inspired by Levenshtein distance and longest common sub-sequence.   In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.

We then modify that algorithm to detect 4 cases:

 - A function input is missing
 - An extra argument was provided
 - The type of an argument is straight up invalid
 - Two arguments have been swapped
 - A subset of the arguments have been shuffled

(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)

It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.

The basic sketch of the algorithm is as follows:

 - Construct a boolean grid, with a row for each argument, and a column for each input.  The cell [i, j] is true if the i'th argument could satisfy the j'th input.
 - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
 - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
 - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
 - Swapped / Permuted arguments are identified with a cycle detection algorithm.

As each issue is found, we remove the relevant inputs / arguments and check for more issues.  If we find no issues, we match up any "valid" arguments, and start again.

Note that there's a lot of extra complexity:
 - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
 - Closure arguments are wrapped in a tuple and need to be unwrapped
 - We need to resolve closure types after the rest, to allow the most specific type constraints
 - We need to handle imported C functions that might be variadic in their inputs.

I tried to document a lot of this in comments in the code and keep the naming clear.

2 years agoRollup merge of #96099 - clarfonthey:maybeuninit_array_cleanup, r=dtolnay
Dylan DPC [Sat, 16 Apr 2022 05:12:49 +0000 (07:12 +0200)]
Rollup merge of #96099 - clarfonthey:maybeuninit_array_cleanup, r=dtolnay

MaybeUninit array cleanup

* Links `MaybeUninit::uninit_array` to meta-tracking issue
* Links `MaybeUninit::array_assume_init` to meta-tracking issue
* Unstably constifies `MaybeUninit::array_assume_init`

Another thing worth mentioning: this splits the const feature flag for `maybe_uninit_uninit_array` into `const_maybe_uninit_uninit_array` to avoid weird cases where only one gets stabilised.

Note that it may be desired to keep the `array_assume_init` method linked to its dedicated issue, but at least for now, I decided to link to the meta-tracking issue so that all of the methods lead users to the same place. But I can revert that bit if desired.

The meta-tracking issue that I filed is #96097.

2 years agoRollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc
Dylan DPC [Sat, 16 Apr 2022 05:12:48 +0000 (07:12 +0200)]
Rollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc

[test] Add test cases for untested functions for BTreeMap

- add `pop_first()`, `pop_last()`, `get_key_value()` and `try_insert()` test cases

2 years agoRollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung
Dylan DPC [Sat, 16 Apr 2022 05:12:47 +0000 (07:12 +0200)]
Rollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung

Remove some now-dead code that was only relevant before deaggregation.

The code was broken anyway, if the deaggregator is disabled, it would have ICEd on any non-enum Adt

r? ```@RalfJung```

2 years agoRollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkov
Dylan DPC [Sat, 16 Apr 2022 05:12:46 +0000 (07:12 +0200)]
Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkov

Consider lifetimes when comparing types for equality in MIR validator

Closes #95978 .

2 years agoRollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee
Dylan DPC [Sat, 16 Apr 2022 05:12:45 +0000 (07:12 +0200)]
Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee

implement SIMD gather/scatter via vector getelementptr

Fixes https://github.com/rust-lang/portable-simd/issues/271

However, I don't *really* know what I am doing here... Cc ``@workingjubilee`` ``@calebzulawski``

I didn't do anything for cranelift -- ``@bjorn3`` not sure if it's okay for that backend to temporarily break. I'm happy to cherry-pick a patch that adds cranelift support. :)