]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #91199 - camelid:test-mixing-docs, r=GuillaumeGomez
Guillaume Gomez [Wed, 24 Nov 2021 21:56:40 +0000 (22:56 +0100)]
Rollup merge of #91199 - camelid:test-mixing-docs, r=GuillaumeGomez

rustdoc: Add test for mixing doc comments and attrs

This is a step toward adding more test coverage to make it easier to
remove the distinction between collapsed and uncollapsed doc values.

2 years agoRollup merge of #91179 - GuillaumeGomez:a-color, r=jsha
Guillaume Gomez [Wed, 24 Nov 2021 21:56:39 +0000 (22:56 +0100)]
Rollup merge of #91179 - GuillaumeGomez:a-color, r=jsha

Fix more <a> color

Fixes #91175.

Another bug I saw is:

![Screenshot from 2021-11-24 11-41-27](https://user-images.githubusercontent.com/3050060/143239845-f173cfeb-8f5c-4215-a5af-b71d4e1bcd84.png)

I fixed it as well.

r? ``@jsha``

2 years agoRollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
Guillaume Gomez [Wed, 24 Nov 2021 21:56:38 +0000 (22:56 +0100)]
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se

Fix test in std::process on android

closes #10380

2 years agoRollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomez
Guillaume Gomez [Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)]
Rollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomez

Reduce prominence of item-infos

Fixes #59853

 - Remove border.
 - Reduce size of emoji slightly.
 - Remove details disclosure for unstable reason. This was inconsistent with our other details disclosures, and the detail revealed was usually better explained by clicking on the issue link.

Demo: https://rustdoc.crud.net/jsha/chill-item-info/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref

Compare vs: https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.slice_assume_init_ref

<img src="https://user-images.githubusercontent.com/220205/142717815-09828c9e-6ff4-445a-8ccc-31e028fd4985.png" width=700>

2 years agoRollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Guillaume Gomez [Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)]
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid

Create rustdoc_internals feature gate

As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.

This is pretty much what it would look like (needs to update the tests too).

The tracking issue is https://github.com/rust-lang/rust/issues/90418.

What do you think ``@rust-lang/rustdoc`` ?

2 years agoRollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_musl, r=workingj...
Guillaume Gomez [Wed, 24 Nov 2021 21:56:36 +0000 (22:56 +0100)]
Rollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_musl, r=workingjubilee

Restrict aarch64 outline atomics to glibc for now.

The introduced dependency on `getauxval` causes linking problems with musl, making compiling any binaries for `aarch64-unknown-linux-musl` impossible without workarounds such as using lld or adding liblibc.rlib again to the linker invocation, see #89626.

This is a workaround until libc>0.2.108 is merged.

2 years agoRollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk
Guillaume Gomez [Wed, 24 Nov 2021 21:56:35 +0000 (22:56 +0100)]
Rollup merge of #89542 - jhpratt:stabilize-duration-const-fns, r=oli-obk

Partially stabilize `duration_consts_2`

Methods that were only blocked on `const_panic` have been stabilized.
The remaining methods of `duration_consts_2` are all related to floats,
and as such have been placed behind the `duration_consts_float` feature
gate.

2 years agorustdoc: Add test for mixing doc comments and attrs
Noah Lev [Wed, 24 Nov 2021 21:16:10 +0000 (13:16 -0800)]
rustdoc: Add test for mixing doc comments and attrs

This is a step toward adding more test coverage to make it easier to
remove the distinction between collapsed and uncollapsed doc values.

2 years agoAdd test for merged features
Guillaume Gomez [Wed, 17 Nov 2021 20:09:45 +0000 (21:09 +0100)]
Add test for merged features

2 years agoUpdate error message for doc(keyword)
Guillaume Gomez [Mon, 8 Nov 2021 19:00:22 +0000 (20:00 +0100)]
Update error message for doc(keyword)

2 years agoAdd feature gate test for "rustdoc_internal" feature
Guillaume Gomez [Mon, 8 Nov 2021 16:27:56 +0000 (17:27 +0100)]
Add feature gate test for "rustdoc_internal" feature

2 years agoCreate rustdoc_internals feature gate
Guillaume Gomez [Sat, 30 Oct 2021 15:44:50 +0000 (17:44 +0200)]
Create rustdoc_internals feature gate

2 years agoAuto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper
bors [Wed, 24 Nov 2021 15:51:46 +0000 (15:51 +0000)]
Auto merge of #90491 - Mark-Simulacrum:push-pred-faster, r=matthewjasper

Optimize live point computation

This refactors the live-point computation to lower per-MIR-instruction costs by operating on a largely per-block level. This doesn't fundamentally change the number of operations necessary, but it greatly improves the practical performance by aggregating bit manipulation into ranges rather than single-bit; this scales much better with larger blocks.

On the benchmark provided in #90445, with 100,000 array elements, walltime for a check build is improved from 143 seconds to 15.

I consider the tiny losses here acceptable given the many small wins on real world benchmarks and large wins on stress tests. The new code scales much better, but on some subset of inputs the slightly higher constant overheads decrease performance somewhat. Overall though, this is expected to be a big win for pathological cases (as illustrated by the test case motivating this work) and largely not material for non-pathological cases. I consider the new code somewhat easier to follow, too.

2 years agoUpdate GUI tests for <a> color
Guillaume Gomez [Wed, 24 Nov 2021 12:35:25 +0000 (13:35 +0100)]
Update GUI tests for <a> color

2 years agoFix more <a> color
Guillaume Gomez [Wed, 24 Nov 2021 12:35:15 +0000 (13:35 +0100)]
Fix more <a> color

2 years agoAuto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011
bors [Wed, 24 Nov 2021 12:51:19 +0000 (12:51 +0000)]
Auto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011

Remove eval_always for inherent_impls.

Split off https://github.com/rust-lang/rust/pull/86056
r? `@ghost`

2 years agoAuto merge of #91171 - jsha:fix-rustdoc-gui-test, r=GuillaumeGomez
bors [Wed, 24 Nov 2021 09:43:47 +0000 (09:43 +0000)]
Auto merge of #91171 - jsha:fix-rustdoc-gui-test, r=GuillaumeGomez

Fix toggle-click-deadspace rustdoc-gui test

In #91103 I introduced a rustdoc-gui test for clicks on toggles. I introduced some documentation on a method in lib2/struct.Foo.html so there would be something to toggle, but accidentally left the test checking test_docs/struct.Foo.html. That caused the test to reliably fail.

I'm not sure how that test got past GitHub Actions and bors, but it's manifesting in test failures at https://github.com/rust-lang/rust/pull/91062#issuecomment-977589705 and https://github.com/rust-lang/rust/pull/91170#issuecomment-977636159.

This fixes by pointing at the right file.

r? `@GuillaumeGomez`

2 years agoFix toggle-click-deadspace rustdoc-gui test
Jacob Hoffman-Andrews [Wed, 24 Nov 2021 08:58:07 +0000 (00:58 -0800)]
Fix toggle-click-deadspace rustdoc-gui test

2 years agoAuto merge of #91149 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514
bors [Tue, 23 Nov 2021 23:48:55 +0000 (23:48 +0000)]
Auto merge of #91149 - notriddle:notriddle/rustdoc-doctest-semicolon, r=jyn514

fix(doctest): detect extern crate items in statement doctests

This partially reverts #91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly.

Fixes #91134

2 years agoAuto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgr
bors [Tue, 23 Nov 2021 20:44:33 +0000 (20:44 +0000)]
Auto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #90856 (Suggestion to wrap inner types using 'allocator_api' in tuple)
 - #91103 (Inhibit clicks on summary's children)
 - #91137 (Give people a single link they can click in the contributing guide)
 - #91140 (Split inline const to two feature gates and mark expression position inline const complete)
 - #91148 (Use `derive_default_enum` in the compiler)
 - #91153 (kernel_copy: avoid panic on unexpected OS error)

Failed merges:

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

2 years agoRollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472
Matthias Krüger [Tue, 23 Nov 2021 18:28:12 +0000 (19:28 +0100)]
Rollup merge of #91153 - birkenfeld:kernel_copy_fallback, r=the8472

kernel_copy: avoid panic on unexpected OS error

According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152

2 years agoRollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkov
Matthias Krüger [Tue, 23 Nov 2021 18:28:11 +0000 (19:28 +0100)]
Rollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkov

Use `derive_default_enum` in the compiler

Let's get this feature some real-world love.

``@rustbot`` label: +C-cleanup +S-waiting-on-review

2 years agoRollup merge of #91140 - nbdd0121:const_typeck, r=oli-obk
Matthias Krüger [Tue, 23 Nov 2021 18:28:10 +0000 (19:28 +0100)]
Rollup merge of #91140 - nbdd0121:const_typeck, r=oli-obk

Split inline const to two feature gates and mark expression position inline const complete

This PR splits inline const in pattern position into its own `#![feature(inline_const_pat)]` feature gate, and make the usage in expression position complete.

I think I have resolved most outstanding issues related to `inline_const` with #89561 and other PRs. The only thing left that I am aware of is #90150 and the lack of lifetime checks when inline const is used in pattern position (FIXME in #89561). Implementation-wise when used in pattern position it has to be lowered during MIR building while in expression position it's evaluated only when monomorphizing (just like normal consts), so it makes some sense to separate it into two feature gates so one can progress without being blocked by another.

``@rustbot`` label: T-compiler F-inline_const

2 years agoRollup merge of #91137 - jyn514:contributing, r=spastorino
Matthias Krüger [Tue, 23 Nov 2021 18:28:09 +0000 (19:28 +0100)]
Rollup merge of #91137 - jyn514:contributing, r=spastorino

Give people a single link they can click in the contributing guide

Doc Jones mentioned that one of the things making it hard to get started
is that the amount of information is overwhelming, between the
dev-guide, contributing guide, and discussion platforms. This gives
people a single link they can click to ask for help.

cc ``@doc-jones`` - is this what you had in mind?

2 years agoRollup merge of #91103 - jsha:non-toggle-click-doesnt-toggle, r=Manishearth,Guillaume...
Matthias Krüger [Tue, 23 Nov 2021 18:28:07 +0000 (19:28 +0100)]
Rollup merge of #91103 - jsha:non-toggle-click-doesnt-toggle, r=Manishearth,GuillaumeGomez

Inhibit clicks on summary's children

A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior.

That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise.

This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target.

r? ``@Manishearth``

2 years agoRollup merge of #90856 - ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple...
Matthias Krüger [Tue, 23 Nov 2021 18:28:06 +0000 (19:28 +0100)]
Rollup merge of #90856 - ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple, r=davidtwco

Suggestion to wrap inner types using 'allocator_api' in tuple

This PR provides a suggestion to wrap the inner types in tuple when being along with 'allocator_api'.

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

```rust
fn main() {
    let _vec: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api'
}
```

```diff
 error[E0658]: use of unstable library feature 'allocator_api'
   --> $DIR/suggest-vec-allocator-api.rs:2:23
    |
 LL |     let _vec: Vec<u8, _> = vec![];
-   |                       ^
+   |                   ----^
+   |                   |
+   |                   help: consider wrapping the inner types in tuple: `(u8, _)`
    |
    = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
    = help: add `#![feature(allocator_api)]` to the crate attributes to enable
```

2 years agoAuto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser
bors [Tue, 23 Nov 2021 17:44:33 +0000 (17:44 +0000)]
Auto merge of #90788 - ecstatic-morse:issue-90752, r=wesleywiser

Mark places as initialized when mutably borrowed

Fixes the example in #90752, but does not handle some corner cases involving raw pointers and unsafe. See [this comment](https://github.com/rust-lang/rust/issues/90752#issuecomment-965822895) for more information, or the second test.

Although I talked about both `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` in #90752, this PR only changes the latter. That's because "maybe uninitialized" is the conservative choice, and marking them as definitely initialized (`!maybe_uninitialized`) when a mutable borrow is created could lead to problems if `addr_of_mut` to an uninitialized local is allowed. Additionally, places cannot become uninitialized via a mutable reference, so if a place is definitely initialized, taking a mutable reference to it should not change that.

I think it's correct to ignore interior mutability as nbdd0121 suggests below. Their analysis doesn't work inside of `core::cell`, which *does* have access to `UnsafeCell`'s field, but that won't be an issue unless we explicitly instantiate one with an `enum` within that module.

r? `@wesleywiser`

2 years agoSuggestion to wrap inner types using `allocator_api` in tuple
Ken Matsui [Sat, 13 Nov 2021 07:39:54 +0000 (16:39 +0900)]
Suggestion to wrap inner types using `allocator_api` in tuple

2 years agoAuto merge of #89881 - Mark-Simulacrum:fieldless-fast, r=davidtwco
bors [Tue, 23 Nov 2021 13:56:00 +0000 (13:56 +0000)]
Auto merge of #89881 - Mark-Simulacrum:fieldless-fast, r=davidtwco

Avoid generating empty closures for fieldless enum variants

For many enums, this avoids generating lots of tiny stubs that need to be codegen'd and then inlined and removed by LLVM. perf shows this to be a fairly small, but significant, win on rustc bootstrap time -- with minimal impact on runtime performance (which is at times even positive).

2 years agokernel_copy: avoid panic on unexpected OS error
Georg Brandl [Tue, 23 Nov 2021 07:09:48 +0000 (08:09 +0100)]
kernel_copy: avoid panic on unexpected OS error

According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152

2 years agoAuto merge of #89883 - Mark-Simulacrum:incr-verify-outline, r=nnethercote
bors [Tue, 23 Nov 2021 09:10:50 +0000 (09:10 +0000)]
Auto merge of #89883 - Mark-Simulacrum:incr-verify-outline, r=nnethercote

Manually outline error on incremental_verify_ich

This reduces codegen for rustc_query_impl by 169k lines of LLVM IR, representing
a 1.2% improvement. This code should be fairly cold, so hopefully this has minimal
performance impact.

2 years agoAuto merge of #84197 - bbjornse:stack-protector, r=nikic
bors [Tue, 23 Nov 2021 06:08:37 +0000 (06:08 +0000)]
Auto merge of #84197 - bbjornse:stack-protector, r=nikic

add codegen option for using LLVM stack smash protection

LLVM has built-in heuristics for adding stack canaries to functions. These
heuristics can be selected with LLVM function attributes. This PR adds a codegen
option `-C stack-protector={basic,strong,all}` which controls the use of these
attributes. This gives rustc the same stack smash protection support as clang
offers through options `-fstack-protector`, `-fstack-protector-strong`, and
`-fstack-protector-all`. The protection this can offer is demonstrated in
test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc
exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html),
originally discussed in #15179.

Stack smash protection adds runtime overhead and is therefore still off by
default, but now users have the option to trade performance for security as they
see fit. An example use case is adding Rust code in an existing C/C++ code base
compiled with stack smash protection. Without the ability to add stack smash
protection to the Rust code, the code base artifacts could be exploitable in
ways not possible if the code base remained pure C/C++.

Stack smash protection support is present in LLVM for almost all the current
tier 1/tier 2 targets: see
test/assembly/stack-protector/stack-protector-target-support.rs. The one
exception is nvptx64-nvidia-cuda. This PR follows clang's example, and adds a
warning message printed if stack smash protection is used with this target (see
test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3
targets has not been checked.

Since the heuristics are applied at the LLVM level, the heuristics are expected
to add stack smash protection to a fraction of functions comparable to C/C++.
Some experiments demonstrating how Rust code is affected by the different
heuristics can be found in
test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is
potential for better heuristics using Rust-specific safety information. For
example it might be reasonable to skip stack smash protection in functions which
transitively only use safe Rust code, or which uses only a subset of functions
the user declares safe (such as anything under `std.*`). Such alternative
heuristics could be added at a later point.

LLVM also offers a "safestack" sanitizer as an alternative way to guard against
stack smashing (see #26612). This could possibly also be included as a
stack-protection heuristic. An alternative is to add it as a sanitizer (#39699).
This is what clang does: safestack is exposed with option
`-fsanitize=safe-stack`.

The options are only supported by the LLVM backend, but as with other codegen
options it is visible in the main codegen option help menu. The heuristic names
"basic", "strong", and "all" are hopefully sufficiently generic to be usable in
other backends as well.

2 years agofix test in std::process on android
name1e5s [Tue, 23 Nov 2021 05:40:19 +0000 (13:40 +0800)]
fix test in std::process on android

2 years agoUpdate issue-91134.stdout
Michael Howell [Tue, 23 Nov 2021 04:00:42 +0000 (21:00 -0700)]
Update issue-91134.stdout

2 years agoAuto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514
bors [Tue, 23 Nov 2021 03:13:26 +0000 (03:13 +0000)]
Auto merge of #91094 - inquisitivecrystal:rustdoc-top-mod, r=jyn514

Avoid documenting top-level private imports

PR #88447 aimed to make rustdoc's `--document-private-items` mode only document imports that are visible outside the importing module. Unfortunately, I inadvertently set things up so that imports at the crate top-level are always documented, regardless of their visibility. This behavior was unintended and is [not desirable](https://github.com/rust-lang/rust/issues/90865#issuecomment-971172649).

This PR treats top-level imports as never being visible outside their parent module. In practice, the only way a top-level import can be visible externally is if it's fully public, and there's a seperate check for that.

It's worth calling attention to the fact that this change means that `pub(crate)` imports will be visible in lower level modules, but not at the top-level. This is because, at the top level of the crate, `pub(crate)` means the same thing as `pub(self)`.

It turned out that there were existing tests checking for the only behavior, which I didn't notice at the time of my previous PR. I have updated them to check for the new behavior and substantially extended them to handle differences between the top-level module and lower level modules. I may have gone overboard, so please tell me if there's anything I should cut.

r? `@jyn514`

Fixes #90865.

2 years agofix(doctest): detect extern crate items in statement doctests
Michael Howell [Tue, 23 Nov 2021 02:47:58 +0000 (19:47 -0700)]
fix(doctest): detect extern crate items in statement doctests

This partially reverts #91026, because rustdoc needs to detect the extern statements,
even when they appear inside implicit `main()`. It does not entirely revert it,
so the old bug is still fixed, by duplicating some of the logic from `parse_mod`
instead of trying to use it directly.

Fixes #91134

2 years agoManually outline error on incremental_verify_ich
Mark Rousskov [Tue, 12 Oct 2021 02:33:16 +0000 (22:33 -0400)]
Manually outline error on incremental_verify_ich

This reduces codegen for rustc_query_impl by 169k lines of LLVM IR, representing
a 1.2% improvement.

2 years agoAvoid generating empty closures for fieldless enums
Mark Rousskov [Tue, 12 Oct 2021 14:43:39 +0000 (10:43 -0400)]
Avoid generating empty closures for fieldless enums

For many enums, this avoids generating lots of tiny stubs that need to be
codegen'd and then inlined and removed by LLVM.

2 years agoUse `derive_default_enum` in the compiler
Jacob Pratt [Tue, 23 Nov 2021 01:17:53 +0000 (20:17 -0500)]
Use `derive_default_enum` in the compiler

2 years agoAuto merge of #91145 - matthiaskrgr:rollup-91g8z8i, r=matthiaskrgr
bors [Tue, 23 Nov 2021 00:09:48 +0000 (00:09 +0000)]
Auto merge of #91145 - matthiaskrgr:rollup-91g8z8i, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #91102 (Set color for <a> in a more straightforward way.)
 - #91143 (Update books)
 - #91144 (Update cargo)

Failed merges:

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

2 years agoRollup merge of #91144 - ehuss:update-cargo, r=ehuss
Matthias Krüger [Mon, 22 Nov 2021 22:30:32 +0000 (23:30 +0100)]
Rollup merge of #91144 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in ad50d0d266213e0cc4f6e526a39d96faae9a3842..e1fb17631eb1b3665cdbe45b1c186111577ef512
2021-11-17 18:36:37 +0000 to 2021-11-22 16:53:06 +0000
- re-enable lto_build test on 32-bit MSVC (rust-lang/cargo#10110)
- Fix a couple issues with cyclic features and dev-dependencies (rust-lang/cargo#10103)
- Add --message-format for install command (rust-lang/cargo#10107)
- Update curl dependency, remove M1 macOS build error note (rust-lang/cargo#10106)
- Make clippy happy (rust-lang/cargo#10105)
- Give a hard error if `-Zrustdoc-scrape-examples` is missing a flag (rust-lang/cargo#10043)
- silly fix, pointer to the empty slice (rust-lang/cargo#10097)

2 years agoRollup merge of #91143 - ehuss:update-books, r=ehuss
Matthias Krüger [Mon, 22 Nov 2021 22:30:30 +0000 (23:30 +0100)]
Rollup merge of #91143 - ehuss:update-books, r=ehuss

Update books

## reference

3 commits in a01d151a7250a540a9cb7ccce5956f020c677c21..c0f222da23568477155991d391c9ce918e381351
2021-10-22 22:34:13 +0900 to 2021-11-22 10:30:57 -0800
- Byte literal and string syntax: add missing quote escapes (rust-lang/reference#1101)
- fix crate_name attribute description (rust-lang/reference#1109)
- Update list of types with magic Copy impls (rust-lang/reference#1104)

## book

19 commits in 5c5dbc5b196c9564422b3193264f3288d2a051ce..a5e0c5b2c5f9054be3b961aea2c7edfeea591de8
2021-11-09 19:30:43 -0500 to 2021-11-19 17:06:19 -0500
- Propagate edits to chapter 4 back
- Edits to the edits of chapter 4
- ch 4 from nostarch
- Fix install links
- Snapshot of chapter 10
- Fix quotes
- Add more explanation of Self in chapter 10. Fixes rust-lang/book#2222.
- We've defined the signatures, not behaviors. Fixes rust-lang/book#2917
- Remove 'most distinctive' claim. Fixes rust-lang/book#2861.
- Clarify that traits must be brought into scope to use their methods
- Explain why lifetimes are part of the function contract better
- Further edits to rust-lang/book#2895
- Clarify generic types in mixin
- Change 'either' to 'at least one of'. See rust-lang/book#2885
- Clarify explanation of lifetime annotations a bit
- Further edits to clarify code explanation
- Clarify the meaning of a sentence in ch10-03
- Clarify this code is demonstrating usage of the library from a binary. Fixes rust-lang/book#1445.
- Clarify generics in method definitions and impls. Fixes rust-lang/book#2679.

## rust-by-example

1 commits in e9d45342d7a6c1def4731f1782d87ea317ba30c3..43f82530210b83cf888282b207ed13d5893da9b2
2021-11-02 13:33:03 -0500 to 2021-11-21 22:31:50 -0300
- Update `Development dependencies` page. (rust-lang/rust-by-example#1478)

## rustc-dev-guide

7 commits in 196ef69aa68f2cef44f37566ee7db37daf00301b..a2fc9635029c04e692474965a6606f8e286d539a
2021-11-07 07:48:47 -0600 to 2021-11-18 13:31:13 -0500
- Describe drop elaboration (rust-lang/rustc-dev-guide#1240)
- Fix an invalid link on Diagnostic Items (rust-lang/rustc-dev-guide#1261)
- Fix broken links related to `rustc_borrowck` (rust-lang/rustc-dev-guide#1259)
- Unify `x.py` usage (rust-lang/rustc-dev-guide#1258)
- Spelling fixes
- Fix compare-mode documentation
- Fix broken link in "Bootstrapping"

## edition-guide

1 commits in 27f4a84d3852e9416cae5861254fa53a825c56bd..8e0ec8c77d8b28b86159fdee9d33a758225ecf9c
2021-11-08 10:13:20 -0500 to 2021-11-12 06:30:23 -0800
- Fix a broken link in the Disjoint Capture in Closure chapter (rust-lang/edition-guide#273)

## embedded-book

1 commits in 51739471276b1776dea27cf562b974ef07e24685..8c395bdd8073deb20ca67e1ed4b14a3a7e315a37
2021-10-17 16:48:42 +0000 to 2021-11-14 11:38:31 +0000
- added math chapter  (rust-embedded/book#308)

2 years agoRollup merge of #91102 - jsha:theme-anchor, r=GuillaumeGomez
Matthias Krüger [Mon, 22 Nov 2021 22:30:29 +0000 (23:30 +0100)]
Rollup merge of #91102 - jsha:theme-anchor, r=GuillaumeGomez

Set color for <a> in a more straightforward way.

Previously, we set the default color for <a> tags to black, and then had an override with a bunch of not() clauses to set anchors in
docblocks to blue.

Instead, we should set the default color for <a> to blue (or equivalent in other themes), and override it for places like the sidebar or search results, where we don't want them to be styled as links.

Demo at https://rustdoc.crud.net/jsha/theme-anchor/std/string/struct.String.html. This should result in no visible changes.

r? `@GuillaumeGomez`

2 years ago`#![feature(inline_const)]` is no longer incomplete
Gary Guo [Mon, 22 Nov 2021 20:14:25 +0000 (20:14 +0000)]
`#![feature(inline_const)]` is no longer incomplete

2 years agoSplit inline const to two feature gates
Gary Guo [Mon, 22 Nov 2021 16:25:28 +0000 (16:25 +0000)]
Split inline const to two feature gates

2 years agoUpdate cargo
Eric Huss [Mon, 22 Nov 2021 22:01:57 +0000 (14:01 -0800)]
Update cargo

2 years agoUpdate books
Eric Huss [Mon, 22 Nov 2021 21:39:44 +0000 (13:39 -0800)]
Update books

2 years agoGive people a single link they can click in the contributing guide
Joshua Nelson [Mon, 22 Nov 2021 17:55:00 +0000 (11:55 -0600)]
Give people a single link they can click in the contributing guide

Doc Jones mentioned that one of the things making it hard to get started
is that the amount of information is overwhelming, between the
dev-guide, contributing guide, and discussion platforms. This gives
people a single link they can click to ask for help.

2 years agoadd rustc option for using LLVM stack smash protection
Benjamin A. Bjørnseth [Tue, 6 Apr 2021 19:37:49 +0000 (21:37 +0200)]
add rustc option for using LLVM stack smash protection

LLVM has built-in heuristics for adding stack canaries to functions. These
heuristics can be selected with LLVM function attributes. This patch adds a
rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use
of these attributes. This gives rustc the same stack smash protection support as
clang offers through options `-fno-stack-protector`, `-fstack-protector`,
`-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can
offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the
current list of rustc exploit
mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html),
originally discussed in #15179.

Stack smash protection adds runtime overhead and is therefore still off by
default, but now users have the option to trade performance for security as they
see fit. An example use case is adding Rust code in an existing C/C++ code base
compiled with stack smash protection. Without the ability to add stack smash
protection to the Rust code, the code base artifacts could be exploitable in
ways not possible if the code base remained pure C/C++.

Stack smash protection support is present in LLVM for almost all the current
tier 1/tier 2 targets: see
test/assembly/stack-protector/stack-protector-target-support.rs. The one
exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a
warning message printed if stack smash protection is used with this target (see
test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3
targets has not been checked.

Since the heuristics are applied at the LLVM level, the heuristics are expected
to add stack smash protection to a fraction of functions comparable to C/C++.
Some experiments demonstrating how Rust code is affected by the different
heuristics can be found in
test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is
potential for better heuristics using Rust-specific safety information. For
example it might be reasonable to skip stack smash protection in functions which
transitively only use safe Rust code, or which uses only a subset of functions
the user declares safe (such as anything under `std.*`). Such alternative
heuristics could be added at a later point.

LLVM also offers a "safestack" sanitizer as an alternative way to guard against
stack smashing (see #26612). This could possibly also be included as a
stack-protection heuristic. An alternative is to add it as a sanitizer (#39699).
This is what clang does: safestack is exposed with option
`-fsanitize=safe-stack`.

The options are only supported by the LLVM backend, but as with other codegen
options it is visible in the main codegen option help menu. The heuristic names
"basic", "strong", and "all" are hopefully sufficiently generic to be usable in
other backends as well.

Reviewed-by: Nikita Popov <nikic@php.net>
Extra commits during review:

- [address-review] make the stack-protector option unstable

- [address-review] reduce detail level of stack-protector option help text

- [address-review] correct grammar in comment

- [address-review] use compiler flag to avoid merging functions in test

- [address-review] specify min LLVM version in fortanix stack-protector test

  Only for Fortanix test, since this target specifically requests the
  `--x86-experimental-lvi-inline-asm-hardening` flag.

- [address-review] specify required LLVM components in stack-protector tests

- move stack protector option enum closer to other similar option enums

- rustc_interface/tests: sort debug option list in tracking hash test

- add an explicit `none` stack-protector option

Revert "set LLVM requirements for all stack protector support test revisions"

This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.

2 years agoPartially stabilize `duration_consts_2`
Jacob Pratt [Tue, 5 Oct 2021 03:09:23 +0000 (23:09 -0400)]
Partially stabilize `duration_consts_2`

Methods that were only blocked on `const_panic` have been stabilized.
The remaining methods of `duration_consts_2` are all related to floats,
and as such have been placed behind the `duration_consts_float` feature
gate.

2 years agoAuto merge of #91129 - rust-lang:rust-analyzer-2021-11-22, r=jonas-schievink
bors [Mon, 22 Nov 2021 17:05:28 +0000 (17:05 +0000)]
Auto merge of #91129 - rust-lang:rust-analyzer-2021-11-22, r=jonas-schievink

:arrow_up: rust-analyzer

`@bors` r+

2 years agoAuto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
bors [Mon, 22 Nov 2021 13:56:51 +0000 (13:56 +0000)]
Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum

Mention std::io::Error::from(ErrorKind) in Error::new() docs

This conversion is not very discoverable for the cases
where an error is required without extra payload.

2 years ago:arrow_up: rust-analyzer
Jonas Schievink [Mon, 22 Nov 2021 11:55:18 +0000 (12:55 +0100)]
:arrow_up: rust-analyzer

2 years agoAuto merge of #91099 - jsha:cleanup-undocumented, r=GuillaumeGomez
bors [Mon, 22 Nov 2021 10:43:12 +0000 (10:43 +0000)]
Auto merge of #91099 - jsha:cleanup-undocumented, r=GuillaumeGomez

Remove styles for details.undocumented

The Rust code that generated tags with that class was deleted in
10bafe1975e53769180701508e2b8cd3a3b34a0e.

r? `@GuillaumeGomez`

2 years agoAdd GUI test for clicking on non-toggle summary
Jacob Hoffman-Andrews [Mon, 22 Nov 2021 08:49:57 +0000 (00:49 -0800)]
Add GUI test for clicking on non-toggle summary

2 years agoSet color for <a> in a more straightforward way
Jacob Hoffman-Andrews [Mon, 22 Nov 2021 05:10:12 +0000 (21:10 -0800)]
Set color for <a> in a more straightforward way

Previously, we set the default color for <a> tags to black, and then
had an override with a bunch of not() clauses to set anchors in
docblocks to blue.

Instead, we should set the default color for <a> to blue (or equivalent
in other themes), and override it for places like the sidebar or search
results, where we don't want them to be styled as links.

2 years agoAuto merge of #90872 - ken-matsui:add-defer-to-rustdoc-template, r=jsha
bors [Mon, 22 Nov 2021 06:28:11 +0000 (06:28 +0000)]
Auto merge of #90872 - ken-matsui:add-defer-to-rustdoc-template, r=jsha

Move `scripts` on the rustdoc template into `head` and apply the `defer` attribute

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

2 years agorustdoc-gui/tester: print full filename on error
Jacob Hoffman-Andrews [Mon, 22 Nov 2021 05:09:23 +0000 (21:09 -0800)]
rustdoc-gui/tester: print full filename on error

This makes it easier to find the test that needs fixing.

2 years agoAuto merge of #88681 - ehuss:duplicate-attributes, r=petrochenkov
bors [Mon, 22 Nov 2021 02:15:25 +0000 (02:15 +0000)]
Auto merge of #88681 - ehuss:duplicate-attributes, r=petrochenkov

Check for duplicate attributes.

This adds some checks for duplicate attributes. In many cases, the duplicates were being ignored without error or warning. This adds several kinds of checks (see `AttributeDuplicates` enum).

The motivation here is to issue unused warnings with similar reasoning for any unused lint, and to error for cases where there are conflicts.

This also adds a check for empty attribute lists in a few attributes where this causes the attribute to be ignored.

Closes #55112.

2 years agoAuto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk
bors [Sun, 21 Nov 2021 21:20:20 +0000 (21:20 +0000)]
Auto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk

Simplify `for` loop desugar

Basically two intermediate bindings are inlined. I could have left one intermediate binding in place as this would simplify some diagnostic logic, but I think the difference in that regard would be negligible, so it is better to have a minimal HIR.

For checking that the pattern is irrefutable, I added a special case when the `match` is found to be non-exhaustive.

The reordering of the arms is purely stylistic. I don't *think* there are any perf implications.

```diff
  match IntoIterator::into_iter($head) {
      mut iter => {
          $label: loop {
-             let mut __next;
              match Iterator::next(&mut iter) {
-                 Some(val) => __next = val,
                  None => break,
+                 Some($pat) => $block,
              }
-             let $pat = __next;
-             $block
          }
      }
  }
```

2 years agoBless coverage tests
Cameron Steffen [Fri, 19 Nov 2021 16:29:29 +0000 (10:29 -0600)]
Bless coverage tests

2 years agoAuto merge of #89611 - eduardosm:next_code_point, r=Mark-Simulacrum
bors [Sun, 21 Nov 2021 18:14:59 +0000 (18:14 +0000)]
Auto merge of #89611 - eduardosm:next_code_point, r=Mark-Simulacrum

libcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF-8-like

The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0`

`unwrap_or_0` was added in 42357d772b8a3a1ce4395deeac0a5cf1f66e951d. I guess `unwrap_unchecked` was not available back then.

Given this example:

```rust
pub fn first_char(s: &str) -> Option<char> {
    s.chars().next()
}
```

Previously, the following assembly was produced:

```asm
_ZN7example10first_char17ha056ddea6bafad1cE:
.cfi_startproc
test rsi, rsi
je .LBB0_1
movzx edx, byte ptr [rdi]
test dl, dl
js .LBB0_3
mov eax, edx
ret
.LBB0_1:
mov eax, 1114112
ret
.LBB0_3:
lea r8, [rdi + rsi]
xor eax, eax
mov r9, r8
cmp rsi, 1
je .LBB0_5
movzx eax, byte ptr [rdi + 1]
add rdi, 2
and eax, 63
mov r9, rdi
.LBB0_5:
mov ecx, edx
and ecx, 31
cmp dl, -33
jbe .LBB0_6
cmp r9, r8
je .LBB0_9
movzx esi, byte ptr [r9]
add r9, 1
and esi, 63
shl eax, 6
or eax, esi
cmp dl, -16
jb .LBB0_12
.LBB0_13:
cmp r9, r8
je .LBB0_14
movzx edx, byte ptr [r9]
and edx, 63
jmp .LBB0_16
.LBB0_6:
shl ecx, 6
or eax, ecx
ret
.LBB0_9:
xor esi, esi
mov r9, r8
shl eax, 6
or eax, esi
cmp dl, -16
jae .LBB0_13
.LBB0_12:
shl ecx, 12
or eax, ecx
ret
.LBB0_14:
xor edx, edx
.LBB0_16:
and ecx, 7
shl ecx, 18
shl eax, 6
or eax, ecx
or eax, edx
ret
```

After this change, the assembly is reduced to:

```asm
_ZN7example10first_char17h4318683472f884ccE:
.cfi_startproc
test rsi, rsi
je .LBB0_1
movzx ecx, byte ptr [rdi]
test cl, cl
js .LBB0_3
mov eax, ecx
ret
.LBB0_1:
mov eax, 1114112
ret
.LBB0_3:
mov eax, ecx
and eax, 31
movzx esi, byte ptr [rdi + 1]
and esi, 63
cmp cl, -33
jbe .LBB0_4
movzx edx, byte ptr [rdi + 2]
shl esi, 6
and edx, 63
or edx, esi
cmp cl, -16
jb .LBB0_7
movzx ecx, byte ptr [rdi + 3]
and eax, 7
shl eax, 18
shl edx, 6
and ecx, 63
or ecx, edx
or eax, ecx
ret
.LBB0_4:
shl eax, 6
or eax, esi
ret
.LBB0_7:
shl eax, 12
or eax, edx
ret
```

2 years agolibcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF...
Eduardo Sánchez Muñoz [Wed, 6 Oct 2021 20:26:36 +0000 (22:26 +0200)]
libcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF-8-like

The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0`

`unwrap_or_0` was added in 42357d772b8a3a1ce4395deeac0a5cf1f66e951d. I guess `unwrap_unchecked` was not available back then.

Given this example:

```rust
pub fn first_char(s: &str) -> Option<char> {
    s.chars().next()
}
```

Previously, the following assembly was produced:

```asm
_ZN7example10first_char17ha056ddea6bafad1cE:
.cfi_startproc
test rsi, rsi
je .LBB0_1
movzx edx, byte ptr [rdi]
test dl, dl
js .LBB0_3
mov eax, edx
ret
.LBB0_1:
mov eax, 1114112
ret
.LBB0_3:
lea r8, [rdi + rsi]
xor eax, eax
mov r9, r8
cmp rsi, 1
je .LBB0_5
movzx eax, byte ptr [rdi + 1]
add rdi, 2
and eax, 63
mov r9, rdi
.LBB0_5:
mov ecx, edx
and ecx, 31
cmp dl, -33
jbe .LBB0_6
cmp r9, r8
je .LBB0_9
movzx esi, byte ptr [r9]
add r9, 1
and esi, 63
shl eax, 6
or eax, esi
cmp dl, -16
jb .LBB0_12
.LBB0_13:
cmp r9, r8
je .LBB0_14
movzx edx, byte ptr [r9]
and edx, 63
jmp .LBB0_16
.LBB0_6:
shl ecx, 6
or eax, ecx
ret
.LBB0_9:
xor esi, esi
mov r9, r8
shl eax, 6
or eax, esi
cmp dl, -16
jae .LBB0_13
.LBB0_12:
shl ecx, 12
or eax, ecx
ret
.LBB0_14:
xor edx, edx
.LBB0_16:
and ecx, 7
shl ecx, 18
shl eax, 6
or eax, ecx
or eax, edx
ret
```

After this change, the assembly is reduced to:

```asm
_ZN7example10first_char17h4318683472f884ccE:
.cfi_startproc
test rsi, rsi
je .LBB0_1
movzx ecx, byte ptr [rdi]
test cl, cl
js .LBB0_3
mov eax, ecx
ret
.LBB0_1:
mov eax, 1114112
ret
.LBB0_3:
mov eax, ecx
and eax, 31
movzx esi, byte ptr [rdi + 1]
and esi, 63
cmp cl, -33
jbe .LBB0_4
movzx edx, byte ptr [rdi + 2]
shl esi, 6
and edx, 63
or edx, esi
cmp cl, -16
jb .LBB0_7
movzx ecx, byte ptr [rdi + 3]
and eax, 7
shl eax, 18
shl edx, 6
and ecx, 63
or ecx, edx
or eax, ecx
ret
.LBB0_4:
shl eax, 6
or eax, esi
ret
.LBB0_7:
shl eax, 12
or eax, edx
ret
```

2 years agoUpdate link_ordinal duplicate attribute handling.
Eric Huss [Sun, 21 Nov 2021 16:02:00 +0000 (08:02 -0800)]
Update link_ordinal duplicate attribute handling.

This removes the duplicate check, as this is now handled in a
centralized location.

2 years agoclippy: Fix pattern_type_mismatch for loop
Cameron Steffen [Fri, 19 Nov 2021 18:23:52 +0000 (12:23 -0600)]
clippy: Fix pattern_type_mismatch for loop

2 years agoFix Clippy with changed for loop desugar
Cameron Steffen [Wed, 27 Oct 2021 14:48:06 +0000 (09:48 -0500)]
Fix Clippy with changed for loop desugar

2 years agoSimplify for loop desugar
Cameron Steffen [Tue, 26 Oct 2021 04:33:12 +0000 (23:33 -0500)]
Simplify for loop desugar

2 years agoAuto merge of #90844 - camelid:cleanup-vis, r=jyn514
bors [Sun, 21 Nov 2021 13:26:31 +0000 (13:26 +0000)]
Auto merge of #90844 - camelid:cleanup-vis, r=jyn514

rustdoc: Finish transition to computed visibility

This finishes the transition to using computed visibility in rustdoc.

2 years agoAuto merge of #91104 - matthiaskrgr:rollup-duk33o1, r=matthiaskrgr
bors [Sun, 21 Nov 2021 10:19:33 +0000 (10:19 +0000)]
Auto merge of #91104 - matthiaskrgr:rollup-duk33o1, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #91008 (Adds IEEE 754-2019 minimun and maximum functions for f32/f64)
 - #91070 (Make `LLVMRustGetOrInsertGlobal` always return a `GlobalVariable`)
 - #91097 (Add spaces in opaque `impl Trait` with more than one trait)
 - #91098 (Don't suggest certain fixups (`.field`, `.await`, etc) when reporting errors while matching on arrays )

Failed merges:

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

2 years agoRollup merge of #91098 - compiler-errors:issue-91058, r=estebank
Matthias Krüger [Sun, 21 Nov 2021 08:55:16 +0000 (09:55 +0100)]
Rollup merge of #91098 - compiler-errors:issue-91058, r=estebank

Don't suggest certain fixups (`.field`, `.await`, etc) when reporting errors while matching on arrays

When we have a type mismatch with a `cause.code` that is an `ObligationCauseCode::Pattern`, skip suggesting fixes like adding `.await` or accessing a struct's `.field` if the pattern's `root_ty` differs from the `expected` ty. This occurs in situations like this:

```rust
struct S(());

fn main() {
    let array = [S(())];

    match array {
        [()] => {}
        _ => {}
    }
}
```

I think what's happening here is a layer of `[_; N]` is peeled off of both types and we end up seeing the mismatch between just `S` and `()`, but when we suggest a fixup, that applies to the expression with type `root_ty`.

---

Questions:
1. Should this check live here, above all of the suggestions, or should I push this down into every suggestion when we match `ObligationCauseCode`?
2. Any other `ObligationCauseCode`s to check here?
3. Am I overlooking an easier way to get to this same conclusion without pattern matching on `ObligationCauseCode` and comparing `root_ty`?

Fixes #91058

2 years agoRollup merge of #91097 - compiler-errors:spaces_in_impl_trait, r=estebank
Matthias Krüger [Sun, 21 Nov 2021 08:55:15 +0000 (09:55 +0100)]
Rollup merge of #91097 - compiler-errors:spaces_in_impl_trait, r=estebank

Add spaces in opaque `impl Trait` with more than one trait

`impl A+B` becomes `impl A + B`

r? `@estebank`

2 years agoRollup merge of #91070 - cuviper:insert-global, r=nagisa
Matthias Krüger [Sun, 21 Nov 2021 08:55:14 +0000 (09:55 +0100)]
Rollup merge of #91070 - cuviper:insert-global, r=nagisa

Make `LLVMRustGetOrInsertGlobal` always return a `GlobalVariable`

`Module::getOrInsertGlobal` returns a `Constant*`, which is a super
class of `GlobalVariable`, but if the given type doesn't match an
existing declaration, it returns a bitcast of that global instead.
This causes UB when we pass that to `LLVMGetVisibility` which
unconditionally casts the opaque argument to a `GlobalValue*`.

Instead, we can do our own get-or-insert without worrying whether
existing types match exactly. It's not relevant when we're just trying
to get/set the linkage and visibility, and if types are needed we can
bitcast or error nicely from `rustc_codegen_llvm` instead.

Fixes #91050, fixes #87933, fixes #87813.

2 years agoRollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm
Matthias Krüger [Sun, 21 Nov 2021 08:55:13 +0000 (09:55 +0100)]
Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm

Adds IEEE 754-2019 minimun and maximum functions for f32/f64

IEEE 754-2019 removed the `minNum` (`min` in Rust) and `maxNum` (`max` in Rust) operations in favor of the newly created `minimum` and `maximum` operations due to their [non-associativity](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf) that cannot be fix in a backwards compatible manner. This PR adds `fN::{minimun,maximum}` functions following the new rules.

### IEEE 754-2019 Rules

> **minimum(x, y)** is x if x < y, y if y < x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, −0 compares less than +0. Otherwise (i.e., when x = y and signs are the same)
it is either x or y.

> **maximum(x, y)** is x if x > y, y if y > x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, +0 compares greater than −0. Otherwise (i.e., when x = y and signs are the
same) it is either x or y.

"IEEE Standard for Floating-Point Arithmetic," in IEEE Std 754-2019 (Revision of IEEE 754-2008) , vol., no., pp.1-84, 22 July 2019, doi: 10.1109/IEEESTD.2019.8766229.

### Implementation

This implementation is inspired by the one in [`glibc` ](https://github.com/bminor/glibc/blob/90f0ac10a74b2d43b5a65aab4be40565e359be43/math/s_fminimum_template.c) (it self derived from the C2X draft) expect that:
 - it doesn't use `copysign` because it's not available in `core` and also because `copysign` is unnecessary (we only want to check the sign, no need to create a new float)
 - it also prefer `other > self` instead of `self < other` like IEEE 754-2019 does

I originally tried to implement them [using intrinsics](https://github.com/Urgau/rust/commit/1d8aa13bc39eeef1afba0524dc5ea10d073522e6) but LLVM [error out](https://godbolt.org/z/7sMrxW49a) when trying to lower them to machine intructions, GCC doesn't yet have built-ins for them, only cranelift support them nativelly (as it doesn't support the nativelly the old sementics).

Helps with https://github.com/rust-lang/rust/issues/83984

2 years agoInhibit clicks on summary's children
Jacob Hoffman-Andrews [Sun, 21 Nov 2021 08:24:38 +0000 (00:24 -0800)]
Inhibit clicks on summary's children

A byproduct of using `<details>` and `<summary>` to show/hide detailed
documentation was that clicking any part of a method heading (or impl
heading) would show or hide the documentation. This was not super
noticeable because clicking a link inside the method heading would
navigate to that link. But clicking any unlinked black text in a method
heading would trigger the behavior.

That behavior was somewhat unexpected, and means that if you try to click
a type name in a method heading, but miss by a few pixels, you get a
confusing surprise.

This change inhibits that behavior by putting an event listener on most
summaries that cancels the event unless the event target was the summary
itself. In practice, that means it cancels the event unless the target
was the "[+]" / "[-]", because the rest of the heading is wrapped inside
a `<div>`, which is the target for anything that doesn't have a more
specific target.

2 years agoMention std::io::Error::from(ErrorKind) in Error::new() docs
Georg Brandl [Sun, 21 Nov 2021 08:00:13 +0000 (09:00 +0100)]
Mention std::io::Error::from(ErrorKind) in Error::new() docs

This conversion is not very discoverable for the cases
where an error is required without extra payload.

2 years agoRemove styles for details.undocumented
Jacob Hoffman-Andrews [Sun, 21 Nov 2021 07:46:23 +0000 (23:46 -0800)]
Remove styles for details.undocumented

The Rust code that generated tags with that class was deleted in
10bafe1975e53769180701508e2b8cd3a3b34a0e.

2 years agoAuto merge of #89580 - estebank:trait-bounds-are-tricky, r=nagisa
bors [Sun, 21 Nov 2021 07:15:32 +0000 (07:15 +0000)]
Auto merge of #89580 - estebank:trait-bounds-are-tricky, r=nagisa

Point at source of trait bound obligations in more places

Be more thorough in using `ItemObligation` and `BindingObligation` when
evaluating obligations so that we can point at trait bounds that
introduced unfulfilled obligations. We no longer incorrectly point at
unrelated trait bounds (`substs-ppaux.verbose.stderr`).

In particular, we now point at trait bounds on method calls.

We no longer point at "obvious" obligation sources (we no longer have a
note pointing at `Trait` saying "required by a bound in `Trait`", like
in `associated-types-no-suitable-supertrait*`).

We no longer point at associated items (`ImplObligation`), as they didn't
add any user actionable information, they just added noise.

Address part of #89418.

2 years agoUpdate tests
inquisitivecrystal [Wed, 17 Nov 2021 05:10:37 +0000 (21:10 -0800)]
Update tests

2 years agoFix for issue 91058
Michael Goulet [Fri, 19 Nov 2021 22:57:33 +0000 (14:57 -0800)]
Fix for issue 91058

2 years agoAuto merge of #91073 - camelid:small-cleanups, r=jyn514
bors [Sun, 21 Nov 2021 01:22:59 +0000 (01:22 +0000)]
Auto merge of #91073 - camelid:small-cleanups, r=jyn514

rustdoc: Make two small cleanups

2 years agoUse same_type_modulo_infer in more places
Michael Goulet [Fri, 19 Nov 2021 23:22:44 +0000 (15:22 -0800)]
Use same_type_modulo_infer in more places

2 years agoFixup test outputs
Michael Goulet [Sun, 21 Nov 2021 01:07:42 +0000 (17:07 -0800)]
Fixup test outputs

2 years agoAdd space in opaque `impl Trait`
Michael Goulet [Sun, 21 Nov 2021 01:01:47 +0000 (17:01 -0800)]
Add space in opaque `impl Trait`

2 years agoMove the issue-91050 tests to appease tidy
Josh Stone [Sun, 21 Nov 2021 01:02:37 +0000 (17:02 -0800)]
Move the issue-91050 tests to appease tidy

2 years agoAdd another test variant of issue-91050
Josh Stone [Sun, 21 Nov 2021 00:29:15 +0000 (16:29 -0800)]
Add another test variant of issue-91050

Co-authored-by: Simonas Kazlauskas <git@kazlauskas.me>
2 years agoApply documentation suggestions from @est31
Urgau [Sat, 20 Nov 2021 22:05:30 +0000 (23:05 +0100)]
Apply documentation suggestions from @est31

Co-authored-by: est31 <est31@users.noreply.github.com>
2 years agoAuto merge of #91093 - matthiaskrgr:rollup-kovzwx0, r=matthiaskrgr
bors [Sat, 20 Nov 2021 21:40:43 +0000 (21:40 +0000)]
Auto merge of #91093 - matthiaskrgr:rollup-kovzwx0, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #89741 (Mark `Arc::from_inner` / `Rc::from_inner` as unsafe)
 - #90927 (Fix float ICE)
 - #90994 (Fix ICE `#90993`: add missing call to cancel)
 - #91018 (Adopt let_else in more places in rustc_mir_build)
 - #91022 (Suggest `await` in more situations where infer types are involved)
 - #91088 (Revert "require full validity when determining the discriminant of a value")

Failed merges:

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

2 years agoRollup merge of #91088 - RalfJung:revert, r=oli-obk
Matthias Krüger [Sat, 20 Nov 2021 21:33:52 +0000 (22:33 +0100)]
Rollup merge of #91088 - RalfJung:revert, r=oli-obk

Revert "require full validity when determining the discriminant of a value"

This reverts commit 0a2b7d71d96a22126cce57f0dab5890d060f2259, reversing
changes made to 47c1bd1bcc50b25d133f8be3d49825491c1df249.
This caused several unforeseen problems:
- https://github.com/rust-lang/rust/issues/91029
- https://github.com/rust-lang/rust/pull/89764#issuecomment-973588007

So I think it's best to revert for now while we keep discussing the MIR semantics of getting a discriminant.

r? `@oli-obk`

2 years agoRollup merge of #91022 - compiler-errors:modulo_infer, r=estebank
Matthias Krüger [Sat, 20 Nov 2021 21:33:51 +0000 (22:33 +0100)]
Rollup merge of #91022 - compiler-errors:modulo_infer, r=estebank

Suggest `await` in more situations where infer types are involved

Currently we use `TyS::same_type` in diagnostics that suggest adding `.await` to opaque future types.

This change makes the suggestion slightly more general, when we're comparing types like `Result<T, E>` and `Result<_, _>` which happens sometimes in places like `match` patterns or `let` statements with partially-elaborated types.

----

Question:
1. Is this change worthwhile? Totally fine if it doesn't make sense adding.
2. Should `same_type_modulo_infer` live in `rustc_infer::infer::error_reporting` or alongside the other method in `rustc_middle::ty::util`?
3. Should we generalize this change? I wanted to change all usages, but I don't want erroneous suggestions when adding `.field_name`...

2 years agoRollup merge of #91018 - est31:let_else, r=matthewjasper
Matthias Krüger [Sat, 20 Nov 2021 21:33:50 +0000 (22:33 +0100)]
Rollup merge of #91018 - est31:let_else, r=matthewjasper

Adopt let_else in more places in rustc_mir_build

Helps avoid rightward drift.

followup of #89933

2 years agoRollup merge of #90994 - Badel2:issue-90993, r=estebank
Matthias Krüger [Sat, 20 Nov 2021 21:33:49 +0000 (22:33 +0100)]
Rollup merge of #90994 - Badel2:issue-90993, r=estebank

Fix ICE `#90993`: add missing call to cancel

Fix #90993

2 years agoRollup merge of #90927 - terrarier2111:fix-float-ice, r=jackh726
Matthias Krüger [Sat, 20 Nov 2021 21:33:49 +0000 (22:33 +0100)]
Rollup merge of #90927 - terrarier2111:fix-float-ice, r=jackh726

Fix float ICE

This fixes https://github.com/rust-lang/rust/issues/90728

2 years agoRollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum
Matthias Krüger [Sat, 20 Nov 2021 21:33:48 +0000 (22:33 +0100)]
Rollup merge of #89741 - sdroege:arc-rc-from-inner-unsafe, r=Mark-Simulacrum

Mark `Arc::from_inner` / `Rc::from_inner` as unsafe

While it's an internal function, it is easy to create invalid Arc/Rcs to
a dangling pointer with it.

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

2 years agobless NLL test
Esteban Kuber [Sat, 20 Nov 2021 19:27:23 +0000 (19:27 +0000)]
bless NLL test

2 years agoMove tests from ui directory
Esteban Kuber [Thu, 18 Nov 2021 01:52:04 +0000 (01:52 +0000)]
Move tests from ui directory

2 years agoreview comments
Esteban Kuber [Thu, 18 Nov 2021 01:35:36 +0000 (01:35 +0000)]
review comments

2 years agoMove tests for missing trait bounds to their own directory
Esteban Kuber [Thu, 14 Oct 2021 09:00:59 +0000 (09:00 +0000)]
Move tests for missing trait bounds to their own directory

2 years agoSuggest constraining `fn` type params when appropriate
Esteban Kuber [Wed, 13 Oct 2021 16:07:22 +0000 (16:07 +0000)]
Suggest constraining `fn` type params when appropriate

2 years agoPoint at `impl` blocks when they introduce unmet obligations
Esteban Kuber [Wed, 13 Oct 2021 14:28:28 +0000 (14:28 +0000)]
Point at `impl` blocks when they introduce unmet obligations

Group obligations by `impl` block that introduced them.

2 years agoAlign multiline messages to their label (add left margin)
Esteban Kuber [Wed, 13 Oct 2021 13:58:41 +0000 (13:58 +0000)]
Align multiline messages to their label (add left margin)