]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #78133 - JohnTitor:mir-tests, r=lcnr
Guillaume Gomez [Tue, 20 Oct 2020 19:46:38 +0000 (21:46 +0200)]
Rollup merge of #78133 - JohnTitor:mir-tests, r=lcnr

Add some MIR-related regression tests

Closes #68841
Closes #75053
Closes #76375
Closes #77911

I think they're fixed by #77306.

3 years agoRollup merge of #78129 - mbartlett21:patch-1, r=kennytm
Guillaume Gomez [Tue, 20 Oct 2020 19:46:37 +0000 (21:46 +0200)]
Rollup merge of #78129 - mbartlett21:patch-1, r=kennytm

Wrapping intrinsics doc links update.

The links in the wrapping intrinsics docs now refer to the `wrapping_*` functions, not the `checked_*` functions.

3 years agoRollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum
Guillaume Gomez [Tue, 20 Oct 2020 19:46:35 +0000 (21:46 +0200)]
Rollup merge of #78076 - est31:orphan_mod, r=Mark-Simulacrum

Move orphan module-name/mod.rs files into module-name.rs files

3 years agoRollup merge of #78070 - RalfJung:const-panic-test, r=oli-obk
Guillaume Gomez [Tue, 20 Oct 2020 19:46:33 +0000 (21:46 +0200)]
Rollup merge of #78070 - RalfJung:const-panic-test, r=oli-obk

we can test std and core panic macros together

r? @oli-obk

3 years agoRollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
Guillaume Gomez [Tue, 20 Oct 2020 19:46:32 +0000 (21:46 +0200)]
Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk

Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

Fixes #68010

r? @oli-obk

3 years agoRollup merge of #78046 - bugadani:issue-73827, r=nikic
Guillaume Gomez [Tue, 20 Oct 2020 19:46:30 +0000 (21:46 +0200)]
Rollup merge of #78046 - bugadani:issue-73827, r=nikic

Add codegen test for issue #73827

Closes #73827

3 years agoAuto merge of #78151 - tmiasko:disable-match-branch-simplification, r=wesleywiser
bors [Tue, 20 Oct 2020 16:59:23 +0000 (16:59 +0000)]
Auto merge of #78151 - tmiasko:disable-match-branch-simplification, r=wesleywiser

Disable MatchBranchSimplification

This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.

Found by validation from #77369 / #78147.

3 years agoAuto merge of #76893 - lcnr:existential-proj, r=estebank
bors [Tue, 20 Oct 2020 08:59:12 +0000 (08:59 +0000)]
Auto merge of #76893 - lcnr:existential-proj, r=estebank

Improve `skip_binder` usage during FlagComputation

It looks like there was previously a bug around `ExistentialPredicate::Projection` here, don't know how to best trigger that one to add a regression test though.

3 years agoAdd test for issue-77911
Yuki Okushi [Tue, 20 Oct 2020 08:07:56 +0000 (17:07 +0900)]
Add test for issue-77911

3 years agoAdd test for issue-76375
Yuki Okushi [Tue, 20 Oct 2020 08:07:41 +0000 (17:07 +0900)]
Add test for issue-76375

3 years agoAdd test for issue-75053
Yuki Okushi [Tue, 20 Oct 2020 08:07:27 +0000 (17:07 +0900)]
Add test for issue-75053

3 years agoAdd test for issue-68841
Yuki Okushi [Tue, 20 Oct 2020 08:07:11 +0000 (17:07 +0900)]
Add test for issue-68841

3 years agoAuto merge of #76696 - Aaron1011:tokenstream-avoid-clone, r=petrochenkov
bors [Tue, 20 Oct 2020 05:45:08 +0000 (05:45 +0000)]
Auto merge of #76696 - Aaron1011:tokenstream-avoid-clone, r=petrochenkov

Avoid cloning the contents of a `TokenStream` in a few places

3 years agoWrapping intrinsics update link
mbartlett21 [Tue, 20 Oct 2020 04:09:01 +0000 (14:09 +1000)]
Wrapping intrinsics update link

Now refers to `wrapping_*`, not `checked_*` for wrapping intrinsics.

3 years agoAuto merge of #78127 - JohnTitor:rollup-p1bxtqq, r=JohnTitor
bors [Tue, 20 Oct 2020 03:13:30 +0000 (03:13 +0000)]
Auto merge of #78127 - JohnTitor:rollup-p1bxtqq, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #77612 (BTreeMap: test invariants more thoroughly and more readably)
 - #77761 (Assert that pthread mutex initialization succeeded)
 - #77778 ([x.py setup] Allow setting up git hooks from other worktrees)
 - #77838 (const keyword: brief paragraph on 'const fn')
 - #77923 ([net] apply clippy lints)
 - #77931 (Fix false positive for `unused_parens` lint)
 - #77959 (Tweak ui-tests structure)
 - #78105 (change name in .mailmap)
 - #78111 (Trait predicate ambiguities are not always in `Self`)
 - #78121 (Do not ICE on pattern that uses a binding multiple times in generator)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78121 - LeSeulArtichaut:issue-78115, r=tmandry
Yuki Okushi [Tue, 20 Oct 2020 03:11:13 +0000 (12:11 +0900)]
Rollup merge of #78121 - LeSeulArtichaut:issue-78115, r=tmandry

Do not ICE on pattern that uses a binding multiple times in generator

Fixes #78115.
r? @tmandry

3 years agoRollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr
Yuki Okushi [Tue, 20 Oct 2020 03:11:11 +0000 (12:11 +0900)]
Rollup merge of #78111 - SNCPlay42:not-always-self, r=lcnr

Trait predicate ambiguities are not always in `Self`

When reporting ambiguities in trait predicates, the compiler incorrectly assumed the ambiguity was always in the type the trait should be implemented on, and never the generic parameters of the trait. This caused silly suggestions for predicates like `<KnownType as Trait<_>>`, such as giving explicit types to completely unrelated variables that happened to be of type `KnownType`.

This also reverts #73027, which worked around this issue in some cases and does not appear to be necessary any more.

fixes #77982
fixes #78055

3 years agoRollup merge of #78105 - lcnr:namesNstuff, r=Mark-Simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:11:10 +0000 (12:11 +0900)]
Rollup merge of #78105 - lcnr:namesNstuff, r=Mark-Simulacrum

change name in .mailmap

3 years agoRollup merge of #77959 - JohnTitor:tweak-test-structure, r=petrochenkov
Yuki Okushi [Tue, 20 Oct 2020 03:11:08 +0000 (12:11 +0900)]
Rollup merge of #77959 - JohnTitor:tweak-test-structure, r=petrochenkov

Tweak ui-tests structure

We have some similar name dirs in ui tests, e.g. `associated-type` and `associated-types` and it can be an issue when we add a test, "which is the right place?". At a glance, it seems they can be merged into one directory so let's merge them to avoid some confusion :)

3 years agoRollup merge of #77931 - aticu:fix_60336, r=petrochenkov
Yuki Okushi [Tue, 20 Oct 2020 03:11:06 +0000 (12:11 +0900)]
Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov

Fix false positive for `unused_parens` lint

Fixes #60336

3 years agoRollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm
Yuki Okushi [Tue, 20 Oct 2020 03:11:04 +0000 (12:11 +0900)]
Rollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm

[net] apply clippy lints

Applied helpful clippy lints to the network std library module.

3 years agoRollup merge of #77838 - RalfJung:const-fn, r=kennytm
Yuki Okushi [Tue, 20 Oct 2020 03:11:02 +0000 (12:11 +0900)]
Rollup merge of #77838 - RalfJung:const-fn, r=kennytm

const keyword: brief paragraph on 'const fn'

`const fn` were mentioned in the title, but called "deterministic functions" which is not their main property (though at least currently it is a consequence of being const-evaluable). This adds a brief paragraph discussing them, also in the hopes of clarifying that they do *not* have any effect on run-time uses.

3 years agoRollup merge of #77778 - jyn514:git-hook, r=mark-simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:11:00 +0000 (12:11 +0900)]
Rollup merge of #77778 - jyn514:git-hook, r=mark-simulacrum

[x.py setup] Allow setting up git hooks from other worktrees

Closes https://github.com/rust-lang/rust/issues/77684
r? @caass

3 years agoRollup merge of #77761 - tmiasko:pthread-mutex, r=cuviper
Yuki Okushi [Tue, 20 Oct 2020 03:10:58 +0000 (12:10 +0900)]
Rollup merge of #77761 - tmiasko:pthread-mutex, r=cuviper

Assert that pthread mutex initialization succeeded

If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.

In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.

Assert that initialization succeeds to ensure that mutex guarantees
mutual exclusion.

Fixes #34966.

3 years agoRollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum
Yuki Okushi [Tue, 20 Oct 2020 03:10:52 +0000 (12:10 +0900)]
Rollup merge of #77612 - ssomers:btree_cleanup_2, r=Mark-Simulacrum

BTreeMap: test invariants more thoroughly and more readably

r? @Mark-Simulacrum

3 years agoDisable MatchBranchSimplification
Tomasz Miąsko [Tue, 20 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Disable MatchBranchSimplification

This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.

3 years agoCheck that pthread mutex initialization succeeded
Tomasz Miąsko [Tue, 20 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Check that pthread mutex initialization succeeded

If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.

In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.

Check that initialization succeeds to ensure that mutex guarantees
mutual exclusion.

3 years agoAdd regression test
LeSeulArtichaut [Mon, 19 Oct 2020 21:32:07 +0000 (23:32 +0200)]
Add regression test

3 years agoDo not ICE on pattern that uses a binding multiple times in generator
LeSeulArtichaut [Mon, 19 Oct 2020 21:14:28 +0000 (23:14 +0200)]
Do not ICE on pattern that uses a binding multiple times in generator

3 years agorevert workaround #73027
SNCPlay42 [Mon, 19 Oct 2020 16:58:44 +0000 (17:58 +0100)]
revert workaround #73027

3 years agodon't assume trait ambiguity happens in `Self`
SNCPlay42 [Mon, 19 Oct 2020 16:42:57 +0000 (17:42 +0100)]
don't assume trait ambiguity happens in `Self`

3 years agoAuto merge of #78106 - GuillaumeGomez:rollup-06vwk7p, r=GuillaumeGomez
bors [Mon, 19 Oct 2020 17:53:17 +0000 (17:53 +0000)]
Auto merge of #78106 - GuillaumeGomez:rollup-06vwk7p, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #77877 (Use `try{}` in `try_fold` to decouple iterators in the library from `Try` details)
 - #78089 (Fix issue with specifying generic arguments for primitive types)
 - #78099 (Add missing punctuation)
 - #78103 (Add link to rustdoc book in rustdoc help popup)

Failed merges:

r? `@ghost`

3 years agoAvoid cloning the contents of a `TokenStream` in a few places
Aaron Hill [Mon, 14 Sep 2020 05:45:10 +0000 (01:45 -0400)]
Avoid cloning the contents of a `TokenStream` in a few places

3 years agoRollup merge of #78103 - GuillaumeGomez:rustdoc-book, r=jyn514
Guillaume Gomez [Mon, 19 Oct 2020 16:20:26 +0000 (18:20 +0200)]
Rollup merge of #78103 - GuillaumeGomez:rustdoc-book, r=jyn514

Add link to rustdoc book in rustdoc help popup

Part of #75520.

It looks like this:

![Screenshot from 2020-10-19 13-46-02](https://user-images.githubusercontent.com/3050060/96446334-934d6900-1211-11eb-8fdc-133fecc8c30d.png)
![Screenshot from 2020-10-19 13-43-46](https://user-images.githubusercontent.com/3050060/96446335-947e9600-1211-11eb-955c-68af5292aecc.png)
![Screenshot from 2020-10-19 13-37-26](https://user-images.githubusercontent.com/3050060/96446337-947e9600-1211-11eb-9a2e-399b99178a65.png)

r? @jyn514

3 years agoRollup merge of #78099 - pierwill:patch-5, r=jonas-schievink
Guillaume Gomez [Mon, 19 Oct 2020 16:20:24 +0000 (18:20 +0200)]
Rollup merge of #78099 - pierwill:patch-5, r=jonas-schievink

Add missing punctuation

3 years agoRollup merge of #78089 - varkor:opt_const_param_of-error, r=lcnr
Guillaume Gomez [Mon, 19 Oct 2020 16:20:23 +0000 (18:20 +0200)]
Rollup merge of #78089 - varkor:opt_const_param_of-error, r=lcnr

Fix issue with specifying generic arguments for primitive types

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

r? @lcnr

3 years agoRollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster
Guillaume Gomez [Mon, 19 Oct 2020 16:20:20 +0000 (18:20 +0200)]
Rollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster

Use `try{}` in `try_fold` to decouple iterators in the library from `Try` details

I'd like to experiment with changing the `?`/`try` desugaring and correspondingly the `Try` trait (see #42327 for discussions about the suboptimalities of the current one) and this change would keep from needing any `cfg(bootstrap)` in iterator things.

This will be lowered to the same thing, so shouldn't cause any perf issues:
https://github.com/rust-lang/rust/blob/08e2d4616613716362b4b49980ff303f2b9ae654/compiler/rustc_ast_lowering/src/expr.rs#L428-L429

But ~~I'll trigger~~ I've triggered [a perf run](https://perf.rust-lang.org/compare.html?start=d65c08e9cc164b7b44de53503fae859a4fafd976&end=2c067c5235e779cd75e9f0cdfe572c64f1a12b9b) just in case.

~~EDIT: changed to a draft because of the rustfmt-only syntax error.  zulip thread about it: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/New.20bootstrap.20rustfmt.20doesn't.20support.20syntax.20from.20sept.3F/near/213098097~~

EDIT: This now includes a rustfmt version bump to get through tidy.

3 years agoAuto merge of #77908 - bugadani:obl-forest, r=nnethercote
bors [Mon, 19 Oct 2020 15:14:15 +0000 (15:14 +0000)]
Auto merge of #77908 - bugadani:obl-forest, r=nnethercote

Try to make ObligationForest more efficient

This PR tries to decrease the number of allocations in ObligationForest, as well as moves some cold path code to an uninlined function.

3 years agoAdd link to rustdoc book in rustdoc help popup
Guillaume Gomez [Mon, 19 Oct 2020 11:44:27 +0000 (13:44 +0200)]
Add link to rustdoc book in rustdoc help popup

3 years agochange name in mailmap
Bastian Kauschke [Mon, 19 Oct 2020 13:23:32 +0000 (15:23 +0200)]
change name in mailmap

3 years agoRevert "[net] clippy: needless_update"
wcampbell [Mon, 19 Oct 2020 11:22:45 +0000 (07:22 -0400)]
Revert "[net] clippy: needless_update"

This reverts commit 058699d0a2fca02127761f014d0ecfce1c5541ec.

3 years agoBTreeMap: test invariants more thoroughly and more readably
Stein Somers [Mon, 5 Oct 2020 23:50:35 +0000 (01:50 +0200)]
BTreeMap: test invariants more thoroughly and more readably

3 years agoAdd missing punctuation
pierwill [Mon, 19 Oct 2020 06:03:16 +0000 (23:03 -0700)]
Add missing punctuation

3 years agoAuto merge of #78087 - camelid:bootstrap-print-units, r=jyn514
bors [Mon, 19 Oct 2020 04:34:34 +0000 (04:34 +0000)]
Auto merge of #78087 - camelid:bootstrap-print-units, r=jyn514

bootstrap: Print units for "finished in xxx" message

It now says "finished in xxx seconds".

Also slightly improved some wording in the README.

3 years agoAuto merge of #77278 - camelid:use-correct-article, r=estebank
bors [Mon, 19 Oct 2020 02:19:21 +0000 (02:19 +0000)]
Auto merge of #77278 - camelid:use-correct-article, r=estebank

Use correct article in help message for conversion or cast

Before it always used `an`; now it uses the correct article for the type.

3 years agoDon't ICE if called with a `TyKind::Error`
Camelid [Mon, 19 Oct 2020 00:37:26 +0000 (17:37 -0700)]
Don't ICE if called with a `TyKind::Error`

It felt too harsh to estebank and others to ICE even though it's
technically a mistake to show a `TyKind::Error`.

3 years agoAuto merge of #77874 - camelid:range-docs-readability, r=scottmcm
bors [Mon, 19 Oct 2020 00:11:08 +0000 (00:11 +0000)]
Auto merge of #77874 - camelid:range-docs-readability, r=scottmcm

Improve range docs

* Improve code formatting and legibility
* Various other readability improvements

3 years agoImprove range docs
Camelid [Mon, 12 Oct 2020 21:53:41 +0000 (14:53 -0700)]
Improve range docs

* Mention that `RangeFull` is a ZST and thus a singleton
* Improve code formatting and legibility
* Various other readability improvements

3 years agoFix issue with specifying generic arguments for primitive types
varkor [Sun, 18 Oct 2020 21:40:50 +0000 (22:40 +0100)]
Fix issue with specifying generic arguments for primitive types

3 years agoAuto merge of #78075 - est31:remove_redundant_static, r=jonas-schievink
bors [Sun, 18 Oct 2020 21:02:05 +0000 (21:02 +0000)]
Auto merge of #78075 - est31:remove_redundant_static, r=jonas-schievink

Remove redundant 'static

3 years agobootstrap: Print units for "finished in xxx" message
Camelid [Sun, 18 Oct 2020 20:54:51 +0000 (13:54 -0700)]
bootstrap: Print units for "finished in xxx" message

It now says "finished in xxx seconds".

Also slightly improved some wording in the README.

3 years agoMove orphan module-name/mod.rs files into module-name.rs files
est31 [Sun, 18 Oct 2020 15:52:01 +0000 (17:52 +0200)]
Move orphan module-name/mod.rs files into module-name.rs files

3 years agoAuto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus
bors [Sun, 18 Oct 2020 18:50:43 +0000 (18:50 +0000)]
Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus

Move `slice::check_range` to `RangeBounds`

Since this method doesn't take a slice anymore (#76662), it makes more sense to define it on `RangeBounds`.

Questions:
- Should the new method be `assert_len` or `assert_length`?

3 years agoAuto merge of #77306 - lcnr:inline-ok, r=eddyb
bors [Sun, 18 Oct 2020 16:10:00 +0000 (16:10 +0000)]
Auto merge of #77306 - lcnr:inline-ok, r=eddyb

normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`

3 years agoRemove redundant 'static in the compiler
est31 [Sun, 18 Oct 2020 15:28:00 +0000 (17:28 +0200)]
Remove redundant 'static in the compiler

3 years agoRemove redundant 'static from library crates
est31 [Sun, 18 Oct 2020 15:14:25 +0000 (17:14 +0200)]
Remove redundant 'static from library crates

3 years agoAuto merge of #78066 - bugadani:wat, r=jonas-schievink
bors [Sun, 18 Oct 2020 13:50:31 +0000 (13:50 +0000)]
Auto merge of #78066 - bugadani:wat, r=jonas-schievink

Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.

3 years agowe can test std and core panic macros together
Ralf Jung [Sun, 18 Oct 2020 12:34:30 +0000 (14:34 +0200)]
we can test std and core panic macros together

3 years agoAuto merge of #78058 - bugadani:arena2, r=lcnr
bors [Sun, 18 Oct 2020 11:19:14 +0000 (11:19 +0000)]
Auto merge of #78058 - bugadani:arena2, r=lcnr

Make sure arenas don't allocate bigger than HUGE_PAGE

Right now, arenas allocate based on the size of the last chunk. It is possible for a `grow` call to allocate a chunk that is not a multiple of `PAGE`, and this size is doubled for each subsequent allocation. This means, instead of `HUGE_PAGE`, the biggest page possible is actually unknown.

This change fixes this, and also removes an unnecessary checked multiplication. It is still possible to allocate bigger than `HUGE_PAGE` pages, but this will only happen as many times as absolutely necessary.

3 years agoAuto merge of #78035 - camelid:basic-block-pointer-note, r=RalfJung
bors [Sun, 18 Oct 2020 09:08:00 +0000 (09:08 +0000)]
Auto merge of #78035 - camelid:basic-block-pointer-note, r=RalfJung

Note that `BasicBlock` is just an index

r? `@RalfJung`

3 years agoReplace unnecessary map_or_else with map_or
Dániel Buga [Sun, 18 Oct 2020 08:59:03 +0000 (10:59 +0200)]
Replace unnecessary map_or_else with map_or

3 years agoZip -> Enumerate
Dániel Buga [Sun, 18 Oct 2020 08:43:01 +0000 (10:43 +0200)]
Zip -> Enumerate

3 years agoNo need to map the max_distance
Dániel Buga [Fri, 16 Oct 2020 10:49:25 +0000 (12:49 +0200)]
No need to map the max_distance

3 years agoEarly return to decrease indentation
Dániel Buga [Wed, 14 Oct 2020 08:58:12 +0000 (10:58 +0200)]
Early return to decrease indentation

3 years agoRemove weird slice conversion
Dániel Buga [Wed, 14 Oct 2020 08:48:03 +0000 (10:48 +0200)]
Remove weird slice conversion

3 years agoClean up surprising borrow
Dániel Buga [Wed, 14 Oct 2020 08:43:51 +0000 (10:43 +0200)]
Clean up surprising borrow

3 years agoAuto merge of #78047 - khyperia:set_span_mut, r=bjorn3
bors [Sun, 18 Oct 2020 05:36:23 +0000 (05:36 +0000)]
Auto merge of #78047 - khyperia:set_span_mut, r=bjorn3

Make set_span take mut self

This was a mistake in https://github.com/rust-lang/rust/pull/77614

It's not a _huge_ deal, because backends can always implement this with interior mutability, but it's nice to avoid interior mutability when possible. For context, the `set_source_location` method, called alongside `set_span`, also takes `&mut self`.

r? `@eddyb`

3 years agoAuto merge of #74480 - yoshuawuyts:hardware_threads, r=dtolnay
bors [Sun, 18 Oct 2020 02:28:21 +0000 (02:28 +0000)]
Auto merge of #74480 - yoshuawuyts:hardware_threads, r=dtolnay

Add std::thread::available_concurrency

This PR adds a counterpart to [C++'s `std::thread::hardware_concurrency`](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency) to Rust, tracking issue https://github.com/rust-lang/rust/issues/74479.

cc/ `@rust-lang/libs`

## Motivation

Being able to know how many hardware threads a platform supports is a core part of building multi-threaded code. In C++ 11 this has become available through the [`std::thread::hardware_concurrency`](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency) API. Currently in Rust most of the ecosystem depends on the [`num_cpus` crate](https://docs.rs/num_cpus/1.13.0/num_cpus/) ([no.35 in top 500 crates](https://docs.google.com/spreadsheets/d/1wwahRMHG3buvnfHjmPQFU4Kyfq15oTwbfsuZpwHUKc4/edit#gid=1253069234)) to provide this functionality. This PR proposes an API to provide access to the number of hardware threads available on a given platform.

__edit (2020-07-24):__ The purpose of this PR is to provide a hint for how many threads to spawn to saturate the processor. There's value in introducing APIs for NUMA and Windows processor groups, but those are intentionally out of scope for this PR. See: https://github.com/rust-lang/rust/pull/74480#issuecomment-662116186.

## Naming

Discussing the naming of the API on Zulip surfaced two options:

- `std::thread::hardware_concurrency`
- `std::thread::hardware_threads`

Both options seemed acceptable, but overall people seem to gravitate the most towards `hardware_threads`. Additionally `@jonas-schievink` pointed out that the "hardware threads" terminology is well-established and is used in among other the [RISC-V specification](https://riscv.org/specifications/isa-spec-pdf/) (page 20):

> A component is termed a core if it contains an independent instruction fetch unit. A RISC-V-compatible core might support multiple RISC-V-compatible __hardware threads__, or harts, through multithreading.

It's also worth noting that [the original paper introducing C++'s `std::thread` submodule](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2320.html) unfortunately doesn't feature any discussion on the naming of `hardware_concurrency`, so we can't use that to help inform our decision here.

## Return type

An important consideration `@joshtriplett` brought up is that we don't want to default to `1` for platforms where the number of available threads cannot be retrieved. Instead we want to inform the users of the fact that we don't know and allow them to handle that case. Which is why this PR uses `Option<NonZeroUsize>` as its return type, where `None` is returned on platforms where we don't know the number of hardware threads available.

The reasoning for `NonZeroUsize` vs `usize` is that if the number of threads for a platform are known, they'll always be at least 1. As evidenced by the example the `NonZero*` family of APIs may currently not be the most ergonomic to use, but improving the ergonomics of them is something that I think we can address separately.

## Implementation

`@Mark-Simulacrum` pointed out that most of the code we wanted to expose here was already available under `libtest`. So this PR mostly moves the internal code of libtest into a public API.

3 years agoAuto merge of #77956 - JohnTitor:more-tests, r=nagisa
bors [Sun, 18 Oct 2020 00:19:24 +0000 (00:19 +0000)]
Auto merge of #77956 - JohnTitor:more-tests, r=nagisa

Add some more regression tests

This is another round of #77741. Tested with `debug-assertions=true` and it passed on my local.
Closes #70877
Closes #70944
Closes #71659
Closes #74816
Closes #75707
Closes #75983
(Skipped #63355 because I'm not sure about the error.)

3 years agoUse smaller example for issue-71659
Yuki Okushi [Sat, 17 Oct 2020 23:13:25 +0000 (08:13 +0900)]
Use smaller example for issue-71659

3 years agoAdd test for issue-75983
Yuki Okushi [Wed, 14 Oct 2020 23:36:24 +0000 (08:36 +0900)]
Add test for issue-75983

3 years agoAdd test for issue-75707
Yuki Okushi [Wed, 14 Oct 2020 23:36:16 +0000 (08:36 +0900)]
Add test for issue-75707

3 years agoAdd test for issue-74816
Yuki Okushi [Wed, 14 Oct 2020 23:36:04 +0000 (08:36 +0900)]
Add test for issue-74816

3 years agoAdd test for issue-71659
Yuki Okushi [Wed, 14 Oct 2020 23:35:45 +0000 (08:35 +0900)]
Add test for issue-71659

3 years agoAdd test for issue-70944
Yuki Okushi [Wed, 14 Oct 2020 23:35:29 +0000 (08:35 +0900)]
Add test for issue-70944

3 years agoAdd test for issue-70877
Yuki Okushi [Wed, 14 Oct 2020 23:35:18 +0000 (08:35 +0900)]
Add test for issue-70877

3 years agoAuto merge of #78041 - luqmana:lld-tls-alignment, r=nikic
bors [Sat, 17 Oct 2020 21:59:28 +0000 (21:59 +0000)]
Auto merge of #78041 - luqmana:lld-tls-alignment, r=nikic

LLVM: Backport fix for LLD COFF TLS Alignment.

Update LLVM submodule to pull in changes from https://github.com/rust-lang/llvm-project/pull/81.

Fixes #72145.

3 years agoMake sure arenas don't allocate bigger than HUGE_PAGE
Dániel Buga [Sat, 17 Oct 2020 17:07:16 +0000 (19:07 +0200)]
Make sure arenas don't allocate bigger than HUGE_PAGE

3 years agoNote that `BasicBlock` is just an index
Camelid [Sat, 17 Oct 2020 03:35:56 +0000 (20:35 -0700)]
Note that `BasicBlock` is just an index

3 years agoOptimize const value interning for ZST types
Wesley Wiser [Sat, 17 Oct 2020 19:47:27 +0000 (15:47 -0400)]
Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

3 years agoAuto merge of #78060 - JohnTitor:rollup-uou8vyu, r=JohnTitor
bors [Sat, 17 Oct 2020 19:39:26 +0000 (19:39 +0000)]
Auto merge of #78060 - JohnTitor:rollup-uou8vyu, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #75802 (resolve: Do not put nonexistent crate `meta` into prelude)
 - #76607 (Modify executable checking to be more universal)
 - #77851 (BTreeMap: refactor Entry out of map.rs into its own file)
 - #78043 (Fix grammar in note for orphan-rule error [E0210])
 - #78048 (Suggest correct place to add `self` parameter when inside closure)
 - #78050 (Small CSS cleanup)
 - #78059 (Set `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78059 - JohnTitor:fix-linkcheck, r=ehuss
Yuki Okushi [Sat, 17 Oct 2020 19:11:15 +0000 (04:11 +0900)]
Rollup merge of #78059 - JohnTitor:fix-linkcheck, r=ehuss

Set `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker

This is found in https://github.com/rust-lang/nomicon/pull/240.
It seems the spurious failure shows up without this flag.

3 years agoRollup merge of #78050 - GuillaumeGomez:small-css-cleanup, r=jyn514
Yuki Okushi [Sat, 17 Oct 2020 19:11:13 +0000 (04:11 +0900)]
Rollup merge of #78050 - GuillaumeGomez:small-css-cleanup, r=jyn514

Small CSS cleanup

r? @jyn514

3 years agoRollup merge of #78048 - blyxxyz:e0424-improve-self-placement, r=lcnr
Yuki Okushi [Sat, 17 Oct 2020 19:11:11 +0000 (04:11 +0900)]
Rollup merge of #78048 - blyxxyz:e0424-improve-self-placement, r=lcnr

Suggest correct place to add `self` parameter when inside closure

It would incorrectly suggest adding it as a parameter to the closure instead of the containing function.

[For example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1936bcd1e5f981573386e0cee985c3c0):
```
help: add a `self` receiver parameter to make the associated `fn` a method
  |
5 |         let _ = || self&self;
  |                        ^^^^^
```

`DiagnosticMetadata.current_function` is only used for these messages so tweaking its behavior should be ok.

3 years agoRollup merge of #78043 - willcrozi:e0210-error-note-fix, r=lcnr
Yuki Okushi [Sat, 17 Oct 2020 19:11:09 +0000 (04:11 +0900)]
Rollup merge of #78043 - willcrozi:e0210-error-note-fix, r=lcnr

Fix grammar in note for orphan-rule error [E0210]

Fixes the grammar in the error note for [E0210] from:

_"= note: implementing a foreign trait is only possible if at least one of the types for which **is it** implemented is local"_

to:

_"= note: implementing a foreign trait is only possible if at least one of the types for which **it is** implemented is local"_

The content of this commit is the result of running the following command at the repository root:

`find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/which is it implemented/which it is implemented/g'`

3 years agoRollup merge of #77851 - exrook:split-btreemap, r=dtolnay
Yuki Okushi [Sat, 17 Oct 2020 19:11:07 +0000 (04:11 +0900)]
Rollup merge of #77851 - exrook:split-btreemap, r=dtolnay

BTreeMap: refactor Entry out of map.rs into its own file

btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom.

I've created this PR because the changes I've made in #77438 will push `map.rs` over the 3000 line limit and cause tidy to complain.

I picked `Entry` to factor out because it feels less tightly coupled to the rest of `BTreeMap` than the various iterator implementations.

Related: #60302

3 years agoRollup merge of #76607 - Mark-Simulacrum:tidy-bins, r=pnkfelix
Yuki Okushi [Sat, 17 Oct 2020 19:11:05 +0000 (04:11 +0900)]
Rollup merge of #76607 - Mark-Simulacrum:tidy-bins, r=pnkfelix

Modify executable checking to be more universal

This uses a dummy file to check if the filesystem being used supports the executable bit in general.

Supersedes #74753.

3 years agoRollup merge of #75802 - petrochenkov:nometa, r=nikomatsakis
Yuki Okushi [Sat, 17 Oct 2020 19:11:03 +0000 (04:11 +0900)]
Rollup merge of #75802 - petrochenkov:nometa, r=nikomatsakis

resolve: Do not put nonexistent crate `meta` into prelude

Before the 2018 edition release there was some vague suggestion about adding a crate named `meta` to the standard distribution.
On this basis the name `meta` was "partially reserved" by putting `meta` into extern prelude (this means importing something named `meta` will result in an ambiguity error, for example).
This only caused confusion so far, and two years later there are no specific plans to add such crate.

If some standard crate (named `meta` or not) is added in the future, then cargo will hopefully already have ability to put it into extern prelude explicitly through `Cargo.toml`.
Otherwise, it could be added to extern prelude by the compiler at edition boundary.

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

3 years agoAppease the almightly lord clippy, hallowed be thy name
Jacob Hughes [Sat, 17 Oct 2020 17:45:40 +0000 (13:45 -0400)]
Appease the almightly lord clippy, hallowed be thy name

3 years agoSet `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker
Yuki Okushi [Sat, 17 Oct 2020 17:30:08 +0000 (02:30 +0900)]
Set `MDBOOK_OUTPUT__HTML__INPUT_404` on linkchecker

3 years agoAuto merge of #77373 - jonas-schievink:rm-rf-copy-prop, r=oli-obk
bors [Sat, 17 Oct 2020 16:57:21 +0000 (16:57 +0000)]
Auto merge of #77373 - jonas-schievink:rm-rf-copy-prop, r=oli-obk

Remove the old copy propagation pass

This pass was added a long time ago, and has not really seen much improvement since (apart from some great work in https://github.com/rust-lang/rust/pull/76569 that unfortunately ran into preexisting soundness issues). It is slow and unsound, and we now have a destination propagation pass that performs a related optimization and could be extended.

Closes https://github.com/rust-lang/rust/issues/36673
Closes https://github.com/rust-lang/rust/issues/73717
Closes https://github.com/rust-lang/rust/issues/76740

3 years agoAuto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk
bors [Sat, 17 Oct 2020 14:44:51 +0000 (14:44 +0000)]
Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk

Implement const expressions and patterns (RFC 2920)

cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`

3 years agoSmall CSS cleanup
Guillaume Gomez [Sat, 17 Oct 2020 13:17:00 +0000 (15:17 +0200)]
Small CSS cleanup

3 years agoAuto merge of #78039 - tmiasko:unreachable-block, r=Mark-Simulacrum
bors [Sat, 17 Oct 2020 12:36:32 +0000 (12:36 +0000)]
Auto merge of #78039 - tmiasko:unreachable-block, r=Mark-Simulacrum

Remove unused cached_unreachable_block from MIR builder

3 years agoSuggest correct place to add `self` parameter when inside closure
Jan Verbeek [Sat, 17 Oct 2020 11:36:59 +0000 (13:36 +0200)]
Suggest correct place to add `self` parameter when inside closure

It would incorrectly suggest adding it as a parameter to the closure instead of the
containing function.

3 years agoMake set_span take mut self
khyperia [Sat, 17 Oct 2020 11:28:58 +0000 (13:28 +0200)]
Make set_span take mut self

3 years agoAdd codegen test for issue #73827
Dániel Buga [Sat, 17 Oct 2020 11:17:31 +0000 (13:17 +0200)]
Add codegen test for issue #73827

3 years agoresolve: Do not put nonexistent crate `meta` into prelude
Vadim Petrochenkov [Sat, 22 Aug 2020 09:28:09 +0000 (12:28 +0300)]
resolve: Do not put nonexistent crate `meta` into prelude

3 years agoAuto merge of #77685 - jackh726:binder-map, r=lcnr
bors [Sat, 17 Oct 2020 10:28:52 +0000 (10:28 +0000)]
Auto merge of #77685 - jackh726:binder-map, r=lcnr

Use rebind instead of Binder::bind when possible

These are really only the easy places. I just searched for `Binder::bind` and replaced where it straightforward.

r? `@lcnr`
cc. `@nikomatsakis`

3 years agoFix grammar in note for orphan-rule error [E0210]
Will Crozier [Sat, 17 Oct 2020 09:56:54 +0000 (10:56 +0100)]
Fix grammar in note for orphan-rule error [E0210]