]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoUpdate the syn crate and adopt let_else in three more places
est31 [Sat, 16 Oct 2021 02:37:30 +0000 (04:37 +0200)]
Update the syn crate and adopt let_else in three more places

The syn crate has gained support for let_else syntax in version 1.0.76,
see https://github.com/dtolnay/syn/pull/1057 .

In the three instances that use let_else, we've sent code through an
attr macro, which would create compile errors when there was no
let_else support in syn. To avoid this, we ran
`cargo +nightly update -p syn` for updating the syn crate.

2 years agoAdopt let_else across the compiler
est31 [Sat, 16 Oct 2021 01:45:14 +0000 (03:45 +0200)]
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

let <id> = if let <pat> = ... { identity } else { ... : ! };

To simplify it to:

let <pat> = ... { identity } else { ... : ! };

By adopting the let_else feature.

2 years agoAuto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay
bors [Fri, 15 Oct 2021 19:03:57 +0000 (19:03 +0000)]
Auto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay

Use BCryptGenRandom instead of RtlGenRandom on Windows.

This removes usage of RtlGenRandom on Windows, in favour of BCryptGenRandom.

BCryptGenRandom isn't available on XP, but we dropped XP support a while ago.

2 years agoAuto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se
bors [Fri, 15 Oct 2021 15:55:08 +0000 (15:55 +0000)]
Auto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se

Avoid allocations and copying in Vec::leak

The [`Vec::leak`] method (#62195) is currently implemented by calling `Vec::into_boxed_slice` and `Box::leak`.  This shrinks the vector before leaking it, which potentially causes a reallocation and copies the vector's contents.

By avoiding the conversion to `Box`, we can instead leak the vector without any expensive operations, just by returning a slice reference and forgetting the `Vec`.  Users who *want* to shrink the vector first can still do so by calling `shrink_to_fit` explicitly.

**Note:**  This could break code that uses `Box::from_raw` to “un-leak” the slice returned by `Vec::leak`.  However, the `Vec::leak` docs explicitly forbid this, so such code is already incorrect.

[`Vec::leak`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.leak

2 years agoAuto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se
bors [Fri, 15 Oct 2021 12:51:31 +0000 (12:51 +0000)]
Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se

Optimize VecDeque::append

Optimize `VecDeque::append` to do unsafe copy rather than iterating through each element.

On my `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz`, the benchmark shows 37% improvements:
```
Master:
custom-bench vec_deque_append 583164 ns/iter
custom-bench vec_deque_append 550040 ns/iter

Patched:
custom-bench vec_deque_append 349204 ns/iter
custom-bench vec_deque_append 368164 ns/iter
```

Additional notes on the context: this is the third attempt to implement a non-trivial version of `VecDeque::append`, the last two are reverted due to unsoundness or regression, see:
- https://github.com/rust-lang/rust/pull/52553, reverted in https://github.com/rust-lang/rust/pull/53571
- https://github.com/rust-lang/rust/pull/53564, reverted in https://github.com/rust-lang/rust/pull/54851

Both cases are covered by existing tests.

Signed-off-by: tabokie <xy.tao@outlook.com>
2 years agoAdd missing bcrypt.lib to make-fulldeps Makefile.
Mara Bos [Fri, 15 Oct 2021 11:25:39 +0000 (13:25 +0200)]
Add missing bcrypt.lib to make-fulldeps Makefile.

2 years agoUse BCryptGenRandom instead of RtlGenRandom on Windows.
Mara Bos [Sun, 11 Apr 2021 12:55:47 +0000 (14:55 +0200)]
Use BCryptGenRandom instead of RtlGenRandom on Windows.

BCryptGenRandom isn't available on XP, but we dropped XP support a while
ago.

2 years agoAuto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm
bors [Fri, 15 Oct 2021 09:35:45 +0000 (09:35 +0000)]
Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm

add `slice::swap_unchecked`

An unsafe version of `slice::swap` that does not do bounds checking.

2 years agoAuto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
bors [Fri, 15 Oct 2021 05:59:49 +0000 (05:59 +0000)]
Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

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

2 years agoRollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum
Matthias Krüger [Fri, 15 Oct 2021 05:44:50 +0000 (07:44 +0200)]
Rollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum

Remove unused dependencies from rustc_const_eval

2 years agoRollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
Matthias Krüger [Fri, 15 Oct 2021 05:44:49 +0000 (07:44 +0200)]
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez

add long explanation for E0183

Addresses #61137

2 years agoRollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu
Matthias Krüger [Fri, 15 Oct 2021 05:44:48 +0000 (07:44 +0200)]
Rollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu

Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than 12 bits - hence we wouldn't ever need the upper 12 bits.

It's unlikely to ever fail in this small test but this is technically correct.

This was noticed incidentally when we found that LLD doesn't support the `tprel_lo12` relocation, even though LLVM can apparently generate it when using `-mtls-size=12`.

2 years agoRollup merge of #89870 - tmandry:box-pin, r=estebank
Matthias Krüger [Fri, 15 Oct 2021 05:44:47 +0000 (07:44 +0200)]
Rollup merge of #89870 - tmandry:box-pin, r=estebank

Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.

2 years agoRollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk
Matthias Krüger [Fri, 15 Oct 2021 05:44:47 +0000 (07:44 +0200)]
Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk

add dedicated error variant for writing the discriminant of an uninhabited enum variant

This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants.

r? ``@oli-obk``

2 years agoRollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum
Matthias Krüger [Fri, 15 Oct 2021 05:44:45 +0000 (07:44 +0200)]
Rollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum

Add a strange test for `unsafe_code` lint.

The current behavior is a little surprising to me. I'm not sure whether people would change it, but at least let me document the current behavior with a test.

I learnt about this from the [totally-speedy-transmute](https://docs.rs/totally-speedy-transmute) crate.

cc #10599 the original implementation pr.

2 years agoRollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
Matthias Krüger [Fri, 15 Oct 2021 05:44:44 +0000 (07:44 +0200)]
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank

move implicit `Sized` predicate to end of list

In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?

2 years agoAuto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
bors [Fri, 15 Oct 2021 02:55:58 +0000 (02:55 +0000)]
Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser

Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.

2 years agoRemove unused dependencies from rustc_const_eval
Cameron Steffen [Thu, 7 Oct 2021 18:18:41 +0000 (13:18 -0500)]
Remove unused dependencies from rustc_const_eval

2 years agoAdd a test for `unsafe_code` lint.
Charles Lew [Tue, 12 Oct 2021 14:34:53 +0000 (22:34 +0800)]
Add a test for `unsafe_code` lint.

2 years agoadd long explanation for E0183
cameron1024 [Thu, 14 Oct 2021 16:44:04 +0000 (17:44 +0100)]
add long explanation for E0183

2 years agoAuto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr
bors [Thu, 14 Oct 2021 16:23:10 +0000 (16:23 +0000)]
Auto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #89390 (Fix incorrect Box::pin suggestion)
 - #89433 (Fix ctrl-c causing reads of stdin to return empty on Windows.)
 - #89823 (Switch order of terms to prevent overflow)
 - #89865 (Allow static linking LLVM with ThinLTO)
 - #89873 (Add missing word to `FromStr` trait documentation)
 - #89878 (Fix missing remaining compiler specific cfg information)

Failed merges:

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

2 years agoDrop reverted stabilizations from release notes
Mark Rousskov [Thu, 14 Oct 2021 14:58:16 +0000 (10:58 -0400)]
Drop reverted stabilizations from release notes

2 years agoRevert "Stabilize `arbitrary_enum_discriminant`"
Mark Rousskov [Thu, 14 Oct 2021 14:57:56 +0000 (10:57 -0400)]
Revert "Stabilize `arbitrary_enum_discriminant`"

This reverts commit 7a62f29f3171767090949778ce0f161e930706b9.

2 years agoRollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle
Matthias Krüger [Thu, 14 Oct 2021 14:06:47 +0000 (16:06 +0200)]
Rollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle

Fix missing remaining compiler specific cfg information

Follow-up of #89596. We forgot a few of them:

![Screenshot from 2021-10-14 11-36-44](https://user-images.githubusercontent.com/3050060/137292700-64ebc59f-d9d2-41f2-be3a-fa5bf211523c.png)
![Screenshot from 2021-10-14 11-36-56](https://user-images.githubusercontent.com/3050060/137292703-f63fa4e5-2c56-446b-9f86-3652f03dfe59.png)

r? `@notriddle`

2 years agoRollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum
Matthias Krüger [Thu, 14 Oct 2021 14:06:46 +0000 (16:06 +0200)]
Rollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum

Add missing word to `FromStr` trait documentation

The doc comment is getting a bit wide, let me know if I should restructure it/add a new line.

2 years agoRollup merge of #89865 - tmandry:llvm-static, r=Mark-Simulacrum
Matthias Krüger [Thu, 14 Oct 2021 14:06:46 +0000 (16:06 +0200)]
Rollup merge of #89865 - tmandry:llvm-static, r=Mark-Simulacrum

Allow static linking LLVM with ThinLTO

There's no reason not to allow this if the user wants it. It works, at least in a local build on linux host.

For our use case, we're happy to spend more time building the compiler if it creates a speedup every time we run it, and we've observed speedups like this with clang.

2 years agoRollup merge of #89823 - jackh726:project-overflow, r=oli-obk
Matthias Krüger [Thu, 14 Oct 2021 14:06:45 +0000 (16:06 +0200)]
Rollup merge of #89823 - jackh726:project-overflow, r=oli-obk

Switch order of terms to prevent overflow

Fixes #89639

r? ``@pnkfelix``

2 years agoRollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett
Matthias Krüger [Thu, 14 Oct 2021 14:06:44 +0000 (16:06 +0200)]
Rollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett

Fix ctrl-c causing reads of stdin to return empty on Windows.

Pressing ctrl+c (or ctrl+break) on Windows caused a blocking read of stdin to unblock and return empty, unlike other platforms which continue to block.

On ctrl-c, `ReadConsoleW` will return success, but also set `LastError` to `ERROR_OPERATION_ABORTED`.

This change detects this case, and re-tries the call to `ReadConsoleW`.

Fixes #89177. See issue for further details.

Tested on Windows 7 and Windows 10 with both MSVC and GNU toolchains

2 years agoRollup merge of #89390 - tmandry:issue-72117, r=estebank
Matthias Krüger [Thu, 14 Oct 2021 14:06:43 +0000 (16:06 +0200)]
Rollup merge of #89390 - tmandry:issue-72117, r=estebank

Fix incorrect Box::pin suggestion

The suggestion checked if `Pin<Box<T>>` could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is still marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

Fixes #72117.

2 years agoadd dedicated error variant for writing the discriminant of an uninhabited enum variant
Ralf Jung [Wed, 13 Oct 2021 20:53:09 +0000 (16:53 -0400)]
add dedicated error variant for writing the discriminant of an uninhabited enum variant

2 years agodon't duplicate slice `panic_bounds_check`
Ibraheem Ahmed [Thu, 14 Oct 2021 13:31:34 +0000 (09:31 -0400)]
don't duplicate slice `panic_bounds_check`

2 years agoAuto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
bors [Thu, 14 Oct 2021 13:21:46 +0000 (13:21 +0000)]
Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk

Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.

2 years agoUse non-checking TLS relocation in aarch64 asm! sym test.
Adam Gemmell [Wed, 13 Oct 2021 09:44:02 +0000 (10:44 +0100)]
Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than
12 bits - hence we wouldn't ever need the upper 12 bits.

2 years agoAuto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
bors [Thu, 14 Oct 2021 10:06:30 +0000 (10:06 +0000)]
Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk

Add `const_eval_select` intrinsic

Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.

See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.

r? `@oli-obk.`

2 years agoFix missing remaining compiler specific cfg information
Guillaume Gomez [Thu, 14 Oct 2021 09:39:30 +0000 (11:39 +0200)]
Fix missing remaining compiler specific cfg information

2 years agofix codegen test
Deadbeef [Thu, 14 Oct 2021 07:35:35 +0000 (07:35 +0000)]
fix codegen test

2 years agoFix const stability
Deadbeef [Thu, 14 Oct 2021 06:53:20 +0000 (06:53 +0000)]
Fix const stability

2 years agoAvoid tupling at the callee
Deadbeef [Thu, 14 Oct 2021 06:18:53 +0000 (06:18 +0000)]
Avoid tupling at the callee

2 years agoAdd missing word to `FromStr` trait docs
Adam Skoufis [Thu, 14 Oct 2021 02:47:54 +0000 (13:47 +1100)]
Add missing word to `FromStr` trait docs

2 years agoAuto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle
bors [Thu, 14 Oct 2021 02:24:52 +0000 (02:24 +0000)]
Auto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle

Associated consts sidebar

Fixes #89354.

A screenshot with `f32`:

![Screenshot from 2021-10-12 15-07-57](https://user-images.githubusercontent.com/3050060/136962078-5faf7b87-7ea5-4d7a-99a4-b2afd77b78e2.png)

2 years agoSuggest Box::pin when Pin::new is used instead
Tyler Mandry [Wed, 13 Oct 2021 23:24:48 +0000 (23:24 +0000)]
Suggest Box::pin when Pin::new is used instead

2 years agoAuto merge of #89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr
bors [Wed, 13 Oct 2021 23:27:57 +0000 (23:27 +0000)]
Auto merge of #89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #89347 (suggestion for typoed crate or module)
 - #89670 (Improve `std::thread::available_parallelism` docs)
 - #89757 (Use shallow clones for submodules)
 - #89759 (Assemble the compiler when running `x.py build`)
 - #89846 (Add `riscv32imc-esp-espidf` to 1.56 changelog)
 - #89853 (Update the 1.56.0 release header for consistency)

Failed merges:

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

2 years agoExit early if expected type is not an adt
Tyler Mandry [Thu, 30 Sep 2021 03:33:12 +0000 (03:33 +0000)]
Exit early if expected type is not an adt

2 years agoMove misplaced comment
Tyler Mandry [Thu, 30 Sep 2021 01:29:24 +0000 (01:29 +0000)]
Move misplaced comment

2 years agoAlways check predicates in can_coerce
Tyler Mandry [Thu, 30 Sep 2021 01:22:17 +0000 (01:22 +0000)]
Always check predicates in can_coerce

This only changed two tests and I consider both changes an improvement.

2 years agoFix incorrect Box::pin suggestion
Tyler Mandry [Thu, 30 Sep 2021 01:06:56 +0000 (01:06 +0000)]
Fix incorrect Box::pin suggestion

The suggestion checked if Pin<Box<T>> could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

2 years agoFix line length
Tyler Mandry [Fri, 24 Sep 2021 22:14:06 +0000 (22:14 +0000)]
Fix line length

2 years agoAllow static linking LLVM with ThinLTO
Tyler Mandry [Wed, 13 Oct 2021 22:56:26 +0000 (22:56 +0000)]
Allow static linking LLVM with ThinLTO

2 years agoRollup merge of #89853 - cuviper:release-1.56, r=Mark-Simulacrum
Matthias Krüger [Wed, 13 Oct 2021 20:51:05 +0000 (22:51 +0200)]
Rollup merge of #89853 - cuviper:release-1.56, r=Mark-Simulacrum

Update the 1.56.0 release header for consistency

2 years agoRollup merge of #89846 - esp-rs:riscv-esp-idf-changelog, r=Mark-Simulacrum
Matthias Krüger [Wed, 13 Oct 2021 20:51:04 +0000 (22:51 +0200)]
Rollup merge of #89846 - esp-rs:riscv-esp-idf-changelog, r=Mark-Simulacrum

Add `riscv32imc-esp-espidf` to 1.56 changelog

2 years agoRollup merge of #89759 - jyn514:x-build-assemble, r=Mark-Simulacrum
Matthias Krüger [Wed, 13 Oct 2021 20:51:03 +0000 (22:51 +0200)]
Rollup merge of #89759 - jyn514:x-build-assemble, r=Mark-Simulacrum

Assemble the compiler when running `x.py build`

Previously, there was no way to actually get binaries in
`build/$TARGET/stage1/bin` without building the standard library. This
makes it possible to build just the compiler. This can be useful when
the standard library isn't actually necessary for trying out your tests
(e.g. a bug that can be reproduced with only a `no_core` crate).

Closes https://github.com/rust-lang/rust/issues/73519.

2 years agoRollup merge of #89757 - jyn514:submodule, r=Mark-Simulacrum
Matthias Krüger [Wed, 13 Oct 2021 20:51:02 +0000 (22:51 +0200)]
Rollup merge of #89757 - jyn514:submodule, r=Mark-Simulacrum

Use shallow clones for submodules

This reduces the amount of git history downloaded for submodules from ~67M to ~11M. For comparison, a shallow clone of rust-lang/rust is 103M and a deep clone is 740M, so this almost halves the amount of history necessary if you made a shallow clone to start, and it's a significant reduction even if not.

Closes https://github.com/rust-lang/rust/issues/63978. r? `@Mark-Simulacrum`

2 years agoRollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett
Matthias Krüger [Wed, 13 Oct 2021 20:51:01 +0000 (22:51 +0200)]
Rollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett

Improve `std::thread::available_parallelism` docs

_Tracking issue: https://github.com/rust-lang/rust/issues/74479_

This PR reworks the documentation of `std::thread::available_parallelism`, as requested [here](https://github.com/rust-lang/rust/pull/89324#issuecomment-934343254).

## Changes

The following changes are made:

- We've removed prior mentions of "hardware threads" and instead centers the docs around "parallelism" as a resource available to a program.
- We now provide examples of when `available_parallelism` may return numbers that differ from the number of CPU cores in the host machine.
- We now mention that the amount of available parallelism may change over time.
- We make note of which platform components we don't take into account which more advanced users may want to take note of.
- The example has been updated, which should be a bit easier to use.
- We've added a docs alias to `num-cpus` which provides similar functionality to `available_parallelism`, and is one of the most popular crates on crates.io.

---

Thanks!

r? `@BurntSushi`

2 years agoRollup merge of #89347 - TaKO8Ki:crate-or-module-typo, r=estebank
Matthias Krüger [Wed, 13 Oct 2021 20:51:00 +0000 (22:51 +0200)]
Rollup merge of #89347 - TaKO8Ki:crate-or-module-typo, r=estebank

suggestion for typoed crate or module

Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules.

#76208

before:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`
```

after:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^
  |     |
  |     use of undeclared crate or module `chono`
  |     help: a similar crate or module exists: `chrono`
```

2 years agoAuto merge of #89555 - oli-obk:nll_member_constraint_diag, r=estebank
bors [Wed, 13 Oct 2021 20:36:10 +0000 (20:36 +0000)]
Auto merge of #89555 - oli-obk:nll_member_constraint_diag, r=estebank

Remove textual span from diagnostic string

This is an unnecessary repetition, as the diagnostic prints the span anyway in the source path right below the message.

I further removed the identification of the node, as that does not give any new information in any of the cases that are changed in tests.

EDIT: also inserted a suggestion that other diagnostics were already emitting

2 years agoImprove code readability for sidebar links
Guillaume Gomez [Wed, 13 Oct 2021 15:09:48 +0000 (17:09 +0200)]
Improve code readability for sidebar links

2 years agoUpdate the 1.56.0 release header for consistency
Josh Stone [Wed, 13 Oct 2021 18:10:00 +0000 (11:10 -0700)]
Update the 1.56.0 release header for consistency

2 years agoAuto merge of #89822 - tmiasko:overflap-duplicates, r=cjgillot
bors [Wed, 13 Oct 2021 16:42:53 +0000 (16:42 +0000)]
Auto merge of #89822 - tmiasko:overflap-duplicates, r=cjgillot

Deduplicate regions ids before merging them

The merging code does not expect to see any duplicates.

Fixes #89820.

r? `@cjgillot`

2 years agoImprove `std::thread::available_parallelism` docs
Yoshua Wuyts [Fri, 8 Oct 2021 15:17:50 +0000 (17:17 +0200)]
Improve `std::thread::available_parallelism` docs

2 years agoAuto merge of #89847 - JohnTitor:rollup-xfymeo4, r=JohnTitor
bors [Wed, 13 Oct 2021 13:41:48 +0000 (13:41 +0000)]
Auto merge of #89847 - JohnTitor:rollup-xfymeo4, r=JohnTitor

Rollup of 12 pull requests

Successful merges:

 - #89768 (add some more testcases)
 - #89777 (Edit explanation of test for nested type ascriptions)
 - #89781 (Add missing words in `Infallible` docs)
 - #89782 (Improve CJK font in rustdoc)
 - #89794 (Add #[must_use] to to_value conversions)
 - #89814 (Fix uppercase/lowercase error)
 - #89816 (Fix invalid rules in .gitignore)
 - #89817 (Add #[inline] to int log10 functions.)
 - #89818 (Use Option::map_or instead of open coding it)
 - #89828 (Fix config.toml overflow-checks options)
 - #89840 (fix the stage0 tools config file path in `config.toml.example`)
 - #89845 (Add davidtwco to the `.mailmap`)

Failed merges:

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

2 years agoRollup merge of #89845 - davidtwco:davidtwco-mailmap, r=oli-obk
Yuki Okushi [Wed, 13 Oct 2021 12:55:19 +0000 (21:55 +0900)]
Rollup merge of #89845 - davidtwco:davidtwco-mailmap, r=oli-obk

Add davidtwco to the `.mailmap`

2 years agoRollup merge of #89840 - wangkirin:master, r=jyn514
Yuki Okushi [Wed, 13 Oct 2021 12:55:18 +0000 (21:55 +0900)]
Rollup merge of #89840 - wangkirin:master, r=jyn514

fix the stage0 tools config file path in `config.toml.example`

in  #88362  , the `stage0.txt ` have been switched to `stage0.json`  , but in `config.toml.example` the guide didn't change ,  this PR fix  this issue

2 years agoRollup merge of #89828 - rusticstuff:overflow-check-options-take-two, r=Mark-Simulacrum
Yuki Okushi [Wed, 13 Oct 2021 12:55:18 +0000 (21:55 +0900)]
Rollup merge of #89828 - rusticstuff:overflow-check-options-take-two, r=Mark-Simulacrum

Fix config.toml overflow-checks options

This a follow-up PR to #87784.

Improvements:
* Add missing entries for overflow-checks to config.toml.example.
* Add --enable-overflow-checks-std option to configure script.
* Make rust.overflow-checks-stdoption default to rust.overflow-checks.

Also adds the missing  `--enable-debug-assertions-std `option to configure script.

r? ```@Mark-Simulacrum```
cc ```@jyn514```

2 years agoRollup merge of #89818 - LingMan:map_or, r=oli-obk
Yuki Okushi [Wed, 13 Oct 2021 12:55:17 +0000 (21:55 +0900)]
Rollup merge of #89818 - LingMan:map_or, r=oli-obk

Use Option::map_or instead of open coding it

````@rustbot```` modify labels +C-cleanup +T-compiler

2 years agoRollup merge of #89817 - m-ou-se:int-log-10-inline, r=the8472
Yuki Okushi [Wed, 13 Oct 2021 12:55:16 +0000 (21:55 +0900)]
Rollup merge of #89817 - m-ou-se:int-log-10-inline, r=the8472

Add #[inline] to int log10 functions.

2 years agoRollup merge of #89816 - Canop:master, r=Mark-Simulacrum
Yuki Okushi [Wed, 13 Oct 2021 12:55:15 +0000 (21:55 +0900)]
Rollup merge of #89816 - Canop:master, r=Mark-Simulacrum

Fix invalid rules in .gitignore

`**node_modules` in a .gitignore is the same than
`*node_modules` or `*****node_modules`.

It matches every file whose name ends with `node_modules`,
including `not_node_modules`.

The intent here was obviously to have `**/node_modules`
which is the same than just `node_modules`.

Reference on git ignoring rules format: https://git-scm.com/docs/gitignore

2 years agoRollup merge of #89814 - jkugelman:must-use-string-transforms-typo, r=joshtriplett
Yuki Okushi [Wed, 13 Oct 2021 12:55:14 +0000 (21:55 +0900)]
Rollup merge of #89814 - jkugelman:must-use-string-transforms-typo, r=joshtriplett

Fix uppercase/lowercase error

Fix https://github.com/rust-lang/rust/pull/89694#discussion_r726829890

r? ````@joshtriplett````

2 years agoRollup merge of #89794 - jkugelman:must-use-to_value-conversions, r=joshtriplett
Yuki Okushi [Wed, 13 Oct 2021 12:55:13 +0000 (21:55 +0900)]
Rollup merge of #89794 - jkugelman:must-use-to_value-conversions, r=joshtriplett

Add #[must_use] to to_value conversions

`NonNull<T>::cast` snuck in when I wasn't looking. What a scamp!

Parent issue: #89692

r? ````@joshtriplett````

2 years agoRollup merge of #89782 - konan8205:develop, r=jsha
Yuki Okushi [Wed, 13 Oct 2021 12:55:12 +0000 (21:55 +0900)]
Rollup merge of #89782 - konan8205:develop, r=jsha

Improve CJK font in rustdoc

This PR includes:
- Fix unicode range of korean letters in `rustdoc.css`.
- Add WOFF2 format version of Noto Sans KR font.
- Shorten the font file name.

2 years agoRollup merge of #89781 - Wilfred:patch-2, r=JohnTitor
Yuki Okushi [Wed, 13 Oct 2021 12:55:11 +0000 (21:55 +0900)]
Rollup merge of #89781 - Wilfred:patch-2, r=JohnTitor

Add missing words in `Infallible` docs

This sentence was previously incomplete.

2 years agoRollup merge of #89777 - pierwill:fix-88233, r=Mark-Simulacrum
Yuki Okushi [Wed, 13 Oct 2021 12:55:10 +0000 (21:55 +0900)]
Rollup merge of #89777 - pierwill:fix-88233, r=Mark-Simulacrum

Edit explanation of test for nested type ascriptions

Fixes typo ("an ascribing") and removes extra.

Closes #88233.

2 years agoRollup merge of #89768 - hellow554:tests, r=Mark-Simulacrum
Yuki Okushi [Wed, 13 Oct 2021 12:55:10 +0000 (21:55 +0900)]
Rollup merge of #89768 - hellow554:tests, r=Mark-Simulacrum

add some more testcases

resolves #52893
resolves #68295
resolves #87750
resolves #88071

All these issues have been fixed according to glacier. Just adding a test so it can be closed.

Can anybody tell me why the github keywords do not work? 🤔
Please edit this post if you can fix it.

2 years agoAdd `riscv32imc-esp-espidf` to changelog
Scott Mabin [Wed, 13 Oct 2021 12:13:08 +0000 (13:13 +0100)]
Add `riscv32imc-esp-espidf` to changelog

2 years agoAdd davidtwco to the `.mailmap`
David Wood [Wed, 13 Oct 2021 11:12:54 +0000 (11:12 +0000)]
Add davidtwco to the `.mailmap`

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoUpdate clippy ui output
Oli Scherer [Wed, 13 Oct 2021 11:06:14 +0000 (11:06 +0000)]
Update clippy ui output

2 years agoBless nll tests
Oli Scherer [Fri, 8 Oct 2021 18:30:58 +0000 (18:30 +0000)]
Bless nll tests

2 years agoRe-use logic for adding a suggestion when a lifetime bound is missing on an impl...
Oli Scherer [Tue, 5 Oct 2021 13:32:03 +0000 (13:32 +0000)]
Re-use logic for adding a suggestion when a lifetime bound is missing on an impl trait

2 years agoRemove explicit -Zborrowck=mir which does not affect test anymore
Oli Scherer [Tue, 5 Oct 2021 12:35:24 +0000 (12:35 +0000)]
Remove explicit -Zborrowck=mir which does not affect test anymore

2 years agoRemove a feature attribute for an accepted feature
Oli Scherer [Tue, 5 Oct 2021 12:32:57 +0000 (12:32 +0000)]
Remove a feature attribute for an accepted feature

2 years agoUse a label instead of a note for member constraint errors
Oli Scherer [Tue, 5 Oct 2021 12:32:08 +0000 (12:32 +0000)]
Use a label instead of a note for member constraint errors

2 years agoRemove textual span from diagnostic string
Oli Scherer [Tue, 5 Oct 2021 12:11:51 +0000 (12:11 +0000)]
Remove textual span from diagnostic string

2 years agoAuto merge of #89587 - camelid:all-candidates, r=petrochenkov
bors [Wed, 13 Oct 2021 10:38:12 +0000 (10:38 +0000)]
Auto merge of #89587 - camelid:all-candidates, r=petrochenkov

Include rmeta candidates in "multiple matching crates" error

Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

I also changed the code to sort the candidates to make the output deterministic;
added full stderr tests for the error; and added a long error code explanation.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436

cc `@Mark-Simulacrum` `@jyn514`

2 years agofix the stage0 tools config file path in config.toml.example
Wang Qilin [Wed, 13 Oct 2021 07:47:15 +0000 (15:47 +0800)]
fix the stage0 tools config file path in config.toml.example

2 years agoAssemble the compiler when running `x.py build`
Joshua Nelson [Mon, 11 Oct 2021 04:09:15 +0000 (04:09 +0000)]
Assemble the compiler when running `x.py build`

Previously, there was no way to actually get binaries in
`build/$TARGET/stage1/bin` without building the standard library. This
makes it possible to build just the compiler. This can be useful when
the standard library isn't actually necessary for trying out your tests
(e.g. a bug that can be reproduced with only a `no_core` crate).

2 years agosuggestion for typoed crate or module
Takayuki Maeda [Wed, 29 Sep 2021 04:55:24 +0000 (13:55 +0900)]
suggestion for typoed crate or module

avoid suggesting the same name

sort candidates

fix a message

use `opt_def_id` instead of `def_id`

move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs

2 years agoAuto merge of #89802 - ehuss:update-cargo, r=ehuss
bors [Wed, 13 Oct 2021 03:00:33 +0000 (03:00 +0000)]
Auto merge of #89802 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in d56b42c549dbb7e7d0f712c51b39400260d114d4..c7957a74bdcf3b11e7154c1a9401735f23ebd484
2021-09-27 13:44:18 +0000 to 2021-10-11 20:17:07 +0000
- Add some more information to verbose version. (rust-lang/cargo#9968)
- Skip all `cargo fix` that tends to write to registry cache. (rust-lang/cargo#9938)
- Stabilize named profiles (rust-lang/cargo#9943)
- Update git2 (rust-lang/cargo#9963)
- Distinguish lockfile version req from normal dep in resolver error message (rust-lang/cargo#9847)
- nit: Allocated slightly bigger vec than needed (rust-lang/cargo#9954)
- Add shell completion for shorthand commands (rust-lang/cargo#9951)

2 years agoDeduplicate regions ids before merging them
Tomasz Miąsko [Wed, 13 Oct 2021 00:00:00 +0000 (00:00 +0000)]
Deduplicate regions ids before merging them

The merging code does not expect to see any duplicates.

2 years agoAuto merge of #89774 - the8472:inline-mut-iter-next, r=m-ou-se
bors [Tue, 12 Oct 2021 23:59:48 +0000 (23:59 +0000)]
Auto merge of #89774 - the8472:inline-mut-iter-next, r=m-ou-se

inline next() on &mut Iterator impl

In [#87431](https://github.com/rust-lang/rust/pull/87431/files#diff-79a6b417b85ecf4f1a4ef2235135fedf540199caf6e9e1d154ac6a413b40a757R132-R136)   I found that `(&mut range).fold` doesn't optimize well because the default impl for for `fold` on `&mut Iterator` doesn't inline `next`. In that particular case it was worked around by using `try_fold` which takes a `&mut self` instead of `self`.

Let's see if this can be fixed more broadly.

2 years agoAuto merge of #89105 - DevinR528:reachable-fix, r=Nadrieril
bors [Tue, 12 Oct 2021 20:54:15 +0000 (20:54 +0000)]
Auto merge of #89105 - DevinR528:reachable-fix, r=Nadrieril

Fix: non_exhaustive_omitted_patterns by filtering unstable and doc hidden variants

Fixes: #89042
Now that #86809 has been merged there are cases (std::io::ErrorKind) where unstable feature gated variants were included in warning/error messages when the feature was not turned on. This filters those variants out of the return of `SplitWildcard::new`.

Variants marked `doc(hidden)` are filtered out of the witnesses list in `Usefulness::apply_constructor`.

Probably worth a perf run :shrug: since this area can be sensitive.

2 years agoWork around different filenames for DLLs
Noah Lev [Tue, 12 Oct 2021 20:30:15 +0000 (13:30 -0700)]
Work around different filenames for DLLs

2 years agoAdd long explanation for E0464
Noah Lev [Wed, 6 Oct 2021 20:01:43 +0000 (13:01 -0700)]
Add long explanation for E0464

The test is copied from `src/test/ui/crate-loading/crateresolve1.rs` and
its auxiliary tests. I added it to the `compile_fail` code example check
exemption list since it's hard if not impossible to reproduce this error
in a standalone code example.

2 years agoInclude rmeta candidates in "multiple matching crates" error
Noah Lev [Wed, 6 Oct 2021 02:43:44 +0000 (19:43 -0700)]
Include rmeta candidates in "multiple matching crates" error

Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436

2 years agoAdd test for showing rmeta candidates in error
Noah Lev [Wed, 6 Oct 2021 03:40:24 +0000 (20:40 -0700)]
Add test for showing rmeta candidates in error

2 years agoTest crate loading error stderr
Noah Lev [Wed, 6 Oct 2021 03:23:40 +0000 (20:23 -0700)]
Test crate loading error stderr

And remove E0464 from test-exemption list, since it now has a full test.

2 years agoSort candidate libraries by source path in error
Noah Lev [Wed, 6 Oct 2021 17:16:02 +0000 (10:16 -0700)]
Sort candidate libraries by source path in error

This makes the error output deterministic and thus testable.

2 years agoMake `rust.overflow-checks-std`option default to `rust.overflow-checks`.
Hans Kratz [Tue, 12 Oct 2021 19:28:49 +0000 (21:28 +0200)]
Make `rust.overflow-checks-std`option default to `rust.overflow-checks`.

2 years agoAdd --enable-debug-assertions-std option to configure script.
Hans Kratz [Tue, 12 Oct 2021 19:32:47 +0000 (21:32 +0200)]
Add --enable-debug-assertions-std option to configure script.

2 years agoAdd --enable-overflow-checks-std option to configure script.
Hans Kratz [Mon, 11 Oct 2021 21:05:26 +0000 (23:05 +0200)]
Add --enable-overflow-checks-std option to configure script.

2 years agoAdd missing entries for overflow-checks to config.toml.example.
Hans Kratz [Mon, 11 Oct 2021 17:54:27 +0000 (19:54 +0200)]
Add missing entries for overflow-checks to config.toml.example.

2 years agoAuto merge of #89813 - the8472:rollup-f1f99mb, r=the8472
bors [Tue, 12 Oct 2021 17:57:34 +0000 (17:57 +0000)]
Auto merge of #89813 - the8472:rollup-f1f99mb, r=the8472

Rollup of 7 pull requests

Successful merges:

 - #89778 (Add #[must_use] to as_type conversions)
 - #89784 (Remove built-in query cache_hit tracking)
 - #89796 (Add #[must_use] to non-mutating verb methods)
 - #89797 (Add #[must_use] to is_condition tests)
 - #89799 (fix minor spelling error in Poll::ready docs)
 - #89800 (Update books)
 - #89809 (Remap ssa RealPredicate to llvm RealPredicate)

Failed merges:

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