]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoPackage more llvm-* tools in the rust-dev component, for run-make-fulldeps tests
Simon Sapin [Tue, 20 Oct 2020 07:14:27 +0000 (09:14 +0200)]
Package more llvm-* tools in the rust-dev component, for run-make-fulldeps tests

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

3 years agoUse DroplessArena for variance inference
Dániel Buga [Tue, 20 Oct 2020 09:05:00 +0000 (11:05 +0200)]
Use DroplessArena for variance inference

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 agoResolve: Use dropless arena for types that don't need drop
Dániel Buga [Tue, 20 Oct 2020 08:37:56 +0000 (10:37 +0200)]
Resolve: Use dropless arena for types that don't need drop

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 inline const macro test
Santiago Pastorino [Mon, 19 Oct 2020 21:55:43 +0000 (18:55 -0300)]
Add inline const macro test

3 years agoAllow NtBlock to parse on check inline const next token
Santiago Pastorino [Mon, 19 Oct 2020 19:57:04 +0000 (16:57 -0300)]
Allow NtBlock to parse on check inline const next token

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 agoDo not print braces again print_anon_const already does it
Santiago Pastorino [Mon, 19 Oct 2020 19:26:13 +0000 (16:26 -0300)]
Do not print braces again print_anon_const already does it

3 years agoRewrite `collect_tokens` implementations to use a flattened buffer
Aaron Hill [Sun, 27 Sep 2020 01:56:29 +0000 (21:56 -0400)]
Rewrite `collect_tokens` implementations to use a flattened buffer

Instead of trying to collect tokens at each depth, we 'flatten' the
stream as we go allong, pushing open/close delimiters to our buffer
just like regular tokens. One capturing is complete, we reconstruct a
nested `TokenTree::Delimited` structure, producing a normal
`TokenStream`.

The reconstructed `TokenStream` is not created immediately - instead, it is
produced on-demand by a closure (wrapped in a new `LazyTokenStream` type). This
closure stores a clone of the original `TokenCursor`, plus a record of the
number of calls to `next()/next_desugared()`. This is sufficient to reconstruct
the tokenstream seen by the callback without storing any additional state. If
the tokenstream is never used (e.g. when a captured `macro_rules!` argument is
never passed to a proc macro), we never actually create a `TokenStream`.

This implementation has a number of advantages over the previous one:

* It is significantly simpler, with no edge cases around capturing the
  start/end of a delimited group.

* It can be easily extended to allow replacing tokens an an arbitrary
  'depth' by just using `Vec::splice` at the proper position. This is
  important for PR #76130, which requires us to track information about
  attributes along with tokens.

* The lazy approach to `TokenStream` construction allows us to easily
  parse an AST struct, and then decide after the fact whether we need a
  `TokenStream`. This will be useful when we start collecting tokens for
  `Attribute` - we can discard the `LazyTokenStream` if the parsed
  attribute doesn't need tokens (e.g. is a builtin attribute).

The performance impact seems to be neglibile (see
https://github.com/rust-lang/rust/pull/77250#issuecomment-703960604). There is a
small slowdown on a few benchmarks, but it only rises above 1% for incremental
builds, where it represents a larger fraction of the much smaller instruction
count. There a ~1% speedup on a few other incremental benchmarks - my guess is
that the speedups and slowdowns will usually cancel out in practice.

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 agofix Rvalue::ty for ThreadLocalRef
Ralf Jung [Mon, 19 Oct 2020 08:53:20 +0000 (10:53 +0200)]
fix Rvalue::ty for ThreadLocalRef

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 agoRemove <CTX: QueryContext> in a bunch of places.
Julian Wollersberger [Mon, 12 Oct 2020 14:29:41 +0000 (16:29 +0200)]
Remove <CTX: QueryContext> in a bunch of places.
It was only needed by `find_cycle_in_stack()` in job.rs, but needed to be forwarded through dozens of types.

3 years agoCalculate visibilities once in resolve
Vadim Petrochenkov [Fri, 16 Oct 2020 23:28:11 +0000 (02:28 +0300)]
Calculate visibilities once in resolve

Then use them through a query based on resolver outputs

3 years agofix static_ptr_ty for foreign statics, and more comments in check_unsafety
Ralf Jung [Mon, 19 Oct 2020 07:47:18 +0000 (09:47 +0200)]
fix static_ptr_ty for foreign statics, and more comments in check_unsafety

3 years agoremove what seems to be an outdated comment
Ralf Jung [Mon, 19 Oct 2020 07:46:18 +0000 (09:46 +0200)]
remove what seems to be an outdated comment

Even in the PR that introduced this comment, it does not seem like these locals are actually ignored -- just their `source_info` is adjusted:
https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139

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

3 years agoRefactor liveness-issue-77915 to liveness-asm and improve tests
Olivia Crain [Mon, 19 Oct 2020 04:52:15 +0000 (23:52 -0500)]
Refactor liveness-issue-77915 to liveness-asm and improve tests

3 years agoMark InOut operands as used in RWU table with write_place
Olivia Crain [Mon, 19 Oct 2020 04:51:10 +0000 (23:51 -0500)]
Mark InOut operands as used in RWU table with write_place

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 agorustdoc: Show the correct source filename, without `.html`
Camelid [Mon, 19 Oct 2020 02:38:47 +0000 (19:38 -0700)]
rustdoc: Show the correct source filename, without `.html`

Previously the title would be

    lib.rs.html -- source

if `lib.rs` was the actual source filename. Now the title is

    lib.rs – source

(note the en dash).

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 agoGreatly improve display for small mobile devices screens
Guillaume Gomez [Sun, 18 Oct 2020 19:54:59 +0000 (21:54 +0200)]
Greatly improve display for small mobile devices screens

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 agoBTreeMap: split off most code of remove and split_off
Stein Somers [Sat, 17 Oct 2020 15:00:59 +0000 (17:00 +0200)]
BTreeMap: split off most code of remove and split_off

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 agoImprove wording of "cannot multiply" type error
Camelid [Sun, 18 Oct 2020 02:59:51 +0000 (19:59 -0700)]
Improve wording of "cannot multiply" type error

For example, if you had this code:

    fn foo(x: i32, y: f32) -> f32 {
        x * y
    }

You would get this error:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

However, that's not usually how people describe multiplication. People
usually describe multiplication like how the division error words it:

    error[E0277]: cannot divide `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x / y
      |       ^ no implementation for `i32 / f32`
      |
      = help: the trait `Div<f32>` is not implemented for `i32`

So that's what this change does. It changes this:

    error[E0277]: cannot multiply `f32` to `i32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

To this:

    error[E0277]: cannot multiply `i32` by `f32`
     --> src/lib.rs:2:7
      |
    2 |     x * y
      |       ^ no implementation for `i32 * f32`
      |
      = help: the trait `Mul<f32>` is not implemented for `i32`

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 agoTreat InOut variables like other input variables
Olivia Crain [Sat, 17 Oct 2020 21:36:58 +0000 (16:36 -0500)]
Treat InOut variables like other input variables

3 years agoMark inout asm! operands as used in liveness pass
Olivia Crain [Thu, 15 Oct 2020 13:40:40 +0000 (08:40 -0500)]
Mark inout asm! operands as used in liveness pass

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.