Rollup of 12 pull requests
Successful merges:
- #87601 (Add functions to add unsigned and signed integers)
- #88523 (Expand documentation for `FpCategory`.)
- #89050 (refactor: VecDeques Drain fields to private)
- #89245 (refactor: make VecDeque's IterMut fields module-private, not just crate-private)
- #89324 (Rename `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`)
- #89329 (print-type-sizes: skip field printing for primitives)
- #89501 (Note specific regions involved in 'borrowed data escapes' error)
- #89506 (librustdoc: Use correct heading levels.)
- #89528 (Fix suggestion to borrow when casting from pointer to reference)
- #89531 (library std, libc dependency update)
- #89588 (Add a test for generic_const_exprs)
- #89591 (fix: alloc-optimisation is only for rust llvm)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
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.
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`).
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.
Rename `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`
_Tracking issue: https://github.com/rust-lang/rust/issues/74479_
This PR renames `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`.
## Rationale
The API was initially named `std:🧵: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`
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(...).
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(...).
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.
Switch to our own mirror of libisl plus `ct-ng oldconfig` fixes
Switching to mirror the ISL libs (#89594) unearthed a (possibly long-standing?) issue with `ct-ng oldconfig`. It always overwrites the mirror config values. This PR adds the ISL mirror, gets rid of `ct-ng oldconfig` and adds crosstools-ng config files which can be used directly. (Edited)
Fixes#89593.
r? `@pietroalbini`
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.
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.
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
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.
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``
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.
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.
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.
Move generic error message to separate branches
This decomposes an error message in generic constants into more specific branches, for better
readability.
r? ``@lcnr``
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.
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.
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(...).
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.
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
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.
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.
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``
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
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.
refactor: VecDeques PairSlices fields to private
Reducing VecDeque's PairSlices fields to private, a `from(...)` method is already used to create PairSlices.