]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #92680 - camelid:assoc-item-cleanup, r=petrochenkov
Matthias Krüger [Thu, 20 Jan 2022 16:10:36 +0000 (17:10 +0100)]
Rollup merge of #92680 - camelid:assoc-item-cleanup, r=petrochenkov

intra-doc: Use the impl's assoc item where possible

Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.

As an example of the old and new behavior, take this code:

    trait MyTrait {
        type AssocTy;
    }

    impl MyTrait for String {
        type AssocTy = u8;
    }

Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.

r? `@petrochenkov`

2 years agoRollup merge of #92582 - lcnr:generic-arg-infer, r=BoxyUwU
Matthias Krüger [Thu, 20 Jan 2022 16:10:35 +0000 (17:10 +0100)]
Rollup merge of #92582 - lcnr:generic-arg-infer, r=BoxyUwU

improve `_` constants in item signature handling

removing the "type" from the error messages does slightly worsen the error messages for types, but figuring out whether the placeholder is for a type or a constant and correctly dealing with that seemed fairly difficult to me so I took the easy way out :sparkles: Imo the error message is still clear enough.

r? `@BoxyUwU` cc `@estebank`

2 years agoRollup merge of #92183 - tmandry:issue-74256, r=estebank
Matthias Krüger [Thu, 20 Jan 2022 16:10:34 +0000 (17:10 +0100)]
Rollup merge of #92183 - tmandry:issue-74256, r=estebank

Point at correct argument when async fn output type lifetime disagrees with signature

Fixes most of #74256.

## Problems fixed

This PR fixes a couple of related problems in the error reporting code.

### Highlighting the wrong argument

First, the error reporting code was looking at the desugared return type of an `async fn` to decide which parameter to highlight. For example, a function like

```rust
async fn async_fn(self: &Struct, f: &u32) -> &u32
{ f }
```

desugars to

```rust
async fn async_fn<'a, 'b>(self: &'a Struct, f: &'b u32)
-> impl Future<Output = &'a u32> + 'a + 'b
{ f }
```

Since `f: &'b u32` is returned but the output type is `&'a u32`, the error would occur when checking that `'a: 'b`.

The reporting code would look to see if the "offending" lifetime `'b` was included in the return type, and because the code was looking at the desugared future type, it was included. So it defaulted to reporting that the source of the other lifetime `'a` (the `self` type) was the problem, when it was really the type of `f`. (Note that if it had chosen instead to look at `'a` first, it too would have been included in the output type, and it would have arbitrarily reported the error (correctly this time) on the type of `f`.)

Looking at the actual future type isn't useful for this reason; it captures all input lifetimes. Using the written return type for `async fn` solves this problem and results in less confusing error messages for the user.

This isn't a perfect fix, unfortunately; writing the "manually desugared" form of the above function still results in the wrong parameter being highlighted. Looking at the output type of every `impl Future` return type doesn't feel like a very principled approach, though it might work. The problem would remain for function signatures that look like the desugared one above but use different traits. There may be deeper changes required to pinpoint which part of each type is conflicting.

### Lying about await point capture causing lifetime conflicts

The second issue fixed by this PR is the unnecessary complexity in `try_report_anon_anon_conflict`. It turns out that the root cause I suggested in https://github.com/rust-lang/rust/issues/76547#issuecomment-692863608 wasn't really the root cause. Adding special handling to report that a variable was captured over an await point only made the error messages less correct and pointed to a problem other than the one that actually occurred.

Given the above discussion, it's easy to see why: `async fn`s capture all input lifetimes in their return type, so holding an argument across an await point should never cause a lifetime conflict! Removing the special handling simplified the code and improved the error messages (though they still aren't very good!)

## Future work

* Fix error reporting on the "desugared" form of this code
* Get the `suggest_adding_lifetime_params` suggestion firing on these examples
  * cc #42703, I think

r? `@estebank`

2 years agoRollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomez
Matthias Krüger [Thu, 20 Jan 2022 16:10:33 +0000 (17:10 +0100)]
Rollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomez

rustdoc: decouple stability and const-stability

This PR tweaks the stability rendering code to consider stability and const-stability separately. This fixes two issues:

- Stabilities that match the enclosing item are now always omitted, even if the item has const-stability as well (#90552)
- Const-stable unstable functions will now have their (const-) stability rendered.

Fixes #90552.

2 years agoRollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelix
Matthias Krüger [Thu, 20 Jan 2022 16:10:32 +0000 (17:10 +0100)]
Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelix

Stabilize `-Z print-link-args` as `--print link-args`

We have stable options for adding linker arguments; we should have a
stable option to help debug linker arguments.

Add documentation for the new option. In the documentation, make it clear that
the *exact* format of the output is not a stable guarantee.

2 years agoRollup merge of #89764 - tmiasko:uninhabited-enums, r=wesleywiser
Matthias Krüger [Thu, 20 Jan 2022 16:10:31 +0000 (17:10 +0100)]
Rollup merge of #89764 - tmiasko:uninhabited-enums, r=wesleywiser

Fix variant index / discriminant confusion in uninhabited enum branching

Fix confusion between variant index and variant discriminant. The pass
incorrectly assumed that for `Variants::Single` variant index is the same as
variant discriminant.

r? `@wesleywiser`

2 years agoRollup merge of #89747 - Amanieu:maybeuninit_bytes, r=m-ou-se
Matthias Krüger [Thu, 20 Jan 2022 16:10:30 +0000 (17:10 +0100)]
Rollup merge of #89747 - Amanieu:maybeuninit_bytes, r=m-ou-se

Add MaybeUninit::(slice_)as_bytes(_mut)

This adds methods to convert between `MaybeUninit<T>` and a slice of `MaybeUninit<u8>`. This is safe since `MaybeUninit<u8>` can correctly handle padding bytes in any `T`.

These methods are added:
```rust
impl<T> MaybeUninit<T> {
pub fn as_bytes(&self) -> &[MaybeUninit<u8>];
pub fn as_bytes_mut(&mut self) -> &mut [MaybeUninit<u8>];
pub fn slice_as_bytes(this: &[MaybeUninit<T>]) -> &[MaybeUninit<u8>];
pub fn slice_as_bytes_mut(this: &mut [MaybeUninit<T>]) -> &mut [MaybeUninit<u8>];
}
```

2 years agoAuto merge of #92138 - AngelicosPhosphoros:try_smarter_vec_from_iter_48994_2, r=Mark...
bors [Thu, 20 Jan 2022 06:50:14 +0000 (06:50 +0000)]
Auto merge of #92138 - AngelicosPhosphoros:try_smarter_vec_from_iter_48994_2, r=Mark-Simulacrum

Improve capacity estimation in Vec::from_iter

Iterates on the attempt made in #53086.

Closes #48994

2 years agoAuto merge of #93085 - matthiaskrgr:rollup-mgpu2ju, r=matthiaskrgr
bors [Wed, 19 Jan 2022 22:34:55 +0000 (22:34 +0000)]
Auto merge of #93085 - matthiaskrgr:rollup-mgpu2ju, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #92316 (mangling_v0: Skip extern blocks during mangling)
 - #92630 (Change PhantomData type for `BuildHasherDefault` (and more))
 - #92800 (Add manifest docs fallback.)
 - #93005 (Move back templates into html folder)
 - #93065 (Pretty printer algorithm revamp step 2)
 - #93077 (remove `List::is_noop`)

Failed merges:

 - #93068 (Fix spacing for `·` between stability and source)

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

2 years agoSimplify error reporting code, remove await point wording
Tyler Mandry [Fri, 10 Dec 2021 00:01:05 +0000 (00:01 +0000)]
Simplify error reporting code, remove await point wording

2 years agoNiceRegionError: Use written return type for async fn
Tyler Mandry [Sat, 20 Nov 2021 02:48:29 +0000 (02:48 +0000)]
NiceRegionError: Use written return type for async fn

2 years agoProperly account for binders in get_impl_future_output_ty
Tyler Mandry [Tue, 21 Dec 2021 22:08:47 +0000 (22:08 +0000)]
Properly account for binders in get_impl_future_output_ty

2 years agoAdd MaybeUninit::as_bytes
Amanieu d'Antras [Sun, 10 Oct 2021 18:19:52 +0000 (19:19 +0100)]
Add MaybeUninit::as_bytes

2 years agoRollup merge of #93077 - lcnr:write_substs, r=oli-obk
Matthias Krüger [Wed, 19 Jan 2022 18:19:52 +0000 (19:19 +0100)]
Rollup merge of #93077 - lcnr:write_substs, r=oli-obk

remove `List::is_noop`

think that `is_noop` is actually less clear than just using `is_empty`

2 years agoRollup merge of #93065 - dtolnay:ringbuffer, r=lcnr
Matthias Krüger [Wed, 19 Jan 2022 18:19:51 +0000 (19:19 +0100)]
Rollup merge of #93065 - dtolnay:ringbuffer, r=lcnr

Pretty printer algorithm revamp step 2

This PR follows #92923 as a second chunk of modernizations backported from https://github.com/dtolnay/prettyplease into rustc_ast_pretty.

I've broken this up into atomic commits that hopefully are sensible in isolation. At every commit, the pretty printer is compilable and has runtime behavior that is identical to before and after the PR. None of the refactoring so far changes behavior.

The general theme of this chunk of commits is: the logic in the old pretty printer is doing some very basic things (pushing and popping tokens on a ring buffer) but expressed in a too-low-level way that I found makes it quite complicated/subtle to reason about. There are a number of obvious invariants that are "almost true" -- things like `self.left == self.buf.offset` and `self.right == self.buf.offset + self.buf.data.len()` and `self.right_total == self.left_total + self.buf.data.sum()`. The reason these things are "almost true" is the implementation tends to put updating one side of the invariant unreasonably far apart from updating the other side, leaving the invariant broken while unrelated stuff happens in between. The following code from master is an example of this:

https://github.com/rust-lang/rust/blob/e5e2b0be26ea177527b60d355bd8f56cd473bd00/compiler/rustc_ast_pretty/src/pp.rs#L314-L317

In this code the `advance_right` is reserving an entry into which to write a next token on the right side of the ring buffer, the `check_stack` is doing something totally unrelated to the right boundary of the ring buffer, and the `scan_push` is actually writing the token we previously reserved space for. Much of what this PR is doing is rearranging code to shrink the amount of stuff in between when an invariant is broken to when it is restored, until the whole thing can be factored out into one indivisible method call on the RingBuffer type.

The end state of the PR is that we can entirely eliminate `self.left` (because it's now just equal to `self.buf.offset` always) and `self.right` (because it's equal to `self.buf.offset + self.buf.data.len()` always) and the whole `Token::Eof` state which used to be the value of tokens that have been reserved space for but not yet written.

I found without these changes the pretty printer implementation to be hard to reason about and I wasn't able to confidently introduce improvements like trailing commas in `prettyplease` until after this refactor. The logic here is 43 years old at this point (Graydon translated it as directly as possible from the 1979 pretty printing paper) and while there are advantages to following the paper as closely as possible, in `prettyplease` I decided if we're going to adapt the algorithm to work better for Rust syntax, it was worthwhile making it easier to follow than the original.

2 years agoRollup merge of #93005 - GuillaumeGomez:templates-in-html, r=notriddle
Matthias Krüger [Wed, 19 Jan 2022 18:19:49 +0000 (19:19 +0100)]
Rollup merge of #93005 - GuillaumeGomez:templates-in-html, r=notriddle

Move back templates into html folder

Follow-up of https://github.com/rust-lang/rust/pull/92526.

r? `@notriddle`

2 years agoRollup merge of #92800 - ehuss:docs-fallback, r=Mark-Simulacrum
Matthias Krüger [Wed, 19 Jan 2022 18:19:48 +0000 (19:19 +0100)]
Rollup merge of #92800 - ehuss:docs-fallback, r=Mark-Simulacrum

Add manifest docs fallback.

This adds a fallback so that the rustup manifest will contain the rust-docs component for all hosts. There is a mapping so that the docs that get downloaded are roughly close to the actual host. There inevitably will be things that don't match. Ideally the standard library docs would be the same for every platform (`cfg(doc)` goes a long way towards this), but there are still lots of minor differences.

Closes #69525

2 years agoRollup merge of #92630 - steffahn:lift_bounds_on_BuildHasherDefault, r=yaahc
Matthias Krüger [Wed, 19 Jan 2022 18:19:47 +0000 (19:19 +0100)]
Rollup merge of #92630 - steffahn:lift_bounds_on_BuildHasherDefault, r=yaahc

Change PhantomData type for `BuildHasherDefault` (and more)

Changes `PhantomData<H>` to `PhantomData<fn() -> H>` for `BuildHasherDefault`. This preserves the covariance of `H`, while it lifts the currently inferred unnecessary bounds like [`H: Send` for `BuildHasherDefault<H>: Send`](https://doc.rust-lang.org/1.57.0/std/hash/struct.BuildHasherDefault.html#impl-Send), etc.

_Edit:_ Also does a similar change for `iter::Empty` and `future::Pending`.

2 years agoRollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser
Matthias Krüger [Wed, 19 Jan 2022 18:19:45 +0000 (19:19 +0100)]
Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser

mangling_v0: Skip extern blocks during mangling

There's no need to include the dummy `Nt` into the symbol name, items in extern blocks belong to their parent modules for all purposes except for inheriting the ABI and attributes.

Follow up to https://github.com/rust-lang/rust/pull/92032

(There's also a drive-by fix to the `rust-demangler` tool's tests, which don't run on CI, I initially attempted using them for testing this PR.)

2 years agoAdd assert that fallback targets must be available.
Eric Huss [Wed, 19 Jan 2022 17:41:04 +0000 (09:41 -0800)]
Add assert that fallback targets must be available.

2 years agoAuto merge of #93069 - matthiaskrgr:rollup-gx1vkp7, r=matthiaskrgr
bors [Wed, 19 Jan 2022 15:01:10 +0000 (15:01 +0000)]
Auto merge of #93069 - matthiaskrgr:rollup-gx1vkp7, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #88642 (Formally implement let chains)
 - #89621 (doc: guarantee call order for sort_by_cached_key)
 - #91278 (Use iterator instead of recursion in `codegen_place`)
 - #92124 (Little improves in CString `new` when creating from slice)
 - #92783 (Annotate dead code lint with notes about ignored derived impls)
 - #92797 (Remove horizontal lines at top of page)
 - #92920 (Move expr- and item-related pretty printing functions to modules)
 - #93041 (Remove some unused ordering derivations based on `DefId`)
 - #93051 (Add Option::is_some_with and Result::is_{ok,err}_with)
 - #93062 (Update books)

Failed merges:

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

2 years agoImprove estimation of capacity in Vec::from_iter
AngelicosPhosphoros [Mon, 20 Dec 2021 20:58:45 +0000 (23:58 +0300)]
Improve estimation of capacity in Vec::from_iter

Closes #48994

2 years agoremove `is_noop`
lcnr [Wed, 19 Jan 2022 09:33:23 +0000 (10:33 +0100)]
remove `is_noop`

2 years agoMove back templates into html folder
Guillaume Gomez [Mon, 17 Jan 2022 16:36:39 +0000 (17:36 +0100)]
Move back templates into html folder

2 years agoRollup merge of #93062 - ehuss:update-books, r=ehuss
Matthias Krüger [Wed, 19 Jan 2022 09:42:21 +0000 (10:42 +0100)]
Rollup merge of #93062 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in c05c452b36358821bf4122f9c418674edd1d713d..66d097d3d80e8f88c288c6879c7c2b909ecf8ad4
2021-12-13 15:23:48 +0900 to 2022-01-05 05:45:21 +0900
- Fix typo / type error in FFI code example (rust-lang/nomicon#327)

## reference

8 commits in f8ba2f12df60ee19b96de24ae5b73af3de8a446b..4dee6eb63d728ffb9e7a2ed443e9ada9275c69d2
2022-01-03 11:02:08 -0800 to 2022-01-18 09:26:33 -0800
- (minor) Remove Expression Path sub-types splits in Pattern specs (rust-lang/reference#1138)
- Document destructuring assignment (rust-lang/reference#1116)
- Document the 2021 edition changes to macros-by-example `pat` metavariables (rust-lang/reference#1135)
- Improve the documentation of macros-by-example metavariable names (rust-lang/reference#1130)
- trait-bounds.md: add pronoun 'that' (rust-lang/reference#1131)
- Say that macros-by-example `ident` metavariables can match raw identifiers (rust-lang/reference#1133)
- State in the UAX31 profile description that a lone `_` is not an identifier (rust-lang/reference#1129)
- Document syntax reserved in Rust 2021 (rust-lang/reference#1128)

## book

17 commits in d3740fb7aad0ea4a80ae20f64dee3a8cfc0c5c3c..f17df27fc14696912c48b8b7a7a8fa49e648088d
2022-01-03 21:46:04 -0500 to 2022-01-18 17:46:28 -0500
- Add a notice to the top of all nostarch snapshots
- Fix quotes
- Grammar (minor): 'or' → 'and' for enum variants
- Propagate edits of chapter 8 to src
- Replies to nostarch edits
- more edits
- ch8 from nostarch
- Fix grammar and line wrapping
- Merge remote-tracking branch 'origin/pr/2880'
- Remove wikipedia link
- Merge remote-tracking branch 'origin/pr/2927'
- Snapshot of ch14 for nostarch
- Backport fixes to chapter 14 noticed while doing nostarch snapshot
- Fix usage of find piped into xargs
- Adjust some more line numbers of Cargo.toml includes
- Merge branch '2909'
- Merge remote-tracking branch 'parkerziegler/fix/ch14-add-one-naming'

## rustc-dev-guide

7 commits in 875464457c4104686faf667f47848aa7b0f0a744..78dd6a4684cf8d6b72275fab6d0429ea40b66338
2021-12-28 22:17:49 -0600 to 2022-01-18 14:44:26 -0300
- Reorganize and expand the testing chapters. (rust-lang/rustc-dev-guide#1281)
- Add inline assembly internals (rust-lang/rustc-dev-guide#1266)
- Spelling: Rename `rust` to `Rust` (rust-lang/rustc-dev-guide#1288)
- Clean up section about FCPs (rust-lang/rustc-dev-guide#1287)
- Address more review comments in rust-lang/rustc-dev-guide#1286.
- Address review comments in rust-lang/rustc-dev-guide#1286.
- Streamline "Getting Started" some more.

2 years agoRollup merge of #93051 - m-ou-se:is-some-with, r=yaahc
Matthias Krüger [Wed, 19 Jan 2022 09:42:20 +0000 (10:42 +0100)]
Rollup merge of #93051 - m-ou-se:is-some-with, r=yaahc

Add Option::is_some_with and Result::is_{ok,err}_with

See https://github.com/rust-lang/rust/issues/62358#issuecomment-1015827777

2 years agoRollup merge of #93041 - pierwill:rm-unused-defid-ords, r=cjgillot
Matthias Krüger [Wed, 19 Jan 2022 09:42:19 +0000 (10:42 +0100)]
Rollup merge of #93041 - pierwill:rm-unused-defid-ords, r=cjgillot

Remove some unused ordering derivations based on `DefId`

Like #93018, this removes some unused/unneeded ordering derivations as part of ongoing work on #90317. Here, these changes are aimed at making https://github.com/rust-lang/rust/pull/90749 easier to review, test, and merge.

r? `@cjgillot`

2 years agoRollup merge of #92920 - dtolnay:printtidy, r=cjgillot
Matthias Krüger [Wed, 19 Jan 2022 09:42:18 +0000 (10:42 +0100)]
Rollup merge of #92920 - dtolnay:printtidy, r=cjgillot

Move expr- and item-related pretty printing functions to modules

Currently *compiler/rustc_ast_pretty/src/pprust/state.rs* is 2976 lines on master. The `tidy` limit is 3000, which is blocking #92243.

This PR adds a `mod expr;` and `mod item;` to move logic related to those AST nodes out of the single huge file.

2 years agoRollup merge of #92797 - jsha:fewer-lines, r=GuillaumeGomez
Matthias Krüger [Wed, 19 Jan 2022 09:42:17 +0000 (10:42 +0100)]
Rollup merge of #92797 - jsha:fewer-lines, r=GuillaumeGomez

Remove horizontal lines at top of page

They are not needed to separate the search bar and the title, which are visually distinct on their own.

Part of #59840

Demo: https://rustdoc.crud.net/jsha/fewer-lines/std/string/struct.String.html

r? `@GuillaumeGomez`

2 years agoRollup merge of #92783 - FabianWolff:issue-92726, r=nikomatsakis
Matthias Krüger [Wed, 19 Jan 2022 09:42:16 +0000 (10:42 +0100)]
Rollup merge of #92783 - FabianWolff:issue-92726, r=nikomatsakis

Annotate dead code lint with notes about ignored derived impls

Fixes #92726. CC `@pmetzger,` is this what you had in mind?

r? `@nikomatsakis`

2 years agoRollup merge of #92124 - AngelicosPhosphoros:remove_extra_alloc_in_cstring_new_35838...
Matthias Krüger [Wed, 19 Jan 2022 09:42:15 +0000 (10:42 +0100)]
Rollup merge of #92124 - AngelicosPhosphoros:remove_extra_alloc_in_cstring_new_35838, r=Mark-Simulacrum

Little improves in CString `new` when creating from slice

Old code already contain optimization for cases with `&str` and `&[u8]` args. This commit adds a specialization for `&mut[u8]` too.

Also, I added usage of old slice in search for zero bytes instead of new buffer because it produce better code for constant inputs on Windows LTO builds. For other platforms, this wouldn't cause any difference because it calls `libc` anyway.

Inlined `_new` method into spec trait to reduce amount of code generated to `CString::new` callers.

2 years agoRollup merge of #91278 - SparrowLii:place, r=spastorino
Matthias Krüger [Wed, 19 Jan 2022 09:42:14 +0000 (10:42 +0100)]
Rollup merge of #91278 - SparrowLii:place, r=spastorino

Use iterator instead of recursion in `codegen_place`

This PR fixes the FIXME in `codegen_place` about using iterator instead of recursion when processing the `projection` field in `mir::PlaceRef`. At the same time, it also reduces the right drift.

2 years agoRollup merge of #89621 - digama0:patch-2, r=yaahc
Matthias Krüger [Wed, 19 Jan 2022 09:42:13 +0000 (10:42 +0100)]
Rollup merge of #89621 - digama0:patch-2, r=yaahc

doc: guarantee call order for sort_by_cached_key

`slice::sort_by_cached_key` takes a caching function `f: impl FnMut(&T) -> K`, which means that the order that calls to the caching function are made is user-visible. This adds a clause to the documentation to promise the current behavior, which is that `f` is called on all elements of the slice from left to right, unless the slice has len < 2 in which case `f` is not called.

For example, this can be used to ensure that the following code is a correct way to involve the index of the element in the sort key:
```rust
let mut index = 0;
slice.sort_by_cached_key(|x| (my_key(index, x), index += 1).0);
```

2 years agoRollup merge of #88642 - c410-f3r:let_chains_2, r=matthewjasper
Matthias Krüger [Wed, 19 Jan 2022 09:42:12 +0000 (10:42 +0100)]
Rollup merge of #88642 - c410-f3r:let_chains_2, r=matthewjasper

Formally implement let chains

## Let chains

My longest and hardest contribution since #64010.

Thanks to `@Centril` for creating the RFC and special thanks to `@matthewjasper` for helping me since the beginning of this journey. In fact, `@matthewjasper` did much of the complicated MIR stuff so it's true to say that this feature wouldn't be possible without him. Thanks again `@matthewjasper!`

With the changes proposed in this PR, it will be possible to chain let expressions along side local variable declarations or ordinary conditional expressions. In other words, do much of what the `if_chain` crate already does.

## Other considerations

* `if let guard` and `let ... else` features need special care and should be handled in a following PR.

* Irrefutable patterns are allowed within a let chain context

* ~~Three Clippy lints were already converted to start dogfooding and help detect possible corner cases~~

cc #53667

2 years agoAuto merge of #93063 - ehuss:update-cargo, r=ehuss
bors [Wed, 19 Jan 2022 06:17:07 +0000 (06:17 +0000)]
Auto merge of #93063 - ehuss:update-cargo, r=ehuss

Update cargo

16 commits in 358e79fe56fe374649275ca7aebaafd57ade0e8d..95bb3c92bf516017e812e7f1c14c2dea3845b30e
2022-01-04 18:39:45 +0000 to 2022-01-18 17:39:35 +0000
- Error when setting crate type of both dylib and cdylib in library (rust-lang/cargo#10243)
- Include `help` in `--list` (rust-lang/cargo#10300)
- Add report subcommand to bash completion. (rust-lang/cargo#10295)
- Downgrade some log messages. (rust-lang/cargo#10296)
- Enable shortcut for triage bot (rust-lang/cargo#10298)
- Bump to 0.61.0, update changelog (rust-lang/cargo#10294)
- use new cargo fmt option (rust-lang/cargo#10291)
- Add `run-fail` to semver-check for docs (rust-lang/cargo#10287)
- Use `is_symlink()` method (rust-lang/cargo#10290)
- Stabilize namespaced and weak dependency features. (rust-lang/cargo#10269)
- Port cargo to clap3 (rust-lang/cargo#10265)
- feat: support rustflags per profile (rust-lang/cargo#10217)
- Make bors ignore the PR template so it doesn't end up in merge messages (rust-lang/cargo#10267)
- Be resilient to most IO error and filesystem loop while walking dirs (rust-lang/cargo#10214)
- Remove the option to disable pipelining (rust-lang/cargo#10258)
- Always ask rustc for messages about artifacts, and always process them (rust-lang/cargo#10255)

2 years agoEliminate left and right cursors in favor of ring buffer
David Tolnay [Wed, 19 Jan 2022 04:19:10 +0000 (20:19 -0800)]
Eliminate left and right cursors in favor of ring buffer

2 years agoEliminate eof token state
David Tolnay [Wed, 19 Jan 2022 03:59:36 +0000 (19:59 -0800)]
Eliminate eof token state

2 years agoSimplify the buffer push done by scan_break
David Tolnay [Wed, 19 Jan 2022 03:24:17 +0000 (19:24 -0800)]
Simplify the buffer push done by scan_break

2 years agoUpdate books
Eric Huss [Wed, 19 Jan 2022 03:23:45 +0000 (19:23 -0800)]
Update books

2 years agoEliminate a check_stack call on an empty scan stack
David Tolnay [Wed, 19 Jan 2022 03:23:22 +0000 (19:23 -0800)]
Eliminate a check_stack call on an empty scan stack

2 years agoIndex a single time in check_stack
David Tolnay [Wed, 19 Jan 2022 03:21:18 +0000 (19:21 -0800)]
Index a single time in check_stack

2 years agoImplement check_stack nonrecursively
David Tolnay [Wed, 19 Jan 2022 03:20:33 +0000 (19:20 -0800)]
Implement check_stack nonrecursively

2 years agoImplement check_stream nonrecursively
David Tolnay [Wed, 19 Jan 2022 03:19:18 +0000 (19:19 -0800)]
Implement check_stream nonrecursively

2 years agoReplace `if` + `unwrap` with `if let` in check_stack
David Tolnay [Wed, 19 Jan 2022 03:18:47 +0000 (19:18 -0800)]
Replace `if` + `unwrap` with `if let` in check_stack

2 years agoEnsure Printer buf is always indexed using self.left or self.right
David Tolnay [Wed, 19 Jan 2022 03:18:04 +0000 (19:18 -0800)]
Ensure Printer buf is always indexed using self.left or self.right

2 years agoInline Printer's scan_pop_bottom method
David Tolnay [Wed, 19 Jan 2022 03:15:38 +0000 (19:15 -0800)]
Inline Printer's scan_pop_bottom method

2 years agoInline Printer's scan_top method
David Tolnay [Wed, 19 Jan 2022 03:15:21 +0000 (19:15 -0800)]
Inline Printer's scan_top method

2 years agoInline Printer's scan_pop method
David Tolnay [Wed, 19 Jan 2022 03:15:02 +0000 (19:15 -0800)]
Inline Printer's scan_pop method

2 years agoUpdate cargo
Eric Huss [Wed, 19 Jan 2022 03:14:33 +0000 (19:14 -0800)]
Update cargo

2 years agoSimplify ring buffer pushes
David Tolnay [Wed, 19 Jan 2022 03:07:12 +0000 (19:07 -0800)]
Simplify ring buffer pushes

2 years agoInline Printer's scan_push method
David Tolnay [Wed, 19 Jan 2022 03:04:12 +0000 (19:04 -0800)]
Inline Printer's scan_push method

2 years agoInline Printer's advance_right method
David Tolnay [Wed, 19 Jan 2022 03:02:49 +0000 (19:02 -0800)]
Inline Printer's advance_right method

2 years agoRemove horizontal lines at top of page
Jacob Hoffman-Andrews [Tue, 11 Jan 2022 23:31:40 +0000 (15:31 -0800)]
Remove horizontal lines at top of page

They are not needed to separate the search bar and the title, which are
visually distinct on their own.

2 years agointra-doc: Use the impl's assoc item where possible
Noah Lev [Sat, 8 Jan 2022 22:48:25 +0000 (14:48 -0800)]
intra-doc: Use the impl's assoc item where possible

Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.

As an example of the old and new behavior, take this code:

    trait MyTrait {
        type AssocTy;
    }

    impl MyTrait for String {
        type AssocTy = u8;
    }

Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.

2 years agoFix is_some_with tests.
Mara Bos [Tue, 18 Jan 2022 23:09:59 +0000 (00:09 +0100)]
Fix is_some_with tests.

2 years agoAuto merge of #93048 - matthiaskrgr:rollup-cz5ma34, r=matthiaskrgr
bors [Tue, 18 Jan 2022 22:46:47 +0000 (22:46 +0000)]
Auto merge of #93048 - matthiaskrgr:rollup-cz5ma34, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #90782 (Implement raw-dylib support for windows-gnu)
 - #91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`)
 - #92425 (Improve SIMD casts)
 - #92692 (Simplify and unify rustdoc sidebar styles)
 - #92780 (Directly use ConstValue for single literals in blocks)
 - #92924 (Delete pretty printer tracing)
 - #93018 (Remove some unused `Ord` derives based on `Span`)
 - #93026 (fix typo in `max` description for f32/f64)
 - #93035 (Fix stdarch submodule pointing to commit outside tree)

Failed merges:

 - #92861 (Rustdoc mobile: put out-of-band info on its own line)

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

2 years agoFormally implement let chains
Caio [Tue, 18 Jan 2022 22:38:17 +0000 (19:38 -0300)]
Formally implement let chains

2 years agoImprove is_err_with example.
Mara Bos [Tue, 18 Jan 2022 21:53:43 +0000 (22:53 +0100)]
Improve is_err_with example.

2 years agoAdd is_some_with tracking issue number.
Mara Bos [Tue, 18 Jan 2022 21:18:16 +0000 (22:18 +0100)]
Add is_some_with tracking issue number.

2 years agoAdd Result::{is_ok_with, is_err_with}.
Mara Bos [Tue, 18 Jan 2022 21:17:44 +0000 (22:17 +0100)]
Add Result::{is_ok_with, is_err_with}.

2 years agoAdd Option::is_some_with.
Mara Bos [Tue, 18 Jan 2022 21:17:34 +0000 (22:17 +0100)]
Add Option::is_some_with.

2 years agoRollup merge of #93035 - Amanieu:stdarch_fix, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 21:00:52 +0000 (22:00 +0100)]
Rollup merge of #93035 - Amanieu:stdarch_fix, r=Mark-Simulacrum

Fix stdarch submodule pointing to commit outside tree

PR #93016 was merged with the stdarch submodule pointing to a commit in
a PR branch and not in master. This was due to a circular dependency
between the rust and stdarch changes which would cause the other to fail
to build.

cc #75109

2 years agoRollup merge of #93026 - klensy:f-typo, r=scottmcm
Matthias Krüger [Tue, 18 Jan 2022 21:00:51 +0000 (22:00 +0100)]
Rollup merge of #93026 - klensy:f-typo, r=scottmcm

fix typo in `max` description for f32/f64

2 years agoRollup merge of #93018 - pierwill:rm-unused-ord, r=davidtwco
Matthias Krüger [Tue, 18 Jan 2022 21:00:50 +0000 (22:00 +0100)]
Rollup merge of #93018 - pierwill:rm-unused-ord, r=davidtwco

Remove some unused `Ord` derives based on `Span`

Remove some `Ord`, `PartialOrd` derivations that rely on underlying ordering of `Span`. These ordering traits appear to be unused right now.

If we're going to attempt to remove ordering traits from `Span` as suggested in https://github.com/rust-lang/rust/issues/90317#issuecomment-1013980591, we might want to slowly remove code that depends on this ordering (as opposed to the all-at-once approach in https://github.com/rust-lang/rust/pull/90749 and https://github.com/rust-lang/rust/pull/90408).

cc `@tmiasko` `@cjgillot`

2 years agoRollup merge of #92924 - dtolnay:pptracing, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 21:00:49 +0000 (22:00 +0100)]
Rollup merge of #92924 - dtolnay:pptracing, r=Mark-Simulacrum

Delete pretty printer tracing

These are left over from 2011. I did not find these helpful at all in my work on https://github.com/dtolnay/prettyplease despite doing significant refactors to this code. Learning what these messages all refer to is harder than putting in your own messages to log exactly what is relevant to specifically the thing that you are working on debugging.

2 years agoRollup merge of #92780 - b-naber:postpone-const-eval-coherence, r=lcnr
Matthias Krüger [Tue, 18 Jan 2022 21:00:47 +0000 (22:00 +0100)]
Rollup merge of #92780 - b-naber:postpone-const-eval-coherence, r=lcnr

Directly use ConstValue for single literals in blocks

Addresses the minimal repro in https://github.com/rust-lang/rust/issues/92186, but doesn't fix the underlying problem (which would be solved by solving the anon subst problem afaict).

I do, however, think that it makes sense in general to treat single literals in anon blocks as const values directly, especially in light of the problem that the issue refers to (anon const evaluation being postponed until infer variables in substs can be resolved, which was introduced by https://github.com/rust-lang/rust/pull/90023), i.e. while we do get warnings for those unnecessary braces, we should try to avoid errors caused by those braces if possible.

2 years agoRollup merge of #92692 - jsha:cool-sidebar, r=GuillaumeGomez
Matthias Krüger [Tue, 18 Jan 2022 21:00:46 +0000 (22:00 +0100)]
Rollup merge of #92692 - jsha:cool-sidebar, r=GuillaumeGomez

Simplify and unify rustdoc sidebar styles

Fixes #59860

This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width slightly.

As a very minor change, removed version from the "All types" page. It's now only on the crate page.

struct - https://rustdoc.crud.net/jsha/cool-sidebar/std/vec/struct.Vec.html
trait - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/trait.Read.html
crate - https://rustdoc.crud.net/jsha/cool-sidebar/std/index.html
mod - https://rustdoc.crud.net/jsha/cool-sidebar/std/any/index.html
macro - https://rustdoc.crud.net/jsha/cool-sidebar/std/macro.panic.html
fn - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/fn.stdin.html
type alias - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/type.Result.html
keyword - https://rustdoc.crud.net/jsha/cool-sidebar/std/keyword.as.html
primitive - https://rustdoc.crud.net/jsha/cool-sidebar/std/primitive.pointer.html

r? `@GuillaumeGomez`
cc `@camelid`
[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/sidebar.20headings).

Note: This has a lot of smaller commits, but I plan to squash them before merging.

2 years agoRollup merge of #92425 - calebzulawski:simd-cast, r=workingjubilee
Matthias Krüger [Tue, 18 Jan 2022 21:00:45 +0000 (22:00 +0100)]
Rollup merge of #92425 - calebzulawski:simd-cast, r=workingjubilee

Improve SIMD casts

* Allows `simd_cast` intrinsic to take `usize` and `isize`
* Adds `simd_as` intrinsic, which is the same as `simd_cast` except for saturating float-to-int conversions (matching the behavior of `as`).

cc `@workingjubilee`

2 years agoRollup merge of #91150 - dtolnay:qpath, r=davidtwco
Matthias Krüger [Tue, 18 Jan 2022 21:00:43 +0000 (22:00 +0100)]
Rollup merge of #91150 - dtolnay:qpath, r=davidtwco

Let qpath contain NtTy: `<$:ty as $:ty>::…`

Example:

```rust
macro_rules! m {
    (<$type:ty as $trait:ty>::$name:ident) => {
        <$type as $trait>::$name
    };
}

fn main() {
    let _: m!(<str as ToOwned>::Owned);
}
```

Previous behavior:

```console
error: expected identifier, found `ToOwned`
 --> src/main.rs:3:19
  |
3 |         <$type as $trait>::$name
  |                   ^^^^^^ expected identifier
...
8 |     let _: m!(<str as ToOwned>::Owned);
  |            ---------------------------
  |            |
  |            this macro call doesn't expand to a type
  |            in this macro invocation
```

The <code>expected identifier, found \`ToOwned\`</code> error is particularly silly. I think it should be fine to accept this code as long as $trait is of the form `TyKind::Path(None, path)`; if it is any other kind of `NtTy`, we'll keep the same behavior as before.

2 years agoRollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoerister
Matthias Krüger [Tue, 18 Jan 2022 21:00:42 +0000 (22:00 +0100)]
Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoerister

Implement raw-dylib support for windows-gnu

Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets.  Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801.  (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.)

In support of #58713.

2 years agoMove item-related pretty printing functions to module
David Tolnay [Sat, 15 Jan 2022 04:59:54 +0000 (20:59 -0800)]
Move item-related pretty printing functions to module

2 years agoMove expr-related pretty printing functions to module
David Tolnay [Sat, 15 Jan 2022 04:41:20 +0000 (20:41 -0800)]
Move expr-related pretty printing functions to module

2 years agoDelete pretty printer tracing
David Tolnay [Sat, 15 Jan 2022 06:34:23 +0000 (22:34 -0800)]
Delete pretty printer tracing

2 years agoSimplify and unify rustdoc sidebar styles
Jacob Hoffman-Andrews [Fri, 7 Jan 2022 00:48:24 +0000 (19:48 -0500)]
Simplify and unify rustdoc sidebar styles

This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width
slightly.

As a very minor change, removed version from the "All types" page. It's
now only on the crate page.

2 years agoRemove some unused `Ord` derivations based on `DefId`
pierwill [Tue, 18 Jan 2022 16:05:41 +0000 (10:05 -0600)]
Remove some unused `Ord` derivations based on `DefId`

Removes `Ord` and `PartialOrd` from  middle::mir::mirsource, inlineasmoperand,
terminatorkind, operand, constant, constantkind, and place

2 years agoFix stdarch submodule pointing to commit outside tree
Amanieu d'Antras [Tue, 18 Jan 2022 15:25:38 +0000 (15:25 +0000)]
Fix stdarch submodule pointing to commit outside tree

PR #93016 was merged with the stdarch submodule pointing to a commit in
a PR branch and not in master. This was due to a circular dependency
between the rust and stdarch changes which would cause the other to fail
to build.

cc #75109

2 years agoAuto merge of #92731 - bjorn3:asm_support_changes, r=nagisa
bors [Tue, 18 Jan 2022 14:32:52 +0000 (14:32 +0000)]
Auto merge of #92731 - bjorn3:asm_support_changes, r=nagisa

Avoid unnecessary monomorphization of inline asm related functions

This should reduce build time for codegen backends by avoiding duplicated monomorphization of certain inline asm related functions for each passed in closure type.

2 years agointra-doc links
lcnr [Mon, 17 Jan 2022 06:54:56 +0000 (07:54 +0100)]
intra-doc links

2 years agoprivacy: update `visit_infer`
lcnr [Mon, 10 Jan 2022 09:59:26 +0000 (10:59 +0100)]
privacy: update `visit_infer`

2 years agogeneric_arg_infer: placeholder in signature err
lcnr [Wed, 5 Jan 2022 10:43:21 +0000 (11:43 +0100)]
generic_arg_infer: placeholder in signature err

2 years agoremove unnecessary fixme
lcnr [Wed, 5 Jan 2022 10:42:45 +0000 (11:42 +0100)]
remove unnecessary fixme

2 years agochange `ct_infer` to a delay_span_bug
lcnr [Wed, 5 Jan 2022 10:42:08 +0000 (11:42 +0100)]
change `ct_infer` to a delay_span_bug

2 years agoAuto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
bors [Tue, 18 Jan 2022 09:58:39 +0000 (09:58 +0000)]
Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk

allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`

2 years agofix typo in `max` description for f32/f64
klensy [Tue, 18 Jan 2022 07:26:30 +0000 (10:26 +0300)]
fix typo in `max` description for f32/f64

2 years agoAuto merge of #93021 - matthiaskrgr:rollup-o7z8zoe, r=matthiaskrgr
bors [Tue, 18 Jan 2022 06:07:58 +0000 (06:07 +0000)]
Auto merge of #93021 - matthiaskrgr:rollup-o7z8zoe, r=matthiaskrgr

Rollup of 14 pull requests

Successful merges:

 - #92629 (Pick themes on settings page, not every page)
 - #92640 (Fix ICEs related to `Deref<Target=[T; N]>` on newtypes)
 - #92701 (Add some more attribute validation)
 - #92803 (Hide mobile sidebar on some clicks)
 - #92830 (Rustdoc style cleanups)
 - #92866 ("Does exists" typos fix)
 - #92870 (add `rustc_diagnostic_item` attribute to `AtomicBool` type)
 - #92914 (htmldocck: Add support for `/text()` in ``@snapshot`)`
 - #92923 (Abstract the pretty printer's ringbuffer to be infinitely sized)
 - #92946 (Exclude llvm-libunwind from the self-contained set on s390x-musl targets)
 - #92947 (rustdoc: Use `intersperse` in a `visit_path` function)
 - #92997 (Add `~const` bound test for negative impls)
 - #93004 (update codegen test for LLVM 14)
 - #93016 (Stabilize vec_spare_capacity)

Failed merges:

 - #92924 (Delete pretty printer tracing)

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

2 years agoDisable docs on aarch64-apple-darwin.
Eric Huss [Tue, 18 Jan 2022 04:18:56 +0000 (20:18 -0800)]
Disable docs on aarch64-apple-darwin.

This builder is the slowest in the fleet. This should cut a considerable
amount of time. The manifest should now include the docs from
x86_64-apple-darwin. Although those docs are slightly different, it
should be close enough. When aarch64-apple-darwin heads towards tier 1,
we can revisit whether or not to re-enable the docs.

2 years agoImprove documentation of splatted constants
Caleb Zulawski [Tue, 18 Jan 2022 03:51:04 +0000 (03:51 +0000)]
Improve documentation of splatted constants

2 years agoRollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 03:42:11 +0000 (04:42 +0100)]
Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-Simulacrum

Stabilize vec_spare_capacity

Closes #75017

2 years agoRollup merge of #93004 - krasimirgg:threadlocal-llvm-up, r=nikic
Matthias Krüger [Tue, 18 Jan 2022 03:42:10 +0000 (04:42 +0100)]
Rollup merge of #93004 - krasimirgg:threadlocal-llvm-up, r=nikic

update codegen test for LLVM 14

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

2 years agoRollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 03:42:09 +0000 (04:42 +0100)]
Rollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum

Add `~const` bound test for negative impls

Resolves #92114 which has been fixed in #92892.

2 years agoRollup merge of #92947 - vacuus:rustdoc-core-visit-path, r=camelid
Matthias Krüger [Tue, 18 Jan 2022 03:42:08 +0000 (04:42 +0100)]
Rollup merge of #92947 - vacuus:rustdoc-core-visit-path, r=camelid

rustdoc: Use `intersperse` in a `visit_path` function

(~~Is there a better way to word the title?~~ Eh, this works, I guess.)
I'm surprised that the compiler didn't complain when I left out the `.to_string()`, but hey, if it works then it works.

2 years agoRollup merge of #92946 - kaniini:chore/llvm-libunwind-s390x, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 03:42:07 +0000 (04:42 +0100)]
Rollup merge of #92946 - kaniini:chore/llvm-libunwind-s390x, r=Mark-Simulacrum

Exclude llvm-libunwind from the self-contained set on s390x-musl targets

llvm-libunwind does not support s390x targets at present, so we cannot build it
for s390x targets.  Accordingly, remove it from the self-contained set.

2 years agoRollup merge of #92923 - dtolnay:ringbuffer, r=petrochenkov
Matthias Krüger [Tue, 18 Jan 2022 03:42:06 +0000 (04:42 +0100)]
Rollup merge of #92923 - dtolnay:ringbuffer, r=petrochenkov

Abstract the pretty printer's ringbuffer to be infinitely sized

This PR backports https://github.com/dtolnay/prettyplease/commit/8e5e83c3ff7faaa272115a81b76f07a1d4a91969 from the `prettyplease` crate into `rustc_ast_pretty`.

Using a dedicated RingBuffer type with non-wrapping indices, instead of manually `%`-ing indices into a capped sized buffer, unlocks a number of simplifications to the pretty printing algorithm implementation in followup commits such as https://github.com/dtolnay/prettyplease/commit/fcb5968b1e1357497c7d7e205d22bb4e8c1dbd38 and https://github.com/dtolnay/prettyplease/commit/4427cedcb80294e89b823f923fdb16544c737bd9.

This change also greatly reduces memory overhead of the pretty printer. The old implementation always grows its buffer to 205920 bytes even for files without deeply nested code, because it only wraps its indices when they hit the maximum tolerable size of the ring buffer (the size after which the pretty printer will crash if there are that many tokens buffered). In contrast, the new implementation uses memory proportional to the peak number of simultaneously buffered tokens only, not the number of tokens that have ever been in the buffer.

Speaking of crashing the pretty printer and "maximum tolerable size", the constant used for that in the old implementation is a lie:

https://github.com/rust-lang/rust/blob/de9b573eedaaa6d6e7c00c986cccbee802f9287b/compiler/rustc_ast_pretty/src/pp.rs#L227-L228

It was raised from 3 to 55 in https://github.com/rust-lang/rust/pull/33934 because that was empirically the size that avoided crashing on one particular test crate, but according to https://github.com/rust-lang/rust/pull/33934#issuecomment-226700470 other syntax trees still crash at that size. There is no reason to believe that any particular size is good enough for arbitrary code, and using a large number like 55 adds overhead to inputs that never need close to that much of a buffer. The new implementation eliminates this tradeoff.

2 years agoRollup merge of #92914 - camelid:snapshot-text, r=GuillaumeGomez
Matthias Krüger [Tue, 18 Jan 2022 03:42:05 +0000 (04:42 +0100)]
Rollup merge of #92914 - camelid:snapshot-text, r=GuillaumeGomez

htmldocck: Add support for `/text()` in `@snapshot`

This allows just testing the text, in cases where the HTML tags don't
matter.

See https://github.com/rust-lang/rust/pull/92908#discussion_r785191758 for an example of when this would be useful.

r? `@GuillaumeGomez`

2 years agoRollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth
Matthias Krüger [Tue, 18 Jan 2022 03:42:04 +0000 (04:42 +0100)]
Rollup merge of #92870 - llogiq:atomic_bool_sym, r=Manishearth

add `rustc_diagnostic_item` attribute to `AtomicBool` type

I wanted to use this in clippy and found that it didn't work. So hopefully this addition will fix it.

2 years agoRollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum
Matthias Krüger [Tue, 18 Jan 2022 03:42:03 +0000 (04:42 +0100)]
Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum

"Does exists" typos fix

Fixed some typos

2 years agoRollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
Matthias Krüger [Tue, 18 Jan 2022 03:42:02 +0000 (04:42 +0100)]
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez

Rustdoc style cleanups

 - Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown

 Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html

 r? `@GuillaumeGomez`

2 years agoRollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez
Matthias Krüger [Tue, 18 Jan 2022 03:42:00 +0000 (04:42 +0100)]
Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez

Hide mobile sidebar on some clicks

When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close.

Fixes #92682

Demo: https://rustdoc.crud.net/jsha/hide-sidebar/std/string/struct.String.html

2 years agoRollup merge of #92701 - ehuss:even-more-attr-validation, r=matthewjasper
Matthias Krüger [Tue, 18 Jan 2022 03:41:59 +0000 (04:41 +0100)]
Rollup merge of #92701 - ehuss:even-more-attr-validation, r=matthewjasper

Add some more attribute validation

This adds some more validation for the position of attributes:

* `link` is only valid on an `extern` block
* `windows_subsystem` and `no_builtins` are only valid at the crate level

2 years agoRollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr
Matthias Krüger [Tue, 18 Jan 2022 03:41:58 +0000 (04:41 +0100)]
Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr

Fix ICEs related to `Deref<Target=[T; N]>` on newtypes

1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type.
    For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize.
Fixes #92626
Fixes #83704

2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done.
Fixes #92637

... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.