]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #80095 - jyn514:stability-on-demand, r=GuillaumeGomez
bors [Wed, 23 Dec 2020 03:35:32 +0000 (03:35 +0000)]
Auto merge of #80095 - jyn514:stability-on-demand, r=GuillaumeGomez

[rustdoc] Calculate stability, const_stability, and deprecation on-demand

Previously, they would always be calculated ahead of time, which bloated the size of `clean::Item`.

Builds on https://github.com/rust-lang/rust/pull/80090 and should not be merged before. Helps with https://github.com/rust-lang/rust/issues/79103 and https://github.com/rust-lang/rust/issues/76382.

cc https://github.com/rust-lang/rust/pull/80014#issuecomment-746810284

This brings `Item` down to 568 bytes, down from 616.

3 years agoAuto merge of #80314 - GuillaumeGomez:rollup-9rc48vx, r=GuillaumeGomez
bors [Wed, 23 Dec 2020 00:41:46 +0000 (00:41 +0000)]
Auto merge of #80314 - GuillaumeGomez:rollup-9rc48vx, r=GuillaumeGomez

Rollup of 17 pull requests

Successful merges:

 - #80136 (Add test for issue #74824)
 - #80203 (Edit rustc_middle::lint::LintSource docs)
 - #80204 (docs: Edit rustc_middle::ty::query::on_disk_cache)
 - #80219 (Fix labels for 'Library Tracking Issue' template)
 - #80222 (Fix rustc-std-workspace-core documentation)
 - #80223 (docs: Fix outdated crate reference)
 - #80225 (Add module-level docs to rustc_middle::ty)
 - #80241 (Fix typo)
 - #80248 (Remove `I-prioritize` from Zulip topic)
 - #80266 (Remove redundant test)
 - #80272 (rustc_span: Provide a reserved identifier check for a specific edition)
 - #80285 (Update books)
 - #80286 (docs: Edit rustc_middle::middle::privacy)
 - #80297 (Add some intra-doc links to compiler docs)
 - #80298 (Improve the code quality by using matches macro)
 - #80299 (Turn helper method into a closure)
 - #80302 (docs: Update rustc_middle::middle::region::ScopeTree)

Failed merges:

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

3 years agoRollup merge of #80302 - pierwill:fix-80287, r=lcnr
Guillaume Gomez [Tue, 22 Dec 2020 23:14:01 +0000 (00:14 +0100)]
Rollup merge of #80302 - pierwill:fix-80287, r=lcnr

docs: Update rustc_middle::middle::region::ScopeTree

Correct return type in docs for [`yield_in_source`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/middle/region/struct.ScopeTree.html#method.yield_in_scope) method.

Closes #80287.

3 years agoRollup merge of #80299 - LingMan:helper, r=lcnr
Guillaume Gomez [Tue, 22 Dec 2020 23:13:59 +0000 (00:13 +0100)]
Rollup merge of #80299 - LingMan:helper, r=lcnr

Turn helper method into a closure

`replace_prefix` is currently implemented as a method but has no real relation
to the struct it is implemented on. Turn it into a closure and move it into the
only method from which it is called.

`@rustbot` modify labels +C-cleanup +T-compiler
r? `@lcnr`

3 years agoRollup merge of #80298 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez
Guillaume Gomez [Tue, 22 Dec 2020 23:13:56 +0000 (00:13 +0100)]
Rollup merge of #80298 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez

Improve the code quality by using matches macro

Improved the code quality by using matches macro
r? `@GuillaumeGomez`

3 years agoRollup merge of #80297 - jyn514:more-docs, r=bjorn3
Guillaume Gomez [Tue, 22 Dec 2020 23:13:53 +0000 (00:13 +0100)]
Rollup merge of #80297 - jyn514:more-docs, r=bjorn3

Add some intra-doc links to compiler docs

r? `@pierwill`

3 years agoRollup merge of #80286 - pierwill:rustc-middle-privacy, r=petrochenkov
Guillaume Gomez [Tue, 22 Dec 2020 23:13:52 +0000 (00:13 +0100)]
Rollup merge of #80286 - pierwill:rustc-middle-privacy, r=petrochenkov

docs: Edit rustc_middle::middle::privacy

Add descriptions of `AccessLevel` and `AccessLevels`.

Add missing punctuation.

3 years agoRollup merge of #80285 - ehuss:update-books, r=ehuss
Guillaume Gomez [Tue, 22 Dec 2020 23:13:50 +0000 (00:13 +0100)]
Rollup merge of #80285 - ehuss:update-books, r=ehuss

Update books

## nomicon

2 commits in d8383b65f7948c2ca19191b3b4bd709b403aaf45..a5a48441d411f61556b57d762b03d6874afe575d
2020-11-22 10:24:42 -0500 to 2020-12-06 10:39:41 +0900
- Update atomics.md (rust-lang/nomicon#249)
- Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate` (rust-lang/nomicon#248)

## reference

2 commits in a8afdca5d0715b2257b6f8b9a032fd4dd7dae855..b278478b766178491a8b6f67afa4bcd6b64d977a
2020-11-30 06:44:46 -0800 to 2020-12-21 18:18:03 -0800
- Update unions for safe ManuallyDrop assignment. (rust-lang/reference#912)
- Removing ambiguity in type-layout.md (rust-lang/reference#911)

## book

25 commits in a190438d77d28041f24da4f6592e287fab073a61..5bb44f8b5b0aa105c8b22602e9b18800484afa21
2020-11-16 10:44:08 -0600 to 2020-12-18 20:07:31 -0500
- Make some further edits to rust-lang/book#2447
- Merge remote-tracking branch 'origin/pr/2447'
- Remove copied and dangling link brackets
- Merge remote-tracking branch 'origin/pr/2359'
- Override toolchain to nightly for run lints action. (rust-lang/book#2528)
- Remove an uneeded 'static lifetime (rust-lang/book#1752)
- Fixes rust-lang/book#2330. Clarify why the lock is held too long
- Update paragraph about rustfmt in Chapter 1.2 (rust-lang/book#2304)
- Clarify language around  further from rust-lang/book#2418
- Merge remote-tracking branch 'origin/pr/2418'
- Merge remote-tracking branch 'origin/pr/2475'
- Add some further edits to rust-lang/book#2433
- Merge remote-tracking branch 'origin/pr/2433'
- Note all the method families to handle integer overflow
- Merge remote-tracking branch 'origin/pr/2405'
- Fix rust-lang/book#1855 - incorporate new reference cycle diagram
- Make some further edits to the changes in rust-lang/book#1886
- Merge remote-tracking branch 'origin/pr/1886'
- Make some further edits to rust-lang/book#1998
- Merge remote-tracking branch 'origin/pr/1998'
- Update Rust version and output (rust-lang/book#2518)
- Fix typo, regarding privileged ports being up to 1023 instead of 1024 (rust-lang/book#2509)
- Change "appendixes" to "appendices" in intro. (rust-lang/book#2498)
- Update 16-11 to use method call expression for `clone` (rust-lang/book#2511)
- Correct chapter 20 final listing (rust-lang/book#2516)

## rust-by-example

7 commits in 236c734a2cb323541b3394f98682cb981b9ec086..1cce0737d6a7d3ceafb139b4a206861fb1dcb2ab
2020-11-30 14:05:49 -0300 to 2020-12-21 17:36:29 -0300
- Add book.description in book.toml (rust-lang/rust-by-example#1397)
- Simplify the call of filter_map (rust-lang/rust-by-example#1396)
- Update README.md (rust-lang/rust-by-example#1382)
- Add missing main function in static life time example. (rust-lang/rust-by-example#1383)
- Clarify first matching arm and all possible values (rust-lang/rust-by-example#1395)
- Clarify distinction between for iter and into_iter (rust-lang/rust-by-example#1394)
- Drop extern crate (rust-lang/rust-by-example#1393)

3 years agoRollup merge of #80272 - petrochenkov:kwed, r=oli-obk
Guillaume Gomez [Tue, 22 Dec 2020 23:13:48 +0000 (00:13 +0100)]
Rollup merge of #80272 - petrochenkov:kwed, r=oli-obk

rustc_span: Provide a reserved identifier check for a specific edition

while keeping edition evaluation lazy because it may be expensive.

Needed for https://github.com/rust-lang/rust/pull/80226.

3 years agoRollup merge of #80266 - bugadani:dup-test, r=jyn514
Guillaume Gomez [Tue, 22 Dec 2020 23:13:47 +0000 (00:13 +0100)]
Rollup merge of #80266 - bugadani:dup-test, r=jyn514

Remove redundant test

Remove ignored test. This test can also be found at src/test/rustdoc-ui/intra-doc/double-anchor.rs and the second version isn't ignored.

r? ``@jyn514``

3 years agoRollup merge of #80248 - camelid:prioritize-zulip-topic, r=Mark-Simulacrum
Guillaume Gomez [Tue, 22 Dec 2020 23:13:45 +0000 (00:13 +0100)]
Rollup merge of #80248 - camelid:prioritize-zulip-topic, r=Mark-Simulacrum

Remove `I-prioritize` from Zulip topic

It doesn't add anything since every topic in
`t-compiler/wg-prioritization/alerts` is about prioritization.
And it makes it harder to see the issue title, which is what the topic
is actually about.

cc ``@rust-lang/wg-prioritization``

3 years agoRollup merge of #80241 - pierwill:patch-12, r=lcnr
Guillaume Gomez [Tue, 22 Dec 2020 23:13:43 +0000 (00:13 +0100)]
Rollup merge of #80241 - pierwill:patch-12, r=lcnr

Fix typo

Fix typo in rustc_middle::ty::inhabitedness::DefIdForest docs.

3 years agoRollup merge of #80225 - pierwill:patch-11, r=lcnr
Guillaume Gomez [Tue, 22 Dec 2020 23:13:41 +0000 (00:13 +0100)]
Rollup merge of #80225 - pierwill:patch-11, r=lcnr

Add module-level docs to rustc_middle::ty

I thought it would be nice to point out `Ty` and `TyCtxt` on the module page, and link out to the [rustc-dev-guide chapter](https://rustc-dev-guide.rust-lang.org/ty.html).

3 years agoRollup merge of #80223 - pierwill:patch-10, r=lcnr
Guillaume Gomez [Tue, 22 Dec 2020 23:13:40 +0000 (00:13 +0100)]
Rollup merge of #80223 - pierwill:patch-10, r=lcnr

docs: Fix outdated crate reference

3 years agoRollup merge of #80222 - GreenRecycleBin:daniel/fix-rustc-std-workspace-core-document...
Guillaume Gomez [Tue, 22 Dec 2020 23:13:38 +0000 (00:13 +0100)]
Rollup merge of #80222 - GreenRecycleBin:daniel/fix-rustc-std-workspace-core-documentation, r=jyn514

Fix rustc-std-workspace-core documentation

r? ```@steveklabnik```

3 years agoRollup merge of #80219 - camelid:library_tracking_issue-labels, r=m-ou-se
Guillaume Gomez [Tue, 22 Dec 2020 23:13:36 +0000 (00:13 +0100)]
Rollup merge of #80219 - camelid:library_tracking_issue-labels, r=m-ou-se

Fix labels for 'Library Tracking Issue' template

Each label needs to be separated by a comma (see the ICE issue template
for an example of correct usage).

r? `````@m-ou-se`````

3 years agoRollup merge of #80204 - pierwill:pierwill-rustcmiddle-ondisk, r=varkor
Guillaume Gomez [Tue, 22 Dec 2020 23:13:34 +0000 (00:13 +0100)]
Rollup merge of #80204 - pierwill:pierwill-rustcmiddle-ondisk, r=varkor

docs: Edit rustc_middle::ty::query::on_disk_cache

Expand abbreviations for "incremental compliation".

Also added the word "to" to the description of CacheEncoder.

3 years agoRollup merge of #80203 - pierwill:pierwill-rustcmiddle-lint, r=oli-obk
Guillaume Gomez [Tue, 22 Dec 2020 23:13:33 +0000 (00:13 +0100)]
Rollup merge of #80203 - pierwill:pierwill-rustcmiddle-lint, r=oli-obk

Edit rustc_middle::lint::LintSource docs

Edit punctuation in doc comment for [rustc_middle::lint::LintSource::CommandLine](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/enum.LintSource.html#variant.CommandLine).

3 years agoRollup merge of #80136 - aDotInTheVoid:74824-test, r=Mark-Simulacrum
Guillaume Gomez [Tue, 22 Dec 2020 23:13:31 +0000 (00:13 +0100)]
Rollup merge of #80136 - aDotInTheVoid:74824-test, r=Mark-Simulacrum

Add test for issue #74824

It was fixed a while ago, but doesn't have a test.

Closes #74824

3 years agoAuto merge of #80242 - Nadrieril:explain-and-factor-splitting, r=varkor
bors [Tue, 22 Dec 2020 21:51:04 +0000 (21:51 +0000)]
Auto merge of #80242 - Nadrieril:explain-and-factor-splitting, r=varkor

Clarify constructor splitting in exhaustiveness checking

I reworked the explanation of the algorithm completely to make it properly account for the various extensions we've added. This includes constructor splitting, which was previously not clearly included in the algorithm. This makes wildcards less magical; I added some detailed examples; and this distinguishes clearly between constructors that only make sense in patterns (like ranges) and those that make sense for values (like `Some`). This reformulation had been floating around in my mind for a while, and I'm quite happy with how it turned out. Let me know how you feel about it.
I also factored out all three cases of splitting (wildcards, ranges and slices) into dedicated structs to encapsulate the complicated bits.
I measured no perf impact but I don't trust my local measurements for refactors since https://github.com/rust-lang/rust/pull/79284.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking

3 years agoAuto merge of #80177 - tgnottingham:foreign_defpathhash_registration, r=Aaron1011
bors [Tue, 22 Dec 2020 19:02:28 +0000 (19:02 +0000)]
Auto merge of #80177 - tgnottingham:foreign_defpathhash_registration, r=Aaron1011

rustc_query_system: explicitly register reused dep nodes

Register nodes that we've reused from the previous session explicitly
with `OnDiskCache`. Previously, we relied on this happening as a side
effect of accessing the nodes in the `PreviousDepGraph`. For the sake of
performance and avoiding unintended side effects, register explictily.

3 years agodocs: Update rustc_middle::middle::region::ScopeTree
pierwill [Tue, 22 Dec 2020 18:50:41 +0000 (10:50 -0800)]
docs: Update rustc_middle::middle::region::ScopeTree

This corrects the return type in docs for yield_in_source method.

Closes #80287.

3 years agoAuto merge of #80071 - jyn514:timings, r=Mark-Simulacrum
bors [Tue, 22 Dec 2020 16:09:59 +0000 (16:09 +0000)]
Auto merge of #80071 - jyn514:timings, r=Mark-Simulacrum

Add more timing info to rustdoc

This helped me confirm in https://github.com/rust-lang/rust/issues/79103#issuecomment-745737864 that get_blanket_impls is indeed what's taking all the time on stm32.

r? `@Mark-Simulacrum`

3 years agoImprove the code quality by using matches macro
PankajChaudhary5 [Tue, 22 Dec 2020 15:22:38 +0000 (20:52 +0530)]
Improve the code quality by using matches macro

3 years agoFix a comment
Nadrieril [Tue, 22 Dec 2020 11:28:17 +0000 (11:28 +0000)]
Fix a comment

3 years agoApply suggestions from code review
Nadrieril [Tue, 22 Dec 2020 06:09:54 +0000 (06:09 +0000)]
Apply suggestions from code review

Co-authored-by: varkor <github@varkor.com>
3 years agoSimplify field filtering
Nadrieril [Sat, 19 Dec 2020 07:11:00 +0000 (07:11 +0000)]
Simplify field filtering

3 years agoMake the special "missing patterns" constructor real
Nadrieril [Sun, 20 Dec 2020 00:39:37 +0000 (00:39 +0000)]
Make the special "missing patterns" constructor real

3 years agoCompletely rework the explanation of the algorithm
Nadrieril [Sun, 20 Dec 2020 13:29:39 +0000 (13:29 +0000)]
Completely rework the explanation of the algorithm

3 years agoPass `Matrix` explicitly instead of via `PatCtxt`
Nadrieril [Sun, 20 Dec 2020 14:29:42 +0000 (14:29 +0000)]
Pass `Matrix` explicitly instead of via `PatCtxt`

3 years agoInline the constructor-specific `split` functions
Nadrieril [Sun, 20 Dec 2020 14:22:53 +0000 (14:22 +0000)]
Inline the constructor-specific `split` functions

3 years agoInline `all_constructors`
Nadrieril [Mon, 14 Dec 2020 01:09:06 +0000 (01:09 +0000)]
Inline `all_constructors`

3 years agoRebrand `MissingConstructors` as `SplitWildcard`
Nadrieril [Sun, 13 Dec 2020 23:56:13 +0000 (23:56 +0000)]
Rebrand `MissingConstructors` as `SplitWildcard`

3 years agoFactor out `SplitVarLenSlice` used for slice splitting
Nadrieril [Fri, 11 Dec 2020 22:20:14 +0000 (22:20 +0000)]
Factor out `SplitVarLenSlice` used for slice splitting

3 years agoRun the annoying lint separately
Nadrieril [Sat, 19 Dec 2020 00:37:36 +0000 (00:37 +0000)]
Run the annoying lint separately

3 years agoFactor out `SplitIntRange` used for integer range splitting
Nadrieril [Thu, 10 Dec 2020 13:52:51 +0000 (13:52 +0000)]
Factor out `SplitIntRange` used for integer range splitting

3 years agoAdd some tests
Nadrieril [Sat, 14 Nov 2020 21:50:53 +0000 (21:50 +0000)]
Add some tests

3 years agoTurn helper method into a closure
LingMan [Tue, 22 Dec 2020 15:18:34 +0000 (16:18 +0100)]
Turn helper method into a closure

`replace_prefix` is currently implemented as a method but has no real relation
to the struct it is implemented on. Turn it into a closure and move it into the
only method from which it is called.

3 years agoAdd some intra-doc links to compiler docs
Joshua Nelson [Tue, 22 Dec 2020 14:54:23 +0000 (09:54 -0500)]
Add some intra-doc links to compiler docs

3 years agoAuto merge of #79451 - usbalbin:array_zip, r=m-ou-se
bors [Tue, 22 Dec 2020 13:19:40 +0000 (13:19 +0000)]
Auto merge of #79451 - usbalbin:array_zip, r=m-ou-se

Added [T; N]::zip()

This is my first PR to rust so I hope I have done everything right, or at least close :)

---

This is PR adds the array method `[T; N]::zip()` which, in my mind, is a natural extension to #75212.

My implementation of `zip()` is mostly just a modified copy-paste of `map()`. Should I keep the comments? Also am I right in assuming there should be no way for the `for`-loop to panic, thus no need for the dropguard seen in the `map()`-function?

The doc comment is in a similar way a slightly modified copy paste of [`Iterator::zip()`](https://doc.rust-lang.org/beta/std/iter/trait.Iterator.html#method.zip)

`@jplatte` mentioned in [#75490](https://github.com/rust-lang/rust/pull/75490#issuecomment-677790758) `zip_with()`,
> zip and zip_with seem like they would be useful :)

is this something I should add (assuming there is interest for this PR at all :))

3 years agoAuto merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint, r=varkor
bors [Tue, 22 Dec 2020 10:32:03 +0000 (10:32 +0000)]
Auto merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint, r=varkor

Rename `overlapping_patterns` lint

As discussed in https://github.com/rust-lang/rust/issues/65477. I also tweaked a few things along the way.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking

3 years agoAuto merge of #80264 - tmiasko:stdarch, r=Amanieu
bors [Tue, 22 Dec 2020 06:36:22 +0000 (06:36 +0000)]
Auto merge of #80264 - tmiasko:stdarch, r=Amanieu

Update stdarch submodule

Changes:

* Avx512bw
* Move code out of constify macros

3 years agodocs: Edit rustc_middle::middle::privacy
pierwill [Tue, 22 Dec 2020 04:00:18 +0000 (20:00 -0800)]
docs: Edit rustc_middle::middle::privacy

Add descriptions of `AccessLevel` and `AccessLevels`.

Add missing punctuation.

3 years agoUpdate books
Eric Huss [Tue, 22 Dec 2020 03:00:49 +0000 (19:00 -0800)]
Update books

3 years agoAuto merge of #80208 - bugadani:generics-of-alloc, r=matthewjasper
bors [Tue, 22 Dec 2020 00:20:14 +0000 (00:20 +0000)]
Auto merge of #80208 - bugadani:generics-of-alloc, r=matthewjasper

Reserve necessary space for params in generics_of

Always reserve space for the exact number of generic parameters we need in generics_of. As far as I can see, the default is 0/4 elements based on has_self, and the vector grows on after that.

3 years agorustc_span: Provide a reserved identifier check for a specific edition
Vadim Petrochenkov [Mon, 21 Dec 2020 18:59:57 +0000 (21:59 +0300)]
rustc_span: Provide a reserved identifier check for a specific edition

Edition evaluation is kept lazy because it may be expensive.

3 years agoRemove redundant test
Dániel Buga [Mon, 21 Dec 2020 16:40:39 +0000 (17:40 +0100)]
Remove redundant test

3 years agoAuto merge of #79270 - RalfJung:array-repeat-consts, r=oli-obk
bors [Mon, 21 Dec 2020 13:12:36 +0000 (13:12 +0000)]
Auto merge of #79270 - RalfJung:array-repeat-consts, r=oli-obk

Acknowledge that `[CONST; N]` is stable

When `const_in_array_repeat_expressions` (RFC 2203) got unstably implemented as part of https://github.com/rust-lang/rust/pull/61749, accidentally, the special case of repeating a *constant* got stabilized immediately. That is why the following code works on stable:

```rust
const EMPTY: Vec<i32> = Vec::new();

pub const fn bar() -> [Vec<i32>; 2] {
    [EMPTY; 2]
}

fn main() {
    let x = bar();
}
```

In contrast, if we had written `[expr; 2]` for some expression that is not *literally* a constant but could be evaluated at compile-time (e.g. `(EMPTY,).0`), this would have failed.

We could take back this stabilization as it was clearly accidental. However, I propose we instead just officially accept this and stabilize a small subset of RFC 2203, while leaving the more complex case of general expressions that could be evaluated at compile-time unstable. Making that case work well is pretty much blocked on inline `const` expressions (to avoid relying too much on [implicit promotion](https://github.com/rust-lang/const-eval/blob/master/promotion.md)), so it could take a bit until it comes to full fruition. `[CONST; N]` is an uncontroversial subset of this feature that has no semantic ambiguities, does not rely on promotion, and basically provides the full expressive power of RFC 2203 but without the convenience (people have to define constants to repeat them, possibly using associated consts if generics are involved).

Well, I said "no semantic ambiguities", that is only almost true... the one point I am not sure about is `[CONST; 0]`. There are two possible behaviors here: either this is equivalent to `let x = CONST; [x; 0]`, or it is a NOP (if we argue that the constant is never actually instantiated). The difference between the two is that if `CONST` has a destructor, it should run in the former case (but currently doesn't, due to https://github.com/rust-lang/rust/issues/74836); but should not run if it is considered a NOP. For regular `[x; 0]` there seems to be consensus on running drop (there isn't really an alternative); any opinions for the `CONST` special case? Should this instantiate the const only to immediately run its destructors? That seems somewhat silly to me. After all, the `let`-expansion does *not* work in general, for `N > 1`.

Cc `@rust-lang/lang` `@rust-lang/wg-const-eval`
Cc https://github.com/rust-lang/rust/issues/49147

3 years agoAuto merge of #80205 - tomprogrammer:prettyprint-pattern-mut-binding, r=davidtwco
bors [Mon, 21 Dec 2020 10:21:01 +0000 (10:21 +0000)]
Auto merge of #80205 - tomprogrammer:prettyprint-pattern-mut-binding, r=davidtwco

Fix pretty printing an AST representing `&(mut ident)`

The PR fixes a misguiding help diagnostic in the parser that I reported in #80186. I discovered that the parsers recovery and reporting logic was correct but the pretty printer produced wrong code for the example. (Details in https://github.com/rust-lang/rust/issues/80186#issuecomment-748498676)

Example:
```rust
#![allow(unused_variables)]
fn main() {
    let mut &x = &0;
}
```

The AST fragment

`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), Mutability::Not)`

was printed to be `&mut ident`. But this wouldn't round trip through parsing again, because then it would be:

`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Not), ..), Mutability::Mut)`

Now the pretty-printer prints `&(mut ident)`. Reparsing that code results in the AST fragment

`PatKind::Ref(PatKind::Paren(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..)), Mutability::Not)`

which I think should behave like the original pattern.

Old diagnostic:
```
error: `mut` must be attached to each individual binding
 --> src/main.rs:3:9
  |
3 |     let mut &x = &0;
  |         ^^^^^^ help: add `mut` to each binding: `&mut x`
  |
  = note: `mut` may be followed by `variable` and `variable @ pattern`
```

New diagnostic:

```
error: `mut` must be attached to each individual binding
 --> src/main.rs:3:9
  |
3 |     let mut &x = &0;
  |         ^^^^^^ help: add `mut` to each binding: `&(mut x)`
  |
  = note: `mut` may be followed by `variable` and `variable @ pattern`
```

Fixes #80186

3 years agoAuto merge of #80206 - poliorcetics:rustdoc-default-langstring, r=GuillaumeGomez...
bors [Mon, 21 Dec 2020 07:00:17 +0000 (07:00 +0000)]
Auto merge of #80206 - poliorcetics:rustdoc-default-langstring, r=GuillaumeGomez,jyn514

impl Default for LangString, replacing all_false by default

Fix #80015

`@rustbot` label C-cleanup  T-rustdoc  A-markdown-parsing

3 years agoAuto merge of #80253 - Dylan-DPC:rollup-bkmn74z, r=Dylan-DPC
bors [Mon, 21 Dec 2020 04:08:35 +0000 (04:08 +0000)]
Auto merge of #80253 - Dylan-DPC:rollup-bkmn74z, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #80159 (Add array search aliases)
 - #80166 (Edit rustc_middle docs)
 - #80170 (Fix ICE when lookup method in trait for type that have bound vars)
 - #80171 (Edit rustc_middle::ty::TyKind docs)
 - #80199 (also const-check FakeRead)
 - #80211 (Handle desugaring in impl trait bound suggestion)
 - #80236 (Use pointer type in AtomicPtr::swap implementation)
 - #80239 (Update Clippy)
 - #80240 (make sure installer only creates directories in DESTDIR)
 - #80244 (Cleanup markdown span handling)
 - #80250 (Minor cleanups in LateResolver)

Failed merges:

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

3 years agoRollup merge of #80250 - bugadani:resolver-cleanup, r=petrochenkov
Dylan DPC [Mon, 21 Dec 2020 01:47:52 +0000 (02:47 +0100)]
Rollup merge of #80250 - bugadani:resolver-cleanup, r=petrochenkov

Minor cleanups in LateResolver

 - Avoid calculating hash twice
 - Avoid creating a closure in every iteration of a loop
 - Reserve space for path in advance
 - Some readability changes

3 years agoRollup merge of #80244 - jyn514:spans, r=bugadani
Dylan DPC [Mon, 21 Dec 2020 01:47:50 +0000 (02:47 +0100)]
Rollup merge of #80244 - jyn514:spans, r=bugadani

Cleanup markdown span handling

1. Get rid of `locate()` in markdown handling

This function was unfortunate for several reasons:

- It used `unsafe` because it wanted to tell whether a string came from
  the same *allocation* as another, not just whether it was a textual match.
- It recalculated spans even though they were already available from pulldown
- It sometimes *failed* to calculate the span, which meant it was always possible for the span to be `None`, even though in practice that should never happen.

This has several cleanups:

- Make the span required
- Pass through the span from pulldown in the `HeadingLinks` and `Footnotes` iterators
- Only add iterator bounds on the `impl Iterator`, not on `new` and the struct itself.

2. Remove unnecessary scope in `markdown_links`

I recommend reading a single commit at a time.

cc ``@bugadani`` - this will conflict with https://github.com/rust-lang/rust/pull/77859, I'll try to make sure that gets merged first.

3 years agoRollup merge of #80240 - yshui:master, r=Mark-Simulacrum
Dylan DPC [Mon, 21 Dec 2020 01:47:49 +0000 (02:47 +0100)]
Rollup merge of #80240 - yshui:master, r=Mark-Simulacrum

make sure installer only creates directories in DESTDIR

Fixes #80238

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
3 years agoRollup merge of #80239 - flip1995:clippyup, r=Manishearth
Dylan DPC [Mon, 21 Dec 2020 01:47:47 +0000 (02:47 +0100)]
Rollup merge of #80239 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update.

r? ``@Manishearth``

3 years agoRollup merge of #80236 - tmiasko:atomic-swap, r=oli-obk
Dylan DPC [Mon, 21 Dec 2020 01:47:45 +0000 (02:47 +0100)]
Rollup merge of #80236 - tmiasko:atomic-swap, r=oli-obk

Use pointer type in AtomicPtr::swap implementation

Closes #80234.

3 years agoRollup merge of #80211 - wabain:async-fn-trait-bound-suggestion, r=petrochenkov
Dylan DPC [Mon, 21 Dec 2020 01:47:44 +0000 (02:47 +0100)]
Rollup merge of #80211 - wabain:async-fn-trait-bound-suggestion, r=petrochenkov

Handle desugaring in impl trait bound suggestion

Fixes #79843.

When an associated type of a generic function parameter needs extra bounds, the diagnostics may suggest replacing an `impl Trait` with a named type parameter so that it can be referenced in the where clause. On stable and nightly, the suggestion can be malformed, for instance transforming:

```rust
async fn run(_: &(), foo: impl Foo) -> std::io::Result<()>
```

Into:

```rust
async fn run(_: &, F: Foo(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send
                 ^^^^^^^^         ^                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Where we want something like:

```rust
async fn run<F: Foo>(_: &(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send
            ^^^^^^^^              ^                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

The problem is that the elided lifetime of `&()` is added as a generic parameter when desugaring the async fn; the suggestion code sees this as an existing generic parameter and tries to use its span as an anchor to inject `F` into the parameter list. There doesn't seem to be an entirely principled way to check which generic parameters in the HIR were explicitly named in the source, so this commit changes the heuristics when generating the suggestion to only consider type parameters whose spans are contained within the span of the `Generics` when determining how to insert an additional type parameter into the declaration. (And to be safe it also excludes parameters whose spans are marked as originating from desugaring, although that doesn't seem to handle this elided lifetime.)

3 years agoRollup merge of #80199 - RalfJung:const-fake, r=oli-obk
Dylan DPC [Mon, 21 Dec 2020 01:47:42 +0000 (02:47 +0100)]
Rollup merge of #80199 - RalfJung:const-fake, r=oli-obk

also const-check FakeRead

We need to const-check all statements, including `FakeRead`, to avoid issues like https://github.com/rust-lang/rust/issues/77694.

Fixes https://github.com/rust-lang/rust/issues/77694.
r? ``@oli-obk``

3 years agoRollup merge of #80171 - pierwill:pierwill-rustcmiddle-tykind, r=lcnr
Dylan DPC [Mon, 21 Dec 2020 01:47:41 +0000 (02:47 +0100)]
Rollup merge of #80171 - pierwill:pierwill-rustcmiddle-tykind, r=lcnr

Edit rustc_middle::ty::TyKind docs

- Add a definition for this enum.
- Fix typo and missing punctuation.
- Spell out "algebraic data type".

3 years agoRollup merge of #80170 - ldm0:fixice, r=lcnr
Dylan DPC [Mon, 21 Dec 2020 01:47:39 +0000 (02:47 +0100)]
Rollup merge of #80170 - ldm0:fixice, r=lcnr

Fix ICE when lookup method in trait for type that have bound vars

Closes #77910

3 years agoRollup merge of #80166 - pierwill:pierwill-rustcmiddle-place, r=petrochenkov
Dylan DPC [Mon, 21 Dec 2020 01:47:37 +0000 (02:47 +0100)]
Rollup merge of #80166 - pierwill:pierwill-rustcmiddle-place, r=petrochenkov

Edit rustc_middle docs

Re-word doc comment for rustc_middle::hir::place::Projection.

Also adds:

- Missing end stop punctuation, and
- Documentation links to `rustc_middle::mir::Place`.

3 years agoRollup merge of #80159 - jyn514:array, r=m-ou-se
Dylan DPC [Mon, 21 Dec 2020 01:47:33 +0000 (02:47 +0100)]
Rollup merge of #80159 - jyn514:array, r=m-ou-se

Add array search aliases

Missed this in https://github.com/rust-lang/rust/pull/80068. This one will really fix https://github.com/rust-lang/rust/issues/46075.

The last alias especially I'm a little unsure about - maybe fuzzy search should be fixed in rustdoc instead? Happy to make that change although I'd have to figure out how.

r? ``@m-ou-se`` although cc ``@GuillaumeGomez`` for the search issue.

3 years agoAuto merge of #80088 - operutka:fix-cmsg-len-uclibc, r=dtolnay
bors [Mon, 21 Dec 2020 01:16:20 +0000 (01:16 +0000)]
Auto merge of #80088 - operutka:fix-cmsg-len-uclibc, r=dtolnay

Fix failing build of std on armv5te-unknown-linux-uclibceabi due to missing cmsg_len_zero

I'm getting the following error when trying to build `std` on `armv5te-unknown-linux-uclibceabi`:

```
error[E0425]: cannot find value `cmsg_len_zero` in this scope
   --> /home/operutka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/ext/net/ancillary.rs:376:47
    |
376 |             let data_len = (*cmsg).cmsg_len - cmsg_len_zero;
    |                                               ^^^^^^^^^^^^^ not found in this scope
```

Obviously, this branch:
```rust
cfg_if::cfg_if! {
    if #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] {
        let cmsg_len_zero = libc::CMSG_LEN(0) as libc::size_t;
    } else if #[cfg(any(
                  target_os = "dragonfly",
                  target_os = "emscripten",
                  target_os = "freebsd",
                  all(target_os = "linux", target_env = "musl",),
                  target_os = "netbsd",
                  target_os = "openbsd",
              ))] {
        let cmsg_len_zero = libc::CMSG_LEN(0) as libc::socklen_t;
    }
}
```

does not cover the case `all(target_os = "linux", target_env = "uclibc")`.

3 years agoUpdate stdarch submodule
Tomasz Miąsko [Mon, 21 Dec 2020 00:00:00 +0000 (00:00 +0000)]
Update stdarch submodule

3 years agoMove std_path construction into condition
Dániel Buga [Sun, 20 Dec 2020 22:55:03 +0000 (23:55 +0100)]
Move std_path construction into condition

3 years agoInline a single-use closure
Dániel Buga [Sun, 20 Dec 2020 22:17:56 +0000 (23:17 +0100)]
Inline a single-use closure

3 years agoRemove `I-prioritize` from Zulip topic
Camelid [Sun, 20 Dec 2020 22:08:55 +0000 (14:08 -0800)]
Remove `I-prioritize` from Zulip topic

It doesn't add anything since every topic in
`t-compiler/wg-prioritization/alerts` is about prioritization.
And it makes it harder to see the issue title, which is what the topic
is actually about.

3 years agoCreate closure outside of the loop
Dániel Buga [Sun, 20 Dec 2020 21:49:53 +0000 (22:49 +0100)]
Create closure outside of the loop

3 years agoFix incorrect logic when merging matches
Joshua Nelson [Sun, 20 Dec 2020 20:57:43 +0000 (15:57 -0500)]
Fix incorrect logic when merging matches

3 years agoAdd missing semicolon
Dániel Buga [Sun, 20 Dec 2020 20:41:35 +0000 (21:41 +0100)]
Add missing semicolon

3 years agoRemove unnecessary cloned
Dániel Buga [Sun, 20 Dec 2020 20:41:15 +0000 (21:41 +0100)]
Remove unnecessary cloned

3 years agoPrecompute vector length in smart_resolve_path_fragment
Dániel Buga [Sun, 20 Dec 2020 20:38:41 +0000 (21:38 +0100)]
Precompute vector length in smart_resolve_path_fragment

3 years agoClean up with_generic_param_rib, avoid double hashing
Dániel Buga [Sun, 20 Dec 2020 20:08:55 +0000 (21:08 +0100)]
Clean up with_generic_param_rib, avoid double hashing

3 years agoRemove unnecessary scope
Joshua Nelson [Sun, 20 Dec 2020 19:33:58 +0000 (14:33 -0500)]
Remove unnecessary scope

3 years agoGet rid of `locate()` in markdown handling
Joshua Nelson [Sun, 20 Dec 2020 19:28:20 +0000 (14:28 -0500)]
Get rid of `locate()` in markdown handling

This function was unfortunate for several reasons:

- It used `unsafe` because it wanted to tell whether a string came from
  the same *allocation* as another, not just whether it was a textual
  match.
- It recalculated spans even though they were already available from
  pulldown
- It sometimes *failed* to calculate the span, which meant it was always
  possible for the span to be `None`, even though in practice that
  should never happen.

This commit has several cleanups:

- Make the span required
- Pass through the span from pulldown in the `HeadingLinks` and
  `Footnotes` iterators
- Only add iterator bounds on the `impl Iterator`, not on `new` and the
  struct itself.

3 years agoAuto merge of #78317 - est31:linear_in_impl_count, r=matthewjasper
bors [Sun, 20 Dec 2020 19:54:15 +0000 (19:54 +0000)]
Auto merge of #78317 - est31:linear_in_impl_count, r=matthewjasper

Turn quadratic time on number of impl blocks into linear time

Previously, if you had a lot of inherent impl blocks on a type like:

```Rust
struct Foo;

impl Foo { fn foo_1() {} }
// ...
impl Foo { fn foo_100_000() {} }
```

The compiler would be very slow at processing it, because
an internal algorithm would run in O(n^2), where n is the number
of impl blocks. Now, we add a new algorithm that allocates but
is faster asymptotically.

Comparing rustc nightly with a local build of rustc as of this PR (results in seconds):

| N | real time before | real time after |
| - | - | - |
| 4_000 | 0.57 | 0.46 |
| 8_000  | 1.31  | 0.84 |
| 16_000  | 3.56 | 1.69 |
| 32_000 | 10.60 | 3.73 |

I've tuned up the numbers to make the effect larger than the startup noise of rustc, but the asymptotic difference should hold for smaller n as well.

Note: current state of the PR omits error messages if there are other errors present already. For now, I'm mainly interested in a perf run to study whether this issue is present at all. Please queue one for this PR. Thanks!

3 years agoEdit rustc_middle docs
pierwill [Fri, 18 Dec 2020 19:15:27 +0000 (11:15 -0800)]
Edit rustc_middle docs

Re-word doc comment for rustc_middle::hir::place::Projection.

Also adds:

- Missing end stop punctuation, and
- Documentation links to `rustc_middle::mir::Place`.

3 years agoFix typo
pierwill [Sun, 20 Dec 2020 17:53:26 +0000 (09:53 -0800)]
Fix typo

Fix typo in rustc_middle::ty::inhabitedness::DefIdForest docs.

3 years agomake sure installer only creates directories in DESTDIR
Yuxuan Shui [Sun, 20 Dec 2020 17:16:02 +0000 (17:16 +0000)]
make sure installer only creates directories in DESTDIR

Fixes #80238

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
3 years agoEdit rustc_middle::ty::TyKind docs
pierwill [Fri, 18 Dec 2020 22:17:23 +0000 (14:17 -0800)]
Edit rustc_middle::ty::TyKind docs

- Add a definition for this enum.
- Fix typo and missing punctuation.
- Spell out "algebraic data type".

3 years agoAuto merge of #74699 - notriddle:fd-non-negative, r=m-ou-se
bors [Sun, 20 Dec 2020 16:36:23 +0000 (16:36 +0000)]
Auto merge of #74699 - notriddle:fd-non-negative, r=m-ou-se

Mark `-1` as an available niche for file descriptors

Based on discussion from <https://internals.rust-lang.org/t/can-the-standard-library-shrink-option-file/12768>, the file descriptor `-1` is chosen based on the POSIX API designs that use it as a sentinel to report errors. A bigger niche could've been chosen, particularly on Linux, but would not necessarily be portable.

This PR also adds a test case to ensure that the -1 niche (which is kind of hacky and has no obvious test case) works correctly. It requires the "upper" bound, which is actually -1, to be expressed in two's complement.

3 years agoMove test from compile-fail to ui/binop
Donough Liu [Sun, 20 Dec 2020 15:39:25 +0000 (23:39 +0800)]
Move test from compile-fail to ui/binop

3 years agoMerge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup
flip1995 [Sun, 20 Dec 2020 16:19:49 +0000 (17:19 +0100)]
Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup

3 years agoAuto merge of #6482 - flip1995:rustup, r=flip1995
bors [Sun, 20 Dec 2020 16:00:11 +0000 (16:00 +0000)]
Auto merge of #6482 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump nightly to 2020-12-20
flip1995 [Sun, 20 Dec 2020 15:48:26 +0000 (16:48 +0100)]
Bump nightly to 2020-12-20

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Sun, 20 Dec 2020 15:25:54 +0000 (16:25 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agomake sure [CONST; N] drops N times
Ralf Jung [Sat, 28 Nov 2020 16:32:48 +0000 (17:32 +0100)]
make sure [CONST; N] drops N times

3 years agoadd test that repeating non-Copy constants works
Ralf Jung [Sat, 21 Nov 2020 17:05:29 +0000 (18:05 +0100)]
add test that repeating non-Copy constants works

3 years agouse exhaustive match for checking Rvalue::Repeat
Ralf Jung [Sat, 21 Nov 2020 16:42:03 +0000 (17:42 +0100)]
use exhaustive match for checking Rvalue::Repeat

3 years agoAuto merge of #80213 - jryans:bootstrap-skip-dsymutil, r=nagisa
bors [Sun, 20 Dec 2020 13:47:23 +0000 (13:47 +0000)]
Auto merge of #80213 - jryans:bootstrap-skip-dsymutil, r=nagisa

Skip `dsymutil` by default for compiler bootstrap

`dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes it more difficult for debuggers to find debug info (which `@pnkfelix` highlighted on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/does.20lldb.20%28or.20gdb%29.20work.20on.20rustc.20on.20Mac.3F/near/220482092)). The compiler currently defaults to running `dsymutil` to preserve its historical default, but when compiling the compiler itself, we skip it by default since we know it's safe to do so in that case.

r? `@nagisa`

3 years agoUpdate compiler/rustc_typeck/src/check/op.rs
Donough Liu [Sun, 20 Dec 2020 13:45:23 +0000 (21:45 +0800)]
Update compiler/rustc_typeck/src/check/op.rs

Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
3 years agoFix pretty printing an AST representing `&(mut ident)`
Thomas Bahn [Sat, 19 Dec 2020 22:13:50 +0000 (23:13 +0100)]
Fix pretty printing an AST representing `&(mut ident)`

`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), ..)`
is an AST representing `&(mut ident)`. It was errorneously printed as
`&mut ident` which reparsed into a syntactically different AST.

This affected help diagnostics in the parser.

3 years agoCheck that c_int is i32 in FileDesc::new.
Mara Bos [Sun, 20 Dec 2020 11:56:51 +0000 (11:56 +0000)]
Check that c_int is i32 in FileDesc::new.

3 years agoFix ICE on suggesting calling function
Donough Liu [Sun, 20 Dec 2020 08:18:34 +0000 (16:18 +0800)]
Fix ICE on suggesting calling function

3 years agoAuto merge of #80123 - DrMeepster:maybe_uninit_write_slice, r=RalfJung
bors [Sun, 20 Dec 2020 10:08:56 +0000 (10:08 +0000)]
Auto merge of #80123 - DrMeepster:maybe_uninit_write_slice, r=RalfJung

Fix memory leak in test "mem::uninit_write_slice_cloned_no_drop"

This fixes #80116. I replaced the `Rc` based method I was using with a type that panics when dropped.

3 years agoAdd module-level docs to rustc_middle::ty
pierwill [Sun, 20 Dec 2020 08:08:27 +0000 (00:08 -0800)]
Add module-level docs to rustc_middle::ty

3 years agodocs: Fix outdated crate reference
pierwill [Sun, 20 Dec 2020 07:32:51 +0000 (23:32 -0800)]
docs: Fix outdated crate reference

3 years agoFix rustc-std-workspace-core documentation
Daniel Le [Sun, 20 Dec 2020 07:21:17 +0000 (15:21 +0800)]
Fix rustc-std-workspace-core documentation

3 years agoAuto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnr
bors [Sun, 20 Dec 2020 07:01:00 +0000 (07:01 +0000)]
Auto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnr

Make BoundRegion have a kind of BoungRegionKind

Split from #76814

Also includes making `replace_escaping_bound_vars` only return `T`

Going to r? `@lcnr`
Feel free to reassign

3 years agoFix labels for 'Library Tracking Issue' template
Camelid [Sun, 20 Dec 2020 04:47:57 +0000 (20:47 -0800)]
Fix labels for 'Library Tracking Issue' template

Each label needs to be separated by a comma (see the ICE issue template
for an example of correct usage).