Commit graph

159589 commits

Author SHA1 Message Date
SNCPlay42
c5f8788d8d
add regression test for #91489 2021-12-12 12:09:34 +08:00
Deadbeef
5166f68754
Fix #91489 2021-12-12 12:09:27 +08:00
bors
58457bbfd3 Auto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrum
Slightly optimize hash map stable hashing

I was profiling some of the `rustc-perf` benchmarks locally and noticed that quite some time is spent inside the stable hash of hashmaps. I tried to use a `SmallVec` instead of a `Vec` there, which helped very slightly.

Then I tried to remove the sorting, which was a bottleneck, and replaced it with insertion into a binary heap. Locally, it yielded nice improvements in instruction counts and RSS in several benchmarks for incremental builds. The implementation could probably be much nicer and possibly extended to other stable hashes, but first I wanted to test the perf impact properly.

Can I ask someone to do a perf run? Thank you!
2021-12-12 03:50:30 +00:00
bors
e70e4d499d Auto merge of #91813 - matthiaskrgr:rollup-nryyeyj, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #90081 (Make `intrinsics::write_bytes` const)
 - #91643 (asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved by the current target)
 - #91737 (Make certain panicky stdlib functions behave better under panic_immediate_abort)
 - #91750 (rustdoc: Add regression test for Iterator as notable trait on &T)
 - #91764 (Do not ICE when suggesting elided lifetimes on non-existent spans.)
 - #91780 (Remove hir::Node::hir_id.)
 - #91797 (Fix zero-sized reference to deallocated memory)
 - #91806 (Make `Unique`s methods `const`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-12 00:58:30 +00:00
Noah Lev
dce45a9247
rustbot: Add autolabeling for T-rustdoc
This commit adds autolabeling for the `T-rustdoc` label, for PRs that
modify rustdoc's source code, tests, or internal tooling.

This is possible now that rust-lang/triagebot#1321 has landed.
2021-12-11 16:51:07 -08:00
Ralf Jung
3de60264ca better span for unexpected normalization failure in CTFE engine 2021-12-11 18:55:58 -05:00
japm48
0d7b830139 doc: fix typo in comments
dereferencable -> dereferenceable
2021-12-12 00:27:27 +01:00
Matthias Krüger
9031ac4840
Rollup merge of #91806 - woppopo:const_unique, r=dtolnay
Make `Unique`s methods `const`

Tracking issue: None
2021-12-11 23:31:55 +01:00
Matthias Krüger
9aade508d5
Rollup merge of #91797 - the8472:fix-invalid-deref, r=Mark-Simulacrum
Fix zero-sized reference to deallocated memory

fixes #91772

r? `@camelid`
2021-12-11 23:31:54 +01:00
Matthias Krüger
bd46953f0b
Rollup merge of #91780 - cjgillot:localize, r=Mark-Simulacrum
Remove hir::Node::hir_id.

Small cleanup.
2021-12-11 23:31:53 +01:00
Matthias Krüger
72b6a91fe7
Rollup merge of #91764 - cjgillot:elide-anyway, r=jackh726
Do not ICE when suggesting elided lifetimes on non-existent spans.

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

r? `@jackh726`
2021-12-11 23:31:52 +01:00
Matthias Krüger
6c66d3452d
Rollup merge of #91750 - notriddle:notriddle/doc-notable_trait-mut_t_is_not_ref_t, r=Mark-Simulacrum
rustdoc: Add regression test for Iterator as notable trait on &T

Closes #78160

This regression test is different from the one in #91748, because while neither of these function should have Iterator marked as a notable trait, the reasons are different.

* In this PR, it returns `&T where T: Iterator`. The `mut` is what's missing.
* In #91748, it returns `&mut T`. The trait bounds are what's missing.
2021-12-11 23:31:51 +01:00
Matthias Krüger
90eb610d14
Rollup merge of #91737 - Manishearth:panic-immediate-stdlib, r=joshtriplett
Make certain panicky stdlib functions behave better under panic_immediate_abort

The stdlib has a `panic_immediate_abort` feature that turns panics into immediate aborts, without any formatting/display logic. This feature was [introduced](https://github.com/rust-lang/rust/pull/55011) primarily for codesize-constrained situations.

Unfortunately, this win doesn't quite propagate to `Result::expect()` and `Result::unwrap()`, while the formatting machinery is reduced, `expect()` and `unwrap()` both call `unwrap_failed("msg", &err)` which has a signature of `fn unwrap_failed(msg: &str, error: &dyn fmt::Debug)` and is `#[inline(never)]`. This means that `unwrap_failed` will unconditionally construct a `dyn Debug` trait object even though the object is never used in the function.

Constructing a trait object (even if you never call a method on it!) forces rust to include the vtable and any dependencies. This means that in `panic_immediate_abort` mode, calling expect/unwrap on a Result will pull in a whole bunch of formatting code for the error type even if it's completely unused.

This PR swaps out the function with one that won't require a trait object such that it won't force the inclusion of vtables in the code. It also gates off `#[inline(never)]` in a bunch of other places where allowing the inlining of an abort may be useful (this kind of thing is already done elsewhere in the stdlib).

I don't know how to write a test for this; we don't really seem to have any tests for `panic_immediate_abort` anyway so perhaps it's fine as is.
2021-12-11 23:31:50 +01:00
Matthias Krüger
443ed7c620
Rollup merge of #91643 - Amanieu:r9x18, r=joshtriplett
asm: Allow using r9 (ARM) and x18 (AArch64) if they are not reserved by the current target

This supersedes https://github.com/rust-lang/rust/pull/88879.

cc `@Skirmisher`

r? `@joshtriplett`
2021-12-11 23:31:49 +01:00
Matthias Krüger
9383a49cd4
Rollup merge of #90081 - woppopo:const_write_bytes, r=oli-obk
Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: #86302
2021-12-11 23:31:48 +01:00
Abhishek Sudhakaran
b9ae04f088
bootstrap: Change unwrap() to expect() for WIX path
On Windows, `x.py dist` command panics without proper error message if 'WIX' environment variable is not set. This patch changes `Option::unwrap()` to `Option::expect()`.
2021-12-12 03:31:40 +05:30
bors
229d0a9412 Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obk
Tweak assoc type obligation spans

* Point at RHS of associated type in obligation span
* Point at `impl` assoc type on projection error
* Reduce verbosity of recursive obligations
* Point at source of binding lifetime obligation
* Tweak "required bound" note
* Tweak "expected... found opaque (return) type" labels
* Point at set type in impl assoc type WF errors

r? `@oli-obk`

This is a(n uncontroversial) subset of #85799.
2021-12-11 21:57:19 +00:00
woppopo
34eaf52829 Make Uniques methods const 2021-12-12 04:27:43 +09:00
bors
928783de66 Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #83174 (Suggest using a temporary variable to fix borrowck errors)
 - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point)
 - #90270 (Make `Borrow` and `BorrowMut` impls `const`)
 - #90741 (Const `Option::cloned`)
 - #91548 (Add spin_loop hint for RISC-V architecture)
 - #91721 (Minor improvements to `future::join!`'s implementation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-11 18:56:59 +00:00
Amanieu d'Antras
17766f88ff Fix AArch64 asm ui tests 2021-12-11 17:29:29 +00:00
Matthias Krüger
ed81098fcc
Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett
Minor improvements to `future::join!`'s implementation

This is a follow-up from #91645, regarding [some remarks I made](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/join!/near/264293660).

Mainly:
  - it hides the recursive munching through a private `macro`, to avoid leaking such details (a corollary is getting rid of the need to use ``@`` to disambiguate);
  - it uses a `match` binding, _outside_ the `async move` block, to better match the semantics from function-like syntax;
  - it pre-pins the future before calling into `poll_fn`, since `poll_fn`, alone, cannot guarantee that its capture does not move (to clarify: I believe the previous code was sound, thanks to the outer layer of `async`. But I find it clearer / more robust to refactorings this way 🙂).
  - it uses `@ibraheemdev's` very neat `.ready()?`;
  - it renames `Took` to `Taken` for consistency with `Done` (tiny nit 😄).

~~TODO~~Done:

  - [x] Add unit tests to enforce the function-like `:value` semantics are respected.

r? `@nrc`
2021-12-11 17:35:27 +01:00
Matthias Krüger
60b9f3130d
Rollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu
Add spin_loop hint for RISC-V architecture

This commit uses the PAUSE instruction (https://github.com/rust-lang/stdarch/pull/1262) to implement RISC-V spin loop, and updates `stdarch` submodule to use the merged PAUSE instruction.
2021-12-11 17:35:26 +01:00
Matthias Krüger
7fbaf33a3c
Rollup merge of #90741 - mbartlett21:patch-4, r=dtolnay
Const `Option::cloned`

This constifies the two `Option::cloned` functions, bounded on `~const Clone`.
2021-12-11 17:35:25 +01:00
Matthias Krüger
40482bb539
Rollup merge of #90270 - woppopo:const_borrow_trait, r=dtolnay
Make `Borrow` and `BorrowMut` impls `const`

Tracking issue: #91522
2021-12-11 17:35:24 +01:00
Matthias Krüger
7bba5c163c
Rollup merge of #89734 - estebank:issue-72312, r=nikomatsakis
Point at capture points for non-`'static` reference crossing a `yield` point

```
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/issue-72312.rs:10:24
   |
LL |     pub async fn start(&self) {
   |                        ^^^^^ this data with an anonymous lifetime `'_`...
...
LL |         require_static(async move {
   |         -------------- ...is required to live as long as `'static` here...
LL |             &self;
   |             ----- ...and is captured here
   |
note: `'static` lifetime requirement introduced by this trait bound
  --> $DIR/issue-72312.rs:2:22
   |
LL | fn require_static<T: 'static>(val: T) -> T {
   |                      ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0759`.
```

Fix #72312.
2021-12-11 17:35:23 +01:00
Matthias Krüger
433a13b473
Rollup merge of #83174 - camelid:borrow-help, r=oli-obk
Suggest using a temporary variable to fix borrowck errors

Fixes #77834.

In Rust, nesting method calls with both require `&mut` access to `self`
produces a borrow-check error:

    error[E0499]: cannot borrow `*self` as mutable more than once at a time
     --> src/lib.rs:7:14
      |
    7 |     self.foo(self.bar());
      |     ---------^^^^^^^^^^-
      |     |    |   |
      |     |    |   second mutable borrow occurs here
      |     |    first borrow later used by call
      |     first mutable borrow occurs here

That's because Rust has a left-to-right evaluation order, and the method
receiver is passed first. Thus, the argument to the method cannot then
mutate `self`.

There's an easy solution to this error: just extract a local variable
for the inner argument:

    let tmp = self.bar();
    self.foo(tmp);

However, the error doesn't give any suggestion of how to solve the
problem. As a result, new users may assume that it's impossible to
express their code correctly and get stuck.

This commit adds a (non-structured) suggestion to extract a local
variable for the inner argument to solve the error. The suggestion uses
heuristics that eliminate most false positives, though there are a few
false negatives (cases where the suggestion should be emitted but is
not). Those other cases can be implemented in a future change.
2021-12-11 17:35:23 +01:00
The 8472
9063b64cff Fix zero-sized reference to deallocated memory
fixes #91772
2021-12-11 17:10:56 +01:00
bors
b8dc6aa673 Auto merge of #91792 - matthiaskrgr:rollup-2epg7jq, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91617 (Improve the readability of `List<T>`.)
 - #91640 (Simplify collection of in-band lifetimes)
 - #91682 (rustdoc: Show type layout for type aliases)
 - #91711 (Improve `std::iter::zip` example)
 - #91717 (Add deprecation warning for --passes)
 - #91718 (give more help in the unaligned_references lint)
 - #91782 (Correct since attribute for `is_symlink` feature)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-11 15:55:22 +00:00
Matthias Krüger
bb23d82e6f
Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514
Correct since attribute for `is_symlink` feature

Follow-up from [89677](https://github.com/rust-lang/rust/pull/89677)
2021-12-11 16:02:50 +01:00
Matthias Krüger
bc0269dbed
Rollup merge of #91718 - RalfJung:unaligned_references, r=nagisa
give more help in the unaligned_references lint

Cc https://github.com/rust-lang/rust/issues/82523#issuecomment-988138440 ``@kaisq``
2021-12-11 16:02:49 +01:00
Matthias Krüger
ceae1dd3f8
Rollup merge of #91717 - inashivb:issue-91713, r=jyn514
Add deprecation warning for --passes

Issue https://github.com/rust-lang/rust/issues/91713 mentored by ```@jyn514```
2021-12-11 16:02:49 +01:00
Matthias Krüger
94ac197585
Rollup merge of #91711 - andrewbanchich:improve-zip-example, r=Mark-Simulacrum
Improve `std::iter::zip` example

`println!` isn't great for doc comments / tests.
2021-12-11 16:02:48 +01:00
Matthias Krüger
33ebf4de96
Rollup merge of #91682 - camelid:alias-layout, r=jyn514
rustdoc: Show type layout for type aliases

Fixes #91265.

At first, you might think, "Why not just click through to the aliased
type?" But, if a type alias instantiates all of the generic parameters
of the aliased type, then it can show layout info even though the
aliased type cannot (because we can't compute layout for generic types).
So, I think it's useful to show layout info for type aliases.

This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d
(originally part of #83501).
2021-12-11 16:02:47 +01:00
Matthias Krüger
7083f8edfd
Rollup merge of #91640 - cjgillot:in-band-collect, r=oli-obk
Simplify collection of in-band lifetimes

Split from https://github.com/rust-lang/rust/pull/91403

r? ````@oli-obk````
2021-12-11 16:02:46 +01:00
Matthias Krüger
1de7815ebb
Rollup merge of #91617 - nnethercote:improve-List-readability, r=lcnr
Improve the readability of `List<T>`.

This commit does the following.
- Expands on some of the things already mentioned in comments.
- Describes the uniqueness assumption, which is critical but wasn't
  mentioned at all.
- Rewrites `empty()` into a clearer form, as provided by Daniel
  Henry-Mantilla on Zulip.
- Reorders things slightly so that more important things
  are higher up, and incidental things are lower down, which makes
  reading the code easier.

r? ````@lcnr````
2021-12-11 16:02:45 +01:00
Maxwase
8fafb77af9 Correct since attribute for feature 2021-12-11 13:47:20 +03:00
Camille GILLOT
989d1de91b Add test. 2021-12-11 11:40:38 +01:00
bors
b9a37ad0d9 Auto merge of #91776 - matthiaskrgr:rollup-tlb4bw1, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #91127 (Add `<*{const|mut} T>::{to|from}_bits`)
 - #91310 (Add --out-dir flag for rustdoc)
 - #91373 (Add needs-unwind to tests that depend on panicking)
 - #91426 (Make IdFunctor::try_map_id panic-safe)
 - #91515 (Add rsplit_array variants to slices and arrays)
 - #91553 (socket ancillary data implementation for dragonflybsd.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-11 10:37:52 +00:00
Camille GILLOT
9a68003742 Do not ICE when suggesting elided lifetimes on non-existent spans. 2021-12-11 11:08:46 +01:00
Camille GILLOT
d9e997d9eb Remove useless variant. 2021-12-11 11:08:46 +01:00
Matthias Krüger
5da73311be
Rollup merge of #91553 - devnexen:anc_data_dfbsd, r=yaahc
socket ancillary data implementation for dragonflybsd.
2021-12-11 08:22:33 +01:00
Matthias Krüger
27c791ca86
Rollup merge of #91515 - jethrogb:rsplit_array, r=yaahc
Add rsplit_array variants to slices and arrays

By request: https://github.com/rust-lang/rust/issues/90091#issuecomment-985903239

r? `@yaahc`
2021-12-11 08:22:32 +01:00
Matthias Krüger
7e18b79c77
Rollup merge of #91426 - eggyal:idfunctor-panic-safety, r=lcnr
Make IdFunctor::try_map_id panic-safe

Addresses FIXME comment created in #78313

r? ```@lcnr```
2021-12-11 08:22:32 +01:00
Matthias Krüger
f7278cfc3c
Rollup merge of #91373 - djkoloski:fuchsia_test_suite, r=Mark-Simulacrum
Add needs-unwind to tests that depend on panicking

These tests were found by running the test suite on fuchsia which compiles with `panic=abort` by default, then picking through the failures manually to locate the tests that require unwinding support.

Most of these tests are already opted-out on platforms that compile with `panic=abort` by default. This just generalizes it a bit more so that fuchsia tests can be run properly. Currently, the `needs-unwind` directive needs to be manually passed to compiletest (e.g. via `--test-args '--target-panic=abort'`). Eventually, I would like `x.py` or compiletest to determine whether the directive should be used automatically based on the target panic settings.
2021-12-11 08:22:31 +01:00
Matthias Krüger
d8bb4d69db
Rollup merge of #91310 - hi-rustin:rustin-patch-rustdoc, r=jyn514
Add --out-dir flag for rustdoc

part of https://github.com/rust-lang/rust/issues/91260

Add --out-dir flag for rustdoc and change the `-o` option to point to out-dir.

I'm not quite sure if it should be stable, also I'm not sure if this parameter priority is appropriate? Or should I just refuse to pass both parameters at the same time?

r? `@jyn514`
2021-12-11 08:22:30 +01:00
Matthias Krüger
2f8e2ff6ba
Rollup merge of #91127 - scottmcm:ptr_to_from_bits, r=dtolnay
Add `<*{const|mut} T>::{to|from}_bits`

Named based on the floating-point methods of the same name, as those are also about returning the *representation* of the value.

Tracking issue: https://github.com/rust-lang/rust/issues/91126

Based on the conversation in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Adding.20methods.20as.20more.20specific.20versions.20of.20.60as.60/near/238391074

r? `@joshtriplett`
2021-12-11 08:22:29 +01:00
bors
4a66a704b2 Auto merge of #91720 - Aaron1011:skip-llvm-ci-tools, r=Mark-Simulacrum
Don't copy llvm tools to sysroot when using download-ci-llvm

Fixes #91710
2021-12-11 06:58:24 +00:00
bors
c185610ebc Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #91668 (Remove the match on `ErrorKind::Other`)
 - #91678 (Add tests fixed by #90023)
 - #91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs)
 - #91681 (fix typo in `intrinsics::raw_eq` docs)
 - #91686 (Fix `Vec::reserve_exact` documentation)
 - #91697 (Delete Utf8Lossy::from_str)
 - #91706 (Add unstable book entries for parts of asm that are not being stabilized)
 - #91709 (Replace iterator-based set construction by *Set::From<[T; N]>)
 - #91716 (Improve x.py logging and defaults a bit more)
 - #91747 (Add pierwill to .mailmap)
 - #91755 (Fix since attribute for const_linked_list_new feature)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-11 03:52:12 +00:00
Esteban Kuber
5e1972eba7 Tweak assoc type obligation spans
* Point at RHS of associated type in obligation span
* Point at `impl` assoc type on projection error
* Reduce verbosity of recursive obligations
* Point at source of binding lifetime obligation
* Tweak "required bound" note
* Tweak "expected... found opaque (return) type" labels
* Point at set type in impl assoc type WF errors
2021-12-11 02:32:15 +00:00
bors
82575a1d6f Auto merge of #91715 - the8472:bump-rmeta-fromat-version, r=Mark-Simulacrum
Bump rmeta version to fix rustc_serialize ICE

#91407 changed the serialization format which leads to ICEs for nightly users such as #91663 and linked issues. The issue can be solved by running `cargo clean`. But bumping the metadata version should lead to the cached files being discarded, avoiding the issue entirely.
2021-12-11 01:00:14 +00:00