]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #92860 - CraftSpider:rustdoc-json-impl-ice, r=jsha
Matthias Krüger [Thu, 20 Jan 2022 22:37:31 +0000 (23:37 +0100)]
Rollup merge of #92860 - CraftSpider:rustdoc-json-impl-ice, r=jsha

Fix errors on blanket impls by ignoring the children of generated impls

Related to #83718

We can safely skip the children, as they don't contain any new info, and may be subtly different for reasons hard to track down, in ways that are consistently worse than the actual generic impl.

2 years agoRollup merge of #92856 - GuillaumeGomez:exclude-test-doc_auto_cfg, r=Nemo157
Matthias Krüger [Thu, 20 Jan 2022 22:37:30 +0000 (23:37 +0100)]
Rollup merge of #92856 - GuillaumeGomez:exclude-test-doc_auto_cfg, r=Nemo157

Exclude "test" from doc_auto_cfg

Fixes #91740.

cc `@Nemo157` (you were the one suggesting this iirc)
r? `@camelid`

2 years agoRollup merge of #91032 - eholk:generator-drop-tracking, r=nikomatsakis
Matthias Krüger [Thu, 20 Jan 2022 22:37:29 +0000 (23:37 +0100)]
Rollup merge of #91032 - eholk:generator-drop-tracking, r=nikomatsakis

Introduce drop range tracking to generator interior analysis

This PR addresses cases such as this one from #57478:
```rust
struct Foo;
impl !Send for Foo {}

let _: impl Send = || {
    let guard = Foo;
    drop(guard);
    yield;
};
```

Previously, the `generator_interior` pass would unnecessarily include the type `Foo` in the generator because it was not aware of the behavior of `drop`. We fix this issue by introducing a drop range analysis that finds portions of the code where a value is guaranteed to be dropped. If a value is dropped at all suspend points, then it is no longer included in the generator type. Note that we are using "dropped" in a generic sense to include any case in which a value has been moved. That is, we do not only look at calls to the `drop` function.

There are several phases to the drop tracking algorithm, and we'll go into more detail below.
1. Use `ExprUseVisitor` to find values that are consumed and borrowed.
2. `DropRangeVisitor` uses consume and borrow information to gather drop and reinitialization events, as well as build a control flow graph.
3. We then propagate drop and reinitialization information through the CFG until we reach a fix point (see `DropRanges::propagate_to_fixpoint`).
4. When recording a type (see `InteriorVisitor::record`), we check the computed drop ranges to see if that value is definitely dropped at the suspend point. If so, we skip including it in the type.

## 1. Use `ExprUseVisitor` to find values that are consumed and borrowed.

We use `ExprUseVisitor` to identify the places where values are consumed. We track both the `hir_id` of the value, and the `hir_id` of the expression that consumes it. For example, in the expression `[Foo]`, the `Foo` is consumed by the array expression, so after the array expression we can consider the `Foo` temporary to be dropped.

In this process, we also collect values that are borrowed. The reason is that the MIR transform for generators conservatively assumes anything borrowed is live across a suspend point (see `rustc_mir_transform::generator::locals_live_across_suspend_points`). We match this behavior here as well.

## 2. Gather drop events, reinitialization events, and control flow graph

After finding the values of interest, we perform a post-order traversal over the HIR tree to find the points where these values are dropped or reinitialized. We use the post-order index of each event because this is how the existing generator interior analysis refers to the position of suspend points and the scopes of variables.

During this traversal, we also record branching and merging information to handle control flow constructs such as `if`, `match`, and `loop`. This is necessary because values may be dropped along some control flow paths but not others.

## 3. Iterate to fixed point

The previous pass found the interesting events and locations, but now we need to find the actual ranges where things are dropped. Upon entry, we have a list of nodes ordered by their position in the post-order traversal. Each node has a set of successors. For each node we additionally keep a bitfield with one bit per potentially consumed value. The bit is set if we the value is dropped along all paths entering this node.

To compute the drop information, we first reverse the successor edges to find each node's predecessors. Then we iterate through each node, and for each node we set its dropped value bitfield to the intersection of all incoming dropped value bitfields.

If any bitfield for any node changes, we re-run the propagation loop again.

## 4. Ignore dropped values across suspend points

At this point we have a data structure where we can ask whether a value is guaranteed to be dropped at any post order index for the HIR tree. We use this information in `InteriorVisitor` to check whether a value in question is dropped at a particular suspend point. If it is, we do not include that value's type in the generator type.

Note that we had to augment the region scope tree to include all yields in scope, rather than just the last one as we did before.

r? `@nikomatsakis`

2 years agoMore clean up
Guillaume Gomez [Thu, 20 Jan 2022 21:13:32 +0000 (22:13 +0100)]
More clean up

2 years agoExtra cfg_hide a bit to handle inner cfgs
Guillaume Gomez [Sun, 16 Jan 2022 20:03:16 +0000 (21:03 +0100)]
Extra cfg_hide a bit to handle inner cfgs

2 years agoUpdate doc_auto_cfg test
Guillaume Gomez [Thu, 13 Jan 2022 14:50:21 +0000 (15:50 +0100)]
Update doc_auto_cfg test

2 years agoExclude "test" from doc_auto_cfg rendering
Guillaume Gomez [Thu, 13 Jan 2022 14:50:11 +0000 (15:50 +0100)]
Exclude "test" from doc_auto_cfg rendering

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 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 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 agoFix build after rebase
Eric Holk [Tue, 18 Jan 2022 22:42:39 +0000 (14:42 -0800)]
Fix build after rebase

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

2 years agoUse .. patterns in cfg_build.rs
Eric Holk [Tue, 18 Jan 2022 22:02:42 +0000 (14:02 -0800)]
Use .. patterns in cfg_build.rs

2 years agoRespond to code review comments
Eric Holk [Sat, 15 Jan 2022 01:45:00 +0000 (17:45 -0800)]
Respond to code review comments

2 years agoSafely handle partial drops
Eric Holk [Wed, 5 Jan 2022 22:11:37 +0000 (14:11 -0800)]
Safely handle partial drops

We previously weren't tracking partial re-inits while being too
aggressive around partial drops. With this change, we simply ignore
partial drops, which is the safer, more conservative choice.

2 years agodrop_ranges: Add TrackedValue enum
Eric Holk [Mon, 20 Dec 2021 23:50:31 +0000 (15:50 -0800)]
drop_ranges: Add TrackedValue enum

This makes it clearer what values we are tracking and why.

2 years agoUpdate async-fn-nonsend.rs
Eric Holk [Fri, 17 Dec 2021 23:05:38 +0000 (15:05 -0800)]
Update async-fn-nonsend.rs

The previous commit made the non_sync_with_method_call case pass due to
the await being unreachable. Unfortunately, this isn't actually the
behavior the test was verifying. This change lifts the panic into a
helper function so that the generator analysis still thinks the await
is reachable, and therefore we preserve the same testing behavior.

2 years agoHandle uninhabited return types
Eric Holk [Fri, 17 Dec 2021 22:36:51 +0000 (14:36 -0800)]
Handle uninhabited return types

This changes drop range analysis to handle uninhabited return types such
as `!`. Since these calls to these functions do not return, we model
them as ending in an infinite loop.

2 years agoTrack changed bitsets in CFG propagation
Eric Holk [Fri, 17 Dec 2021 01:15:35 +0000 (17:15 -0800)]
Track changed bitsets in CFG propagation

This reduces the amount of work done, especially in later iterations,
by only processing nodes whose predecessors changed in the previous
iteration, or earlier in the current iteration. This also has the side
effect of completely ignoring all unreachable nodes.

2 years agoRemove clones and most allocations from propagate_to_fixpoint
Eric Holk [Thu, 16 Dec 2021 23:46:56 +0000 (15:46 -0800)]
Remove clones and most allocations from propagate_to_fixpoint

2 years agoHandle empty loops better
Eric Holk [Thu, 16 Dec 2021 21:34:39 +0000 (13:34 -0800)]
Handle empty loops better

2 years agoExplicitly list all ExprKinds in cfg_build
Eric Holk [Thu, 16 Dec 2021 20:38:08 +0000 (12:38 -0800)]
Explicitly list all ExprKinds in cfg_build

Also rearranges the existing arms to be more logical. For example, Break
and Continue come closer to Loop now.

2 years agoHandle reinits in match guards
Eric Holk [Thu, 16 Dec 2021 20:07:36 +0000 (12:07 -0800)]
Handle reinits in match guards

2 years agoMore comments and refactoring
Eric Holk [Thu, 16 Dec 2021 00:00:48 +0000 (16:00 -0800)]
More comments and refactoring

The refactoring mainly keeps the separation between the modules clearer.
For example, process_deferred_edges function moved to cfg_build.rs since
that is really part of building the CFG, not finding the fixpoint.

Also, we use PostOrderId instead of usize in a lot more places now.

2 years agoUpdate stderr files
Eric Holk [Wed, 15 Dec 2021 20:35:34 +0000 (12:35 -0800)]
Update stderr files

2 years agoFixing formatting
Eric Holk [Tue, 14 Dec 2021 00:07:02 +0000 (16:07 -0800)]
Fixing formatting

2 years agoAdditional cleanup
Eric Holk [Mon, 13 Dec 2021 23:01:26 +0000 (15:01 -0800)]
Additional cleanup

This cleans up the refactoring from the previous patch and cleans things
up a bit. Each module has a clear entry point and everything else is
private.

2 years agoRefactor drop_ranges
Eric Holk [Mon, 13 Dec 2021 18:47:28 +0000 (10:47 -0800)]
Refactor drop_ranges

Splits drop_ranges into drop_ranges::record_consumed_borrow,
drop_ranges::cfg_build, and drop_ranges::cfg_propagate. The top level
drop_ranges module has an entry point that does all the coordination of
the other three phases, using code original in generator_interior.

2 years agoAddress code review comments
Eric Holk [Mon, 13 Dec 2021 18:47:28 +0000 (10:47 -0800)]
Address code review comments

1. Add test case for partial drops
2. Simplify code in `propagate_to_fixpoint` and remove most clones
3. Clean up PostOrderIndex creation

2 years agoAdd more comments
Eric Holk [Mon, 6 Dec 2021 19:08:00 +0000 (11:08 -0800)]
Add more comments

2 years agoUpdate async-fn-nonsend.stderr
Eric Holk [Mon, 22 Nov 2021 22:53:02 +0000 (14:53 -0800)]
Update async-fn-nonsend.stderr

2 years agoRefactor code to keep most drop range analysis in drop_ranges.rs
Eric Holk [Fri, 19 Nov 2021 02:33:40 +0000 (18:33 -0800)]
Refactor code to keep most drop range analysis in drop_ranges.rs

2 years agoMore comments and small cleanups
Eric Holk [Fri, 19 Nov 2021 01:26:30 +0000 (17:26 -0800)]
More comments and small cleanups

2 years agoFix control flow handling in generator_interior
Eric Holk [Thu, 18 Nov 2021 01:53:47 +0000 (17:53 -0800)]
Fix control flow handling in generator_interior

All tests pass now! The issue was that we weren't handling all edges
correctly, but now they are handled consistently.

This includes code to dump a graphviz file for the CFG we built for drop
tracking.

Also removes old DropRanges tests.

2 years agoHandle break and continue. Change fixpoint computation to handle unreachable nodes.
Eric Holk [Wed, 17 Nov 2021 19:39:27 +0000 (11:39 -0800)]
Handle break and continue. Change fixpoint computation to handle unreachable nodes.

2 years agoRevamped DropRange data structure
Eric Holk [Thu, 11 Nov 2021 01:32:04 +0000 (17:32 -0800)]
Revamped DropRange data structure

Not currently working. Need to flow drop information.

2 years agoMore tracing and tests
Eric Holk [Fri, 5 Nov 2021 22:10:33 +0000 (15:10 -0700)]
More tracing and tests

2 years agoHandle more cases with conditionally initialized/dropped values
Eric Holk [Thu, 4 Nov 2021 23:38:47 +0000 (16:38 -0700)]
Handle more cases with conditionally initialized/dropped values

2 years agoBasic loop support
Eric Holk [Thu, 4 Nov 2021 17:56:07 +0000 (10:56 -0700)]
Basic loop support

2 years agoSupport reinitialization of variables
Eric Holk [Wed, 3 Nov 2021 23:28:07 +0000 (16:28 -0700)]
Support reinitialization of variables

2 years agoSupport conditional drops
Eric Holk [Thu, 28 Oct 2021 00:46:08 +0000 (17:46 -0700)]
Support conditional drops

This adds support for branching and merging control flow and uses this
to correctly handle the case where a value is dropped in one branch of
an if expression but not another.

There are other cases we need to handle, which will come in follow up
patches.

Issue #57478

2 years agoAttribute drop to parent expression of the consume point
Eric Holk [Tue, 26 Oct 2021 00:01:24 +0000 (17:01 -0700)]
Attribute drop to parent expression of the consume point

This is needed to handle cases like `[a, b.await, c]`. `ExprUseVisitor`
considers `a` to be consumed when it is passed to the array, but the
array is not quite live yet at that point. This means we were missing
the `a` value across the await point. Attributing drops to the parent
expression means we do not consider the value consumed until the
consuming expression has finished.

Issue #57478

2 years agoMake generator and async-await tests pass
Eric Holk [Fri, 22 Oct 2021 22:49:38 +0000 (15:49 -0700)]
Make generator and async-await tests pass

The main change needed to make this work is to do a pessimistic over-
approximation for AssignOps. The existing ScopeTree analysis in
region.rs works by doing both left to right and right to left order and
then choosing the most conservative ordering. This behavior is needed
because AssignOp's evaluation order depends on whether it is a primitive
type or an overloaded operator, which runs as a method call.

This change mimics the same behavior as region.rs in
generator_interior.rs.

Issue #57478

2 years agoTrack drops across multiple yields
Eric Holk [Fri, 22 Oct 2021 19:45:02 +0000 (12:45 -0700)]
Track drops across multiple yields

2 years agoTrack drop points in generator_interior
Eric Holk [Wed, 20 Oct 2021 23:42:53 +0000 (16:42 -0700)]
Track drop points in generator_interior

This change adds the basic infrastructure for tracking drop ranges in
generator interior analysis, which allows us to exclude dropped types
from the generator type.

Not yet complete, but many of the async/await and generator tests pass.
The main missing piece is tracking branching control flow (e.g. around
an `if` expression). The patch does include support, however, for
multiple yields in th e same block.

Issue #57478

2 years agoAdd test case for #57478
Eric Holk [Fri, 8 Oct 2021 22:09:20 +0000 (15:09 -0700)]
Add test case for #57478

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.