]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #89591 - infinity0:master, r=Amanieu
Manish Goregaokar [Wed, 6 Oct 2021 19:33:24 +0000 (12:33 -0700)]
Rollup merge of #89591 - infinity0:master, r=Amanieu

fix: alloc-optimisation is only for rust llvm

As discussed at the bottom of #83485.

On a separate note I'll take this chance ask, is it worth pulling in that patch (to recognise `__rust_dealloc`) into Debian's system LLVM? The main factors for us to consider would be (1) is the optimisation significant and (2) is there not any significant negative impact to non-rust packages that use LLVM.

2 years agoRollup merge of #89588 - BoxyUwU:add_a_test_uwu, r=lcnr
Manish Goregaokar [Wed, 6 Oct 2021 19:33:23 +0000 (12:33 -0700)]
Rollup merge of #89588 - BoxyUwU:add_a_test_uwu, r=lcnr

Add a test for generic_const_exprs

Test that const_eval_resolve evaluates consts with unused inference vars in substs

r? ``@lcnr``

2 years agoRollup merge of #89531 - devnexen:stack_overflow_bsd_libc_upd, r=dtolnay
Manish Goregaokar [Wed, 6 Oct 2021 19:33:22 +0000 (12:33 -0700)]
Rollup merge of #89531 - devnexen:stack_overflow_bsd_libc_upd, r=dtolnay

library std, libc dependency update

to solve #87528 build.

2 years agoRollup merge of #89528 - FabianWolff:issue-89497, r=jackh726
Manish Goregaokar [Wed, 6 Oct 2021 19:33:21 +0000 (12:33 -0700)]
Rollup merge of #89528 - FabianWolff:issue-89497, r=jackh726

Fix suggestion to borrow when casting from pointer to reference

Fixes #89497.

2 years agoRollup merge of #89506 - yaymukund:docblock-headings, r=GuillaumeGomez
Manish Goregaokar [Wed, 6 Oct 2021 19:33:20 +0000 (12:33 -0700)]
Rollup merge of #89506 - yaymukund:docblock-headings, r=GuillaumeGomez

librustdoc: Use correct heading levels.

Closes #89309

This fixes the `<h#>` header tags throughout the docs to reflect a semantic hierarchy.

- I ran a script to manually check that we don't have any files with multiple `<h1>` tags.
- Also checked that we never incorrectly nest e.g. a `<h2>` under an `<h3>`.
- I also spot-checked a bunch of pages (`trait.Read`, `enum.Ordering`, `primitive.isize`, `trait.Iterator`).

2 years agoRollup merge of #89501 - Aaron1011:escaping-name-regions, r=davidtwco
Manish Goregaokar [Wed, 6 Oct 2021 19:33:19 +0000 (12:33 -0700)]
Rollup merge of #89501 - Aaron1011:escaping-name-regions, r=davidtwco

Note specific regions involved in 'borrowed data escapes' error

Fixes #67007

Currently, a 'borrowed data escapes' error does not mention
the specific lifetime involved (except indirectly through a suggestion
about adding a lifetime bound). We now explain the specific lifetime
relationship that failed to hold, which improves otherwise vague
error messages.

2 years agoRollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726
Manish Goregaokar [Wed, 6 Oct 2021 19:33:18 +0000 (12:33 -0700)]
Rollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726

print-type-sizes: skip field printing for primitives

Fixes #86528.

2 years agoRollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se
Manish Goregaokar [Wed, 6 Oct 2021 19:33:17 +0000 (12:33 -0700)]
Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se

Rename `std::thread::available_conccurrency` to `std::thread::available_parallelism`

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

This PR renames  `std::thread::available_conccurrency` to `std::thread::available_parallelism`.

## Rationale

The API was initially named `std::thread::hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead.

---

For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine):

> __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones.

> __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well.

_Chapter 2.1: Concurrency is not Parallelism. Page 30._

---

_"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems).

That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program.

r? `@joshtriplett`

2 years agoRollup merge of #89245 - DeveloperC286:iter_mut_fields_to_private, r=joshtriplett
Manish Goregaokar [Wed, 6 Oct 2021 19:33:16 +0000 (12:33 -0700)]
Rollup merge of #89245 - DeveloperC286:iter_mut_fields_to_private, r=joshtriplett

refactor: make VecDeque's IterMut fields module-private, not just crate-private

Made the fields of VecDeque's IterMut private by creating a IterMut::new(...) function to create a new instance of IterMut and migrating usage to use IterMut::new(...).

2 years agoRollup merge of #89050 - DeveloperC286:drain_fields_to_private, r=joshtriplett
Manish Goregaokar [Wed, 6 Oct 2021 19:33:15 +0000 (12:33 -0700)]
Rollup merge of #89050 - DeveloperC286:drain_fields_to_private, r=joshtriplett

refactor: VecDeques Drain fields to private

Made the fields of VecDeque's Drain private by creating a Drain::new(...) function to create a new instance of Drain and migrating usage to use Drain::new(...).

2 years agoRollup merge of #88523 - kpreid:category, r=yaahc
Manish Goregaokar [Wed, 6 Oct 2021 19:33:14 +0000 (12:33 -0700)]
Rollup merge of #88523 - kpreid:category, r=yaahc

Expand documentation for `FpCategory`.

I intend these changes to be helpful to readers who are not yet familiar with the quirks of floating-point numbers. Additionally, I felt it was misleading to describe `Nan` as being the result of division by zero, since most divisions by zero (except for 0/0) produce `Infinite` floats, so I moved that remark to the `Infinite` variant with adjustment.

The first sentence of the `Nan` documentation is copied from `f32`; I followed the example of the `f64` documentation by referring to `f32` for general concepts, rather than duplicating the text.

----

I considered making similar changes to the documentation of the `is_*` methods of floats, but decided that that was a much larger and trickier problem; here, each of the variants' descriptions can be expected to be read in context of being mutually exclusive with the others.

2 years agoRollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm
Manish Goregaokar [Wed, 6 Oct 2021 19:33:13 +0000 (12:33 -0700)]
Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm

Add functions to add unsigned and signed integers

This PR adds methods to unsigned integers to add signed integers with good overflow semantics under `#![feature(mixed_integer_ops)]`.

The added API is:

```rust
// `uX` is `u8`, `u16`, `u32`, `u64`,`u128`, `usize`
impl uX {
    pub const fn checked_add_signed(self, iX) -> Option<Self>;
    pub const fn overflowing_add_signed(self, iX) -> (Self, bool);
    pub const fn saturating_add_signed(self, iX) -> Self;
    pub const fn wrapping_add_signed(self, iX) -> Self;
}

impl iX {
    pub const fn checked_add_unsigned(self, uX) -> Option<Self>;
    pub const fn overflowing_add_unsigned(self, uX) -> (Self, bool);
    pub const fn saturating_add_unsigned(self, uX) -> Self;
    pub const fn wrapping_add_unsigned(self, uX) -> Self;

    pub const fn checked_sub_unsigned(self, uX) -> Option<Self>;
    pub const fn overflowing_sub_unsigned(self, uX) -> (Self, bool);
    pub const fn saturating_sub_unsigned(self, uX) -> Self;
    pub const fn wrapping_sub_unsigned(self, uX) -> Self;
}
```

Maybe it would be interesting to also have `add_signed` that panics in debug and wraps in release ?

2 years agoRevert the rustc_error_codes changes.
Mukund Lakshman [Wed, 6 Oct 2021 11:58:41 +0000 (07:58 -0400)]
Revert the rustc_error_codes changes.

2 years agoRestore h1 styles, which got accidentally removed.
Mukund Lakshman [Wed, 6 Oct 2021 11:27:13 +0000 (07:27 -0400)]
Restore h1 styles, which got accidentally removed.

2 years agofix: alloc-optimisation is only for rust llvm
Ximin Luo [Wed, 6 Oct 2021 09:22:03 +0000 (10:22 +0100)]
fix: alloc-optimisation is only for rust llvm

2 years agoAuto merge of #89323 - estebank:derive-binop, r=petrochenkov
bors [Wed, 6 Oct 2021 06:20:25 +0000 (06:20 +0000)]
Auto merge of #89323 - estebank:derive-binop, r=petrochenkov

Consider unfulfilled obligations in binop errors

When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Fix #84515.

2 years agotest
Ellen [Wed, 6 Oct 2021 03:37:07 +0000 (04:37 +0100)]
test

2 years agoConsider unfulfilled obligations in binop errors
Esteban Kuber [Tue, 28 Sep 2021 14:48:54 +0000 (14:48 +0000)]
Consider unfulfilled obligations in binop errors

When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Point at trait(s) that needs to be `impl`emented.

2 years agoAuto merge of #89572 - Manishearth:rollup-obz5ycp, r=Manishearth
bors [Tue, 5 Oct 2021 22:28:40 +0000 (22:28 +0000)]
Auto merge of #89572 - Manishearth:rollup-obz5ycp, r=Manishearth

Rollup of 10 pull requests

Successful merges:

 - #88706 (Normalize associated type projections when checking return type of main)
 - #88828 (Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock)
 - #88871 (Fix suggestion for nested struct patterns)
 - #89317 (Move generic error message to separate branches)
 - #89351 (for signed wrapping remainder, do not compare lhs with MIN)
 - #89442 (Add check for duplicated doc aliases)
 - #89502 (Fix Lower/UpperExp formatting for integers and precision zero)
 - #89523 (Make `proc_macro_derive_resolution_fallback` a future-breakage lint)
 - #89532 (Document behavior of  `MaybeLiveLocals` regarding enums and field-senstivity)
 - #89546 (Make an initial guess for metadata size to reduce buffer resizes)

Failed merges:

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

2 years agoRollup merge of #89546 - joshtriplett:grow-metadata-faster, r=petrochenkov
Manish Goregaokar [Tue, 5 Oct 2021 19:52:49 +0000 (12:52 -0700)]
Rollup merge of #89546 - joshtriplett:grow-metadata-faster, r=petrochenkov

Make an initial guess for metadata size to reduce buffer resizes

When reading metadata, the compiler starts with a `Vec::new()`, which will need to grow repeatedly as the metadata gets decompressed into it. Reduce the number of resizes by starting out at the size of the compressed data.

2 years agoRollup merge of #89532 - ecstatic-morse:maybe-live-locals-enum, r=oli-obk,tmiasko
Manish Goregaokar [Tue, 5 Oct 2021 19:52:48 +0000 (12:52 -0700)]
Rollup merge of #89532 - ecstatic-morse:maybe-live-locals-enum, r=oli-obk,tmiasko

Document behavior of  `MaybeLiveLocals` regarding enums and field-senstivity

This arose from a [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/MaybeLiveLocals.20and.20Discriminants) where a new contributor attempted to implement a dead-store elimination pass using this analysis. They ran into a nasty hack around `SetDiscriminant` the effect of which is to lets handle assignments of literals to enum-typed locals (e.g. `x = Some(4)`) correctly. This took me a while to figure out.

Document this oddity, so the next person will have an easier time, and add a test to enshrine the current behavior.

r? ``@tmiasko``

2 years agoRollup merge of #89523 - Aaron1011:derive-future-compat, r=wesleywiser
Manish Goregaokar [Tue, 5 Oct 2021 19:52:47 +0000 (12:52 -0700)]
Rollup merge of #89523 - Aaron1011:derive-future-compat, r=wesleywiser

Make `proc_macro_derive_resolution_fallback` a future-breakage lint

When `cargo report future-incompatibilities` is stabilized
(see #71249), this will cause dependencies that trigger
this lint to be included in the report.

2 years agoRollup merge of #89502 - FabianWolff:issue-89493, r=joshtriplett
Manish Goregaokar [Tue, 5 Oct 2021 19:52:46 +0000 (12:52 -0700)]
Rollup merge of #89502 - FabianWolff:issue-89493, r=joshtriplett

Fix Lower/UpperExp formatting for integers and precision zero

Fixes the integer part of #89493 (I daren't touch the floating-point formatting code). The issue is that the "subtracted" precision essentially behaves like extra trailing zeros, but this is not currently reflected in the code properly.

2 years agoRollup merge of #89442 - GuillaumeGomez:duplicated-doc-alias, r=estebank
Manish Goregaokar [Tue, 5 Oct 2021 19:52:45 +0000 (12:52 -0700)]
Rollup merge of #89442 - GuillaumeGomez:duplicated-doc-alias, r=estebank

Add check for duplicated doc aliases

r? ``@estebank``

2 years agoRollup merge of #89351 - tspiteri:wrapping_rem, r=dtolnay
Manish Goregaokar [Tue, 5 Oct 2021 19:52:45 +0000 (12:52 -0700)]
Rollup merge of #89351 - tspiteri:wrapping_rem, r=dtolnay

for signed wrapping remainder, do not compare lhs with MIN

Since the wrapped remainder is going to be 0 for all cases when the rhs is -1, there is no need to compare the lhs with MIN.

2 years agoRollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwU
Manish Goregaokar [Tue, 5 Oct 2021 19:52:44 +0000 (12:52 -0700)]
Rollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwU

Move generic error message to separate branches

This decomposes an error message in generic constants into more specific branches, for better
readability.

r? ``@lcnr``

2 years agoRollup merge of #88871 - FabianWolff:issue-88403, r=jackh726
Manish Goregaokar [Tue, 5 Oct 2021 19:52:43 +0000 (12:52 -0700)]
Rollup merge of #88871 - FabianWolff:issue-88403, r=jackh726

Fix suggestion for nested struct patterns

Fixes #88403, and also a similar problem where the unused binding is in a function parameter pattern.

2 years agoRollup merge of #88828 - FabianWolff:issue-88585, r=dtolnay
Manish Goregaokar [Tue, 5 Oct 2021 19:52:42 +0000 (12:52 -0700)]
Rollup merge of #88828 - FabianWolff:issue-88585, r=dtolnay

Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock

Fixes #88585. POSIX [specifies](https://man7.org/linux/man-pages/man3/fork.3p.html) that after forking,
> to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called.

Rust's standard library does not currently adhere to this, as evidenced by #88585. The child process calls [`sys::signal()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/android.rs#L76), which on Android calls [`libc::dlsym()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/weak.rs#L101), which is [**not**](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, and in fact causes a deadlock in the example in #88585.

I think the easiest solution here would be to just call `libc::sigaction()` instead, which [is](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. [here](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/stack_overflow.rs#L112-L114).

2 years agoRollup merge of #88706 - ThePuzzlemaker:issue-88609, r=jackh726
Manish Goregaokar [Tue, 5 Oct 2021 19:52:41 +0000 (12:52 -0700)]
Rollup merge of #88706 - ThePuzzlemaker:issue-88609, r=jackh726

Normalize associated type projections when checking return type of main

This fixes #88609.

Previously, the return type of `fn main()` would not have any associated type projections within normalized before checking if it implements the standard library trait `std::process::Termination`. This commit appears to fix it.

This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with `assert_impl_termination` and `fn foo()` work, but simply `fn main()` doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this.

I have added a build-pass regression test for this issue.

2 years agoNote specific regions involved in 'borrowed data escapes' error
Aaron Hill [Sun, 3 Oct 2021 20:25:26 +0000 (15:25 -0500)]
Note specific regions involved in 'borrowed data escapes' error

Fixes #67007

Currently, a 'borrowed data escapes' error does not mention
the specific lifetime involved (except indirectly through a suggestion
about adding a lifetime bound). We now explain the specific lifetime
relationship that failed to hold, which improves otherwise vague
error messages.

2 years agorefactor: VecDeques IterMut fields to private
DeveloperC [Sat, 25 Sep 2021 12:55:45 +0000 (13:55 +0100)]
refactor: VecDeques IterMut fields to private

Made the fields of VecDeque's IterMut private by creating a IterMut::new(...) function to create a new instance of IterMut and migrating usage to use IterMut::new(...).

2 years agorefactor: VecDeques Drain fields to private
DeveloperC286 [Fri, 17 Sep 2021 17:25:21 +0000 (18:25 +0100)]
refactor: VecDeques Drain fields to private

2 years agofor signed overflowing remainder, delay comparing lhs with MIN
Trevor Spiteri [Tue, 5 Oct 2021 13:15:24 +0000 (15:15 +0200)]
for signed overflowing remainder, delay comparing lhs with MIN

Since the wrapped remainder is going to be 0 for all cases when the rhs is -1,
there is no need to divide in this case. Comparing the lhs with MIN is only done
for the overflow bool. In particular, this results in better code generation for
wrapping remainder, which discards the overflow bool completely.

2 years agoAuto merge of #89363 - oli-obk:in_tracing_we_trust, r=Mark-Simulacrum
bors [Tue, 5 Oct 2021 12:52:43 +0000 (12:52 +0000)]
Auto merge of #89363 - oli-obk:in_tracing_we_trust, r=Mark-Simulacrum

Fix performance regression with #[instrument]

linked tracing PR: https://github.com/tokio-rs/tracing/pull/1600

regression introduced by #89048

2 years agoAuto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
bors [Tue, 5 Oct 2021 09:45:11 +0000 (09:45 +0000)]
Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister

Move ICH to rustc_query_system

Based on https://github.com/rust-lang/rust/pull/89183

The StableHashingContext does not need to be in rustc_middle.

This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.

2 years agoAuto merge of #89549 - Manishearth:rollup-mhkyc16, r=Manishearth
bors [Tue, 5 Oct 2021 06:56:57 +0000 (06:56 +0000)]
Auto merge of #89549 - Manishearth:rollup-mhkyc16, r=Manishearth

Rollup of 12 pull requests

Successful merges:

 - #87631 (os current_exe using same approach as linux to get always the full ab…)
 - #88234 (rustdoc-json: Don't ignore impls for primitive types)
 - #88651 (Use the 64b inner:monotonize() implementation not the 128b one for aarch64)
 - #88816 (Rustdoc migrate to table so the gui can handle >2k constants)
 - #89244 (refactor: VecDeques PairSlices fields to private)
 - #89364 (rustdoc-json: Encode json files with UTF-8)
 - #89423 (Fix ICE caused by non_exaustive_omitted_patterns struct lint)
 - #89426 (bootstrap: add config option for nix patching)
 - #89462 (haiku thread affinity build fix)
 - #89482 (Follow the diagnostic output style guide)
 - #89504 (Don't suggest replacing region with 'static in NLL)
 - #89535 (fix busted JavaScript in error index generator)

Failed merges:

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

2 years agoRollup merge of #89535 - notriddle:notriddle/error-index-generator-js, r=Mark-Simulacrum
Manish Goregaokar [Tue, 5 Oct 2021 06:56:25 +0000 (23:56 -0700)]
Rollup merge of #89535 - notriddle:notriddle/error-index-generator-js, r=Mark-Simulacrum

fix busted JavaScript in error index generator

The old JavaScript didn't work. It filled the browser console with "e.previousElementSibling not defined" errors, because it didn't account for the example-wrap div that a newer version of rustdoc added.

Additionally, it had copied versions of utility functions that had been optimized in rustdoc main.js. This version updates those.

2 years agoRollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis
Manish Goregaokar [Tue, 5 Oct 2021 06:56:24 +0000 (23:56 -0700)]
Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis

Don't suggest replacing region with 'static in NLL

Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.

2 years agoRollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Manish Goregaokar [Tue, 5 Oct 2021 06:56:23 +0000 (23:56 -0700)]
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett

Follow the diagnostic output style guide

Detected by #89455.

2 years agoRollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa
Manish Goregaokar [Tue, 5 Oct 2021 06:56:22 +0000 (23:56 -0700)]
Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa

haiku thread affinity build fix

2 years agoRollup merge of #89426 - davidtwco:bootstrap-nix-toolchain-env-var, r=Mark-Simulacrum
Manish Goregaokar [Tue, 5 Oct 2021 06:56:21 +0000 (23:56 -0700)]
Rollup merge of #89426 - davidtwco:bootstrap-nix-toolchain-env-var, r=Mark-Simulacrum

bootstrap: add config option for nix patching

On NixOS systems, bootstrap will patch rustc used in bootstrapping after checking `/etc/os-release` (to confirm the current distribution is NixOS). However, when using Nix on a non-NixOS system, it can be desirable for bootstrap to patch rustc. In this commit, a `patch-binaries-for-nix` option is added to `config.toml`, which allows for user opt-in to bootstrap's Nix patching.

r? ``@Mark-Simulacrum``

2 years agoRollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril
Manish Goregaokar [Tue, 5 Oct 2021 06:56:20 +0000 (23:56 -0700)]
Rollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril

Fix ICE caused by non_exaustive_omitted_patterns struct lint

fixes #89382

Add check that a list of `Pat`s is non empty to prevent ICE in `FnCtxt::lint_non_exhaustive_omitted_patterns`.

Is related to #89374 and #89105

2 years agoRollup merge of #89364 - hkmatsumoto:encode-json-with-utf-8, r=Mark-Simulacrum
Manish Goregaokar [Tue, 5 Oct 2021 06:56:19 +0000 (23:56 -0700)]
Rollup merge of #89364 - hkmatsumoto:encode-json-with-utf-8, r=Mark-Simulacrum

rustdoc-json: Encode json files with UTF-8

Currently, `check_missing_items.py` malfunctions when the index contains some letters like emojis.

Related to #89360.

2 years agoRollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private, r=joshtriplett
Manish Goregaokar [Tue, 5 Oct 2021 06:56:18 +0000 (23:56 -0700)]
Rollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private, r=joshtriplett

refactor: VecDeques PairSlices fields to private

Reducing VecDeque's PairSlices fields to private, a `from(...)` method is already used to create PairSlices.

2 years agoRollup merge of #88816 - dns2utf8:rustdoc_test_gui_2k_constants, r=GuillaumeGomez
Manish Goregaokar [Tue, 5 Oct 2021 06:56:17 +0000 (23:56 -0700)]
Rollup merge of #88816 - dns2utf8:rustdoc_test_gui_2k_constants, r=GuillaumeGomez

Rustdoc migrate to table so the gui can handle >2k constants

Closes #88545.

This PR adds a test for overlapping entries in the `item-table` https://github.com/rust-lang/rust/issues/88545
It currently includes the commit with the workaround from https://github.com/rust-lang/rust/pull/88776

2 years agoRollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay
Manish Goregaokar [Tue, 5 Oct 2021 06:56:17 +0000 (23:56 -0700)]
Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay

Use the 64b inner:monotonize() implementation not the 128b one for aarch64

aarch64 prior to v8.4 (FEAT_LSE2) doesn't have an instruction that guarantees
untorn 128b reads except for completing a 128b load/store exclusive pair
(ldxp/stxp) or compare-and-swap (casp) successfully. The requirement to
complete a 128b read+write atomic is actually more expensive and more unfair
than the previous implementation of monotonize() which used a Mutex on aarch64,
especially at large core counts.  For aarch64 switch to the 64b atomic
implementation which is about 13x faster for a benchmark that involves many
calls to Instant::now().

2 years agoRollup merge of #88234 - hkmatsumoto:rustdoc-impls-for-primitive, r=jyn514
Manish Goregaokar [Tue, 5 Oct 2021 06:56:16 +0000 (23:56 -0700)]
Rollup merge of #88234 - hkmatsumoto:rustdoc-impls-for-primitive, r=jyn514

rustdoc-json: Don't ignore impls for primitive types

Fix the issue discussed at [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Json.20output.20lacks.20some.20item.20which.20are.20supposed.20to.20be.20there)

r? ``@jyn514``

2 years agoRollup merge of #87631 - :solarish_upd_fs, r=joshtriplett
Manish Goregaokar [Tue, 5 Oct 2021 06:56:15 +0000 (23:56 -0700)]
Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett

os current_exe using same approach as linux to get always the full ab…

…solute path

2 years agolibrary std, libc dependency update
David Carlier [Mon, 4 Oct 2021 21:11:53 +0000 (22:11 +0100)]
library std, libc dependency update

to solve #87528 build.

2 years agoAuto merge of #89545 - workingjubilee:rollup-ooxf3p2, r=workingjubilee
bors [Tue, 5 Oct 2021 04:13:35 +0000 (04:13 +0000)]
Auto merge of #89545 - workingjubilee:rollup-ooxf3p2, r=workingjubilee

Rollup of 15 pull requests

Successful merges:

 - #87993 (Stabilize try_reserve)
 - #88090 (Perform type inference in range pattern)
 - #88780 (Added abs_diff for integer types.)
 - #89270 (path.push() should work as expected on windows verbatim paths)
 - #89413 (Correctly handle supertraits for min_specialization)
 - #89456 (Update to the final LLVM 13.0.0 release)
 - #89466 (Fix bug with query modifier parsing)
 - #89473 (Fix extra `non_snake_case` warning for shorthand field bindings)
 - #89474 (rustdoc: Improve doctest pass's name and module's name)
 - #89478 (Fixed numerus of error message)
 - #89480 (Add test for issue 89118.)
 - #89487 (Try to recover from a `=>` -> `=` or `->` typo in a match arm)
 - #89494 (Deny `where` clauses on `auto` traits)
 - #89511 (:arrow_up: rust-analyzer)
 - #89536 (update Miri)

Failed merges:

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

2 years agoRollup merge of #89536 - RalfJung:miri, r=RalfJung
Jubilee [Tue, 5 Oct 2021 04:12:44 +0000 (21:12 -0700)]
Rollup merge of #89536 - RalfJung:miri, r=RalfJung

update Miri

Let's get the recent fixes and improvements shipped.
r? ````@ghost````

2 years agoRollup merge of #89511 - lnicola:rust-analyzer-2021-10-04, r=lnicola
Jubilee [Tue, 5 Oct 2021 04:12:43 +0000 (21:12 -0700)]
Rollup merge of #89511 - lnicola:rust-analyzer-2021-10-04, r=lnicola

:arrow_up: rust-analyzer

2 years agoRollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco
Jubilee [Tue, 5 Oct 2021 04:12:43 +0000 (21:12 -0700)]
Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco

Deny `where` clauses on `auto` traits

Fixes #84075.

2 years agoRollup merge of #89487 - FabianWolff:issue-89396, r=petrochenkov
Jubilee [Tue, 5 Oct 2021 04:12:42 +0000 (21:12 -0700)]
Rollup merge of #89487 - FabianWolff:issue-89396, r=petrochenkov

Try to recover from a `=>` -> `=` or `->` typo in a match arm

Fixes #89396.

2 years agoRollup merge of #89480 - hameerabbasi:issue-89118-test, r=jackh726
Jubilee [Tue, 5 Oct 2021 04:12:41 +0000 (21:12 -0700)]
Rollup merge of #89480 - hameerabbasi:issue-89118-test, r=jackh726

Add test for issue 89118.

This PR adds a test for issue 89118.

Closes #89118.

2 years agoRollup merge of #89478 - zvavybir:master, r=jyn514
Jubilee [Tue, 5 Oct 2021 04:12:40 +0000 (21:12 -0700)]
Rollup merge of #89478 - zvavybir:master, r=jyn514

Fixed numerus of error message

When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet:
`format!("{} redundant requirements hidden", count)`
But if there is only a single hidden requirement, it will still print this message in plural instead of singular.

2 years agoRollup merge of #89474 - camelid:better-pass-name, r=jyn514
Jubilee [Tue, 5 Oct 2021 04:12:39 +0000 (21:12 -0700)]
Rollup merge of #89474 - camelid:better-pass-name, r=jyn514

rustdoc: Improve doctest pass's name and module's name

As the docs at the top of the file say, it is an overloaded pass and
actually runs two lints.

2 years agoRollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett
Jubilee [Tue, 5 Oct 2021 04:12:38 +0000 (21:12 -0700)]
Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett

Fix extra `non_snake_case` warning for shorthand field bindings

Fixes #89469. The problem is the innermost `if` condition here:
https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452

This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.

2 years agoRollup merge of #89466 - Mark-Simulacrum:query-macros, r=oli-obk
Jubilee [Tue, 5 Oct 2021 04:12:37 +0000 (21:12 -0700)]
Rollup merge of #89466 - Mark-Simulacrum:query-macros, r=oli-obk

Fix bug with query modifier parsing

The previous macro_rules! parsers failed when an additional modifier was added
with ambiguity errors. The error is pretty unclear as to what exactly the cause
here is, but this change simplifies the argument parsing code such that the
error is avoided.

Extracted from other work, and somewhat duplicates 0358edeb5 from #85830, but
this approach seems a little simpler to me. Not technically currently necessary but seems
like a good cleanup.

2 years agoRollup merge of #89456 - cuviper:llvm-13, r=nikic
Jubilee [Tue, 5 Oct 2021 04:12:36 +0000 (21:12 -0700)]
Rollup merge of #89456 - cuviper:llvm-13, r=nikic

Update to the final LLVM 13.0.0 release

2 years agoRollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Jubilee [Tue, 5 Oct 2021 04:12:35 +0000 (21:12 -0700)]
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis

Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````

2 years agoRollup merge of #89270 - seanyoung:join_fold, r=m-ou-se
Jubilee [Tue, 5 Oct 2021 04:12:35 +0000 (21:12 -0700)]
Rollup merge of #89270 - seanyoung:join_fold, r=m-ou-se

path.push() should work as expected on windows verbatim paths

On Windows, std::fs::canonicalize() returns an so-called UNC path.  UNC paths differ with regular paths because:

- This type of path can much longer than a non-UNC path (32k vs 260 characters).
- The prefix for a UNC path is ``Component::Prefix(Prefix::DiskVerbatim(..)))``
- No `/` is allowed
- No `.` is allowed
- No `..` is allowed

Rust has poor handling of such paths. If you join a UNC path with a path with any of the above, then this will not work.

I've implemented a new method `fn join_fold()` which joins paths and also removes any `.` and `..` from it, and replaces `/` with `\` on Windows. Using this function it is possible to use UNC paths without issue. In addition, this function is useful on Linux too; paths can be appended without having to call `canonicalize()` to remove the `.` and `..`.

This PR needs test cases, which can I add. I hope this will a start of a discussion.

2 years agoRollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se
Jubilee [Tue, 5 Oct 2021 04:12:34 +0000 (21:12 -0700)]
Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se

Added abs_diff for integer types.

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

2 years agoRollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
Jubilee [Tue, 5 Oct 2021 04:12:33 +0000 (21:12 -0700)]
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis

Perform type inference in range pattern

Fix #88074

2 years agoRollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett
Jubilee [Tue, 5 Oct 2021 04:12:33 +0000 (21:12 -0700)]
Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett

Stabilize try_reserve

Stabilization PR for the [`try_reserve` feature](https://github.com/rust-lang/rust/issues/48043#issuecomment-898040475).

2 years agoAdd tests for ensuring docblock headings.
Mukund Lakshman [Tue, 5 Oct 2021 01:54:48 +0000 (21:54 -0400)]
Add tests for ensuring docblock headings.

2 years agoheading_level: u32 -> heading_offset: HeadingOffset
Mukund Lakshman [Tue, 5 Oct 2021 01:54:00 +0000 (21:54 -0400)]
heading_level: u32 -> heading_offset: HeadingOffset

2 years agoNo need to default offset since we always override it.
Mukund Lakshman [Tue, 5 Oct 2021 01:28:26 +0000 (21:28 -0400)]
No need to default offset since we always override it.

2 years agoChange `Markdown(...)` to `Markdown { ... }`
Mukund Lakshman [Tue, 5 Oct 2021 01:08:58 +0000 (21:08 -0400)]
Change `Markdown(...)` to `Markdown { ... }`

2 years agoMake an initial guess for metadata size to reduce buffer resizes
Josh Triplett [Tue, 5 Oct 2021 02:23:13 +0000 (19:23 -0700)]
Make an initial guess for metadata size to reduce buffer resizes

2 years agoFix heading for methods on trait impls.
Mukund Lakshman [Tue, 5 Oct 2021 00:49:07 +0000 (20:49 -0400)]
Fix heading for methods on trait impls.

2 years agoupdate Miri
Ralf Jung [Mon, 4 Oct 2021 22:13:00 +0000 (18:13 -0400)]
update Miri

2 years agofix busted JavaScript in error index generator
Michael Howell [Mon, 4 Oct 2021 20:01:50 +0000 (13:01 -0700)]
fix busted JavaScript in error index generator

The old JavaScript didn't work. It filled the browser console
with "e.previousElementSibling not defined" errors, because
it didn't account for the example-wrap div that a newer version
of rustdoc added.

Additionally, it had copied versions of utility functions that
had been optimized in rustdoc main.js. This version updates those.

2 years agoEnsure that `MaybeLiveLocals` works with simple sum-type assignments
Dylan MacKenzie [Mon, 4 Oct 2021 21:10:30 +0000 (14:10 -0700)]
Ensure that `MaybeLiveLocals` works with simple sum-type assignments

2 years agoDiscuss field-sensitivity and enums in context of `MaybeLiveLocals`
Dylan MacKenzie [Mon, 4 Oct 2021 21:09:19 +0000 (14:09 -0700)]
Discuss field-sensitivity and enums in context of `MaybeLiveLocals`

2 years agoAuto merge of #89530 - workingjubilee:rollup-ua14iq6, r=workingjubilee
bors [Mon, 4 Oct 2021 20:58:57 +0000 (20:58 +0000)]
Auto merge of #89530 - workingjubilee:rollup-ua14iq6, r=workingjubilee

Rollup of 13 pull requests

Successful merges:

 - #83655 ([aarch64] add target feature outline-atomics)
 - #87091 (implement advance_(back_)_by on more iterators)
 - #88451 (Fix an ICE caused by type mismatch errors being ignored)
 - #88452 (VecDeque: improve performance for From<[T; N]>)
 - #89400 (Improve wording of `map_or_else` docs)
 - #89407 (Recommend running `cargo clean` in E0514 output)
 - #89443 (Include the length in BTree hashes)
 - #89444 (rustdoc: use slice::contains instead of open-coding it)
 - #89447 (Improve error message for missing angle brackets in `[_]::method`)
 - #89453 (Consistently use 'supertrait'.)
 - #89483 (Practice diagnostic message convention)
 - #89500 (Fix ICE with buffered lint referring to AST node deleted by everybody_loops)
 - #89508 (Stabilize `const_panic`)

Failed merges:

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

2 years agoRollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Jubilee [Mon, 4 Oct 2021 20:58:17 +0000 (13:58 -0700)]
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett

Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)

2 years agoRollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
Jubilee [Mon, 4 Oct 2021 20:58:16 +0000 (13:58 -0700)]
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov

Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes #87308. Note the following comment:
https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_lint/src/early.rs#L415-L417

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in #87308, the buffered lint is created [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L145-L151) with the `lint_node_id` from [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_expand/src/mbe/macro_rules.rs#L319), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](https://github.com/rust-lang/rust/blob/08759c691e2e9799a3c6780ffdf910240ebd4a6b/compiler/rustc_interface/src/passes.rs#L377).

2 years agoRollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Jubilee [Mon, 4 Oct 2021 20:58:15 +0000 (13:58 -0700)]
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank

Practice diagnostic message convention

Detected by #89455.

r? ```@estebank```

2 years agoRollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa
Jubilee [Mon, 4 Oct 2021 20:58:14 +0000 (13:58 -0700)]
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa

Consistently use 'supertrait'.

A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.

2 years agoRollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
Jubilee [Mon, 4 Oct 2021 20:58:13 +0000 (13:58 -0700)]
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco

Improve error message for missing angle brackets in `[_]::method`

Fixes #89388.

2 years agoRollup merge of #89444 - notriddle:notriddle/contains-str, r=jyn514
Jubilee [Mon, 4 Oct 2021 20:58:12 +0000 (13:58 -0700)]
Rollup merge of #89444 - notriddle:notriddle/contains-str, r=jyn514

rustdoc: use slice::contains instead of open-coding it

2 years agoRollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay
Jubilee [Mon, 4 Oct 2021 20:58:11 +0000 (13:58 -0700)]
Rollup merge of #89443 - cuviper:btree-hash-len, r=dtolnay

Include the length in BTree hashes

This change makes it consistent with `Hash` for all other collections.

2 years agoRollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
Jubilee [Mon, 4 Oct 2021 20:58:10 +0000 (13:58 -0700)]
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco

Recommend running `cargo clean` in E0514 output

This suggestion has worked for me before. Seems to me it could help others.

2 years agoRollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay
Jubilee [Mon, 4 Oct 2021 20:58:09 +0000 (13:58 -0700)]
Rollup merge of #89400 - Nitepone:nitepone/map-or-else-docfix, r=dtolnay

Improve wording of `map_or_else` docs

Changes doc text to refer to the "default" parameter as the "default"
function.

Previously, the doc text referred to the "f" parameter as the "default" function; and the "default" parameter as the "fallback" function.

2 years agoRollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se
Jubilee [Mon, 4 Oct 2021 20:58:08 +0000 (13:58 -0700)]
Rollup merge of #88452 - xu-cheng:vecdeque-from-array, r=m-ou-se

VecDeque: improve performance for From<[T; N]>

Create `VecDeque` directly from the array instead of inserting items one-by-one.

Benchmark
```
./x.py bench library/alloc --test-args vec_deque::bench_from_array_1000
```

* Before
```
test vec_deque::bench_from_array_1000                    ... bench:       3,991 ns/iter (+/- 717)
```

* After
```
test vec_deque::bench_from_array_1000                    ... bench:         268 ns/iter (+/- 37)
```

2 years agoRollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Jubilee [Mon, 4 Oct 2021 20:58:07 +0000 (13:58 -0700)]
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726

Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](https://github.com/theo-lw/rust/blob/dec7fc3ced5bc3c18d0e5d29921d087f93189cb8/compiler/rustc_typeck/src/check/expr.rs#L928) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.

2 years agoRollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett
Jubilee [Mon, 4 Oct 2021 20:58:07 +0000 (13:58 -0700)]
Rollup merge of #87091 - the8472:more-advance-by-impls, r=joshtriplett

implement advance_(back_)_by on more iterators

Add more efficient, non-default implementations for `feature(iter_advance_by)` (#77404) on more iterators and adapters.

This PR only contains implementations where skipping over items doesn't elide any observable side-effects such as user-provided closures or `clone()` functions. I'll put those in a separate PR.

2 years agoRollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
Jubilee [Mon, 4 Oct 2021 20:58:06 +0000 (13:58 -0700)]
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee

[aarch64] add target feature outline-atomics

Enable outline-atomics by default as enabled in clang by the following commit
https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11

Performance improves by several orders of magnitude when using the LSE instructions
instead of the ARMv8.0 compatible load/store exclusive instructions.

Tested on Graviton2 aarch64-linux with
x.py build && x.py install && x.py test

2 years agoUse `TokenKind::similar_tokens()`
Fabian Wolff [Mon, 4 Oct 2021 20:13:00 +0000 (22:13 +0200)]
Use `TokenKind::similar_tokens()`

2 years agoFix suggestion to borrow when casting from pointer to reference
Fabian Wolff [Mon, 4 Oct 2021 19:15:02 +0000 (21:15 +0200)]
Fix suggestion to borrow when casting from pointer to reference

2 years agoAdd test for duplicated doc aliases
Guillaume Gomez [Fri, 1 Oct 2021 18:54:50 +0000 (20:54 +0200)]
Add test for duplicated doc aliases

2 years agoAdd a check for duplicated doc aliases in unused lint
Guillaume Gomez [Fri, 1 Oct 2021 18:54:36 +0000 (20:54 +0200)]
Add a check for duplicated doc aliases in unused lint

2 years agoOptimize `saturating_add_signed`
Benoît du Garreau [Mon, 4 Oct 2021 16:52:17 +0000 (18:52 +0200)]
Optimize `saturating_add_signed`

2 years agoMake `proc_macro_derive_resolution_fallback` a future-breakage lint
Aaron Hill [Mon, 4 Oct 2021 16:05:48 +0000 (11:05 -0500)]
Make `proc_macro_derive_resolution_fallback` a future-breakage lint

When `cargo report future-incompatibilities` is stabilized
(see #71249), this will cause dependencies that trigger
this lint to be included in the report.

2 years agoAuto merge of #88834 - the8472:char-count, r=joshtriplett
bors [Mon, 4 Oct 2021 12:49:57 +0000 (12:49 +0000)]
Auto merge of #88834 - the8472:char-count, r=joshtriplett

optimize str::from_utf8() validation when slice contains multibyte chars and str.chars().count() in all cases

The change shows small but consistent improvements across several x86 target feature levels. I also tried to optimize counting with `slice.as_chunks` but that yielded more inconsistent results, bigger improvements for some optimization levels, lesser ones in others.

```
old, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,924 ns/iter (+/- 26)
test str::str_char_count_lorem                                  ... bench:         879 ns/iter (+/- 12)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64
test str::str_char_count_emoji                                  ... bench:       1,878 ns/iter (+/- 21)
test str::str_char_count_lorem                                  ... bench:         851 ns/iter (+/- 11)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,477 ns/iter (+/- 46)
test str::str_char_count_lorem                                  ... bench:         675 ns/iter (+/- 15)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v2
test str::str_char_count_emoji                                  ... bench:       1,323 ns/iter (+/- 39)
test str::str_char_count_lorem                                  ... bench:         593 ns/iter (+/- 18)
test str::str_char_count_lorem_short                            ... bench:           4 ns/iter (+/- 0)

old, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         748 ns/iter (+/- 7)
test str::str_char_count_lorem                                  ... bench:         348 ns/iter (+/- 2)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)

new, -O2, x86-64-v3
test str::str_char_count_emoji                                  ... bench:         650 ns/iter (+/- 4)
test str::str_char_count_lorem                                  ... bench:         301 ns/iter (+/- 1)
test str::str_char_count_lorem_short                            ... bench:           5 ns/iter (+/- 0)
```

and for the multibyte-char string validation:

```
old, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       4,606 ns/iter (+/- 64)

new, -O2, x86-64
test str::str_validate_emoji                                    ... bench:       3,837 ns/iter (+/- 60)
```

2 years agoAuto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
bors [Mon, 4 Oct 2021 10:09:04 +0000 (10:09 +0000)]
Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk

Fix unsound optimization with explicit variant discriminants

Fixes #89485.

2 years agoStabilize try_reserve
Kornel [Sun, 29 Aug 2021 22:21:33 +0000 (23:21 +0100)]
Stabilize try_reserve

2 years agoAdd doc aliases to `std::thread::available_parallelism`
Yoshua Wuyts [Mon, 4 Oct 2021 09:04:01 +0000 (11:04 +0200)]
Add doc aliases to `std::thread::available_parallelism`

2 years agolibrustdoc: Use correct heading levels.
Mukund Lakshman [Fri, 1 Oct 2021 10:17:15 +0000 (06:17 -0400)]
librustdoc: Use correct heading levels.

- Avoid multiple <h1>s on a page.
- The <h#> tags should follow a semantic hierarchy.
- Cap at h6 (no h7)