Commit graph

2717 commits

Author SHA1 Message Date
Bastian Kauschke 06cc9c26da stabilize min_const_generics 2020-12-26 18:24:10 +01:00
bors 931aa27922 Auto merge of #80246 - matthewjasper:projection-cycle-caching, r=Mark-Simulacrum
Prevent caching normalization results with a cycle

When normalizing a projection which results in a cycle, we would cache the result of `project_type` without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error. `get_paranoid_cache_value_obligation` used to add an obligation that resulted in a cycle in this case previously, but was removed by #73905.

This PR makes the projection cache not cache the value of a projection if it was ever normalized in a cycle (except in a snapshot that's rolled back).

Fixes #79714.

r? `@nikomatsakis`
2020-12-26 00:11:30 +00:00
bors bb178237c5 Auto merge of #80235 - RalfJung:validate-promoteds, r=oli-obk
validate promoteds

Turn on const-value validation for promoteds. This is made possible now that https://github.com/rust-lang/rust/issues/67534 is resolved.

I don't think this is a breaking change. We don't promote any unsafe operation any more (since https://github.com/rust-lang/rust/pull/77526 landed). We *do* promote `const fn` calls under some circumstances (in `const`/`static` initializers), but union field access and similar operations are not allowed in `const fn`. So now is a perfect time to add this check. :D

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/67465
2020-12-25 18:25:48 +00:00
bors 1832bdd7de Auto merge of #80296 - wesleywiser:revert_missing_fragment_specifier_hard_error, r=Mark-Simulacrum
Revert missing fragment specifier hard error

Closes #76605

Reopens #40107

r? `@Mark-Simulacrum`
2020-12-25 14:09:08 +00:00
bors 198ec340f6 Auto merge of #80187 - 0dvictor:nativelib, r=bjorn3
Exclude unnecessary info from CodegenResults

`foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults.

Fixes #77857
2020-12-25 08:17:21 +00:00
bors 9a40539c38 Auto merge of #80364 - Dylan-DPC:rollup-0y96okz, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #79213 (Stabilize `core::slice::fill`)
 - #79999 (Refactored verbose print into a function)
 - #80160 (Implemented a compiler diagnostic for move async mistake)
 - #80274 (Rename rustc_middle::lint::LintSource)
 - #80280 (Add installation commands to `x` tool README)
 - #80319 (Fix elided lifetimes shown as `'_` on async functions)
 - #80327 (Updated the match with the matches macro)
 - #80330 (Fix typo in simplify_try.rs)
 - #80340 (Don't unnecessarily override attrs for Module)
 - #80342 (Fix typo)
 - #80352 (BTreeMap: make test cases more explicit on failure)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-25 05:23:24 +00:00
Dylan DPC 3cf289bd5f
Rollup merge of #80342 - pierwill:patch-1, r=lcnr
Fix typo
2020-12-25 03:39:49 +01:00
Dylan DPC 704f81e3cb
Rollup merge of #80330 - eltociear:patch-2, r=lcnr
Fix typo in simplify_try.rs

assigment -> assignment
2020-12-25 03:39:46 +01:00
Dylan DPC 2dab627d77
Rollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez
Updated the match with the matches macro

r?````@GuillaumeGomez````
2020-12-25 03:39:43 +01:00
Dylan DPC b295b8e67b
Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkov
Rename rustc_middle::lint::LintSource

Rename [`rustc_middle::lint::LintSource`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/enum.LintSource.html) to `rustc_middle::lint::LintLevelSource`.

This enum represents the source of a *lint level*, not a lint. This should improve code readability.

Update: Also documents `rustc_middle::lint::LevelSource` to clarify.
2020-12-25 03:39:36 +01:00
Dylan DPC 299c2fc695
Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco
Implemented a compiler diagnostic for move async mistake

Fixes #79694

First time contributing, so I hope I'm doing everything right.
(If not, please correct me!)

This code performs a check when a move capture clause is parsed. The check is to detect if the user has reversed the async move keywords and to provide a diagnostic with a suggestion to fix it.

Checked code:
```rust
fn main() {
    move async { };
}
```

Previous output:
```txt
PS C:\Repos\move_async_test> cargo build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: expected one of `|` or `||`, found keyword `async`
 --> src\main.rs:2:10
  |
2 |     move async { };
  |          ^^^^^ expected one of `|` or `||`

error: aborting due to previous error

error: could not compile `move_async_test`
```

New output:
```txt
PS C:\Repos\move_async_test> cargo +dev build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: the order of `move` and `async` is incorrect
 --> src\main.rs:2:13
  |
2 |     let _ = move async { };
  |             ^^^^^^^^^^
  |
help: try switching the order
  |
2 |     let _ = async move { };
  |             ^^^^^^^^^^

error: aborting due to previous error

error: could not compile `move_async_test`
```

Is there a file/module where these kind of things are tested?
Would love some feedback 😄
2020-12-25 03:39:35 +01:00
Dylan DPC 787b016957
Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obk
Refactored verbose print into a function

Also handle Tuple and Array separately, which was not explicitly checked.

Fixes #79799.
2020-12-25 03:39:33 +01:00
bors cae1f4ddf2 Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinem
Remap instrument-coverage line numbers in doctests

This uses the `SourceMap::doctest_offset_line` method to re-map line
numbers from doctests. Remapping columns is not yet done, and rustdoc
still does not output the correct filename when running doctests in a
workspace.

Part of #79417 although I dont consider that fixed until both filenames
and columns are mapped correctly.

r? `@richkadel`

I might jump on zulip the comming days. Still need to figure out how to properly write tests for this, and deal with other doctest issues in the meantime.
2020-12-25 02:37:08 +00:00
bors 2acf6ee6d2 Auto merge of #80295 - GuillaumeGomez:beautify-rework, r=petrochenkov
Rework beautify_doc_string so that it returns a Symbol instead of a String

This commit comes from https://github.com/rust-lang/rust/pull/80261, the goal here is to inspect the impact on performance of this change on its own.

The idea of rewriting `beautify_doc_string` is to not go through `String` if we don't need to update the doc comment to be able to keep the original `Symbol` and also to have better performance.

r? `@jyn514`
2020-12-24 11:30:24 +00:00
bors c34c015fe2 Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwco
Added better error message for shared borrow treated as unique for purposes of lifetimes

Part of Issue #76630

r? `@jyn514`
2020-12-24 07:32:19 +00:00
bors 49b315123e Auto merge of #79589 - tgnottingham:shared_dep_graph, r=michaelwoerister
rustc_query_system: reduce dependency graph memory usage

This change implements, at a high level, two space optimizations to the dependency graph.

The first optimization is sharing graph data with the previous dependency graph. Whenever we intern a node, we know whether that node is new (not in the previous graph) or not, and if not, the color of the node in the previous graph.

Red and green nodes have their `DepNode` present in the previous graph, so for that piece of node data, we can just store the index of the node in the previous graph rather than duplicate the `DepNode`. Green nodes additionally have the the same result `Fingerprint`, so we can avoid duplicating that too. Finally, we distinguish between "light" and "dark" green nodes, where the latter are nodes that were marked green because all of their dependencies were marked green. These nodes can additionally share edges with the previous graph, because we know that their set of dependencies is the same (technically, light green and red nodes can have the same dependencies too, but we don't try to figure out whether or not that's the case).

Also, some effort is made to pack data tightly, and to avoid storing `DepNode`s as map keys more than once.

The second optimization is storing edges in a more compact representation, as in the `SerializedDepGraph`, that is, in a single vector, rather than one `EdgesVec` per node. An `EdgesVec` is a `SmallVec` with an inline buffer for 8 elements. Each `EdgesVec` is, at minimum, 40 bytes, and has a per-node overhead of up to 40 bytes. In the ideal case of exactly 8 edges, then 32 bytes are used for edges, and the overhead is 8 bytes. But most of the time, the overhead is higher.

In contrast, using a single vector to store all edges, and having each node specify its start and end elements as 4 byte indices into the vector has a constant overhead of 8 bytes--the best case scenario for the per-node `EdgesVec` approach.

The downside of this approach is that `EdgesVec`s built up during query execution have to be copied into the vector, whereas before, we could just take ownership over them. However, we mostly make up for this because the single vector representation enables a more efficient implementation of `DepGraph::serialize`.
2020-12-24 01:06:36 +00:00
pierwill df94bfceb1
Fix typo 2020-12-23 13:08:15 -08:00
Yenlin Chen ecba49c1bd Fixed formatting 2020-12-23 19:10:59 +00:00
Yenlin Chen f459b0fea5 Addressed feedbacks
Also updated the mir-opt test output files.
2020-12-23 18:55:37 +00:00
Ikko Ashimine 87397080b6
Fix typo in simplify_try.rs
assigment -> assignment
2020-12-23 21:11:59 +09:00
PankajChaudhary5 c625d3183c Updated the match with the matches macro 2020-12-23 11:02:04 +05:30
Victor Ding 732afd41cf Exclude unnecessary info from CodegenResults
`foreign_module` and `wasm_import_module` are not needed for linking,
and hence can be removed from CodegenResults.
2020-12-23 12:51:10 +11:00
bors 89886e6936 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
2020-12-23 00:41:46 +00:00
Guillaume Gomez 67f8244975
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.
2020-12-23 00:14:01 +01:00
Guillaume Gomez f711f3ff5f
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`
2020-12-23 00:13:59 +01:00
Guillaume Gomez 5af144ece1
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`
2020-12-23 00:13:56 +01:00
Guillaume Gomez 125156ca0f
Rollup merge of #80297 - jyn514:more-docs, r=bjorn3
Add some intra-doc links to compiler docs

r? `@pierwill`
2020-12-23 00:13:53 +01:00
Guillaume Gomez 174a9fad2f
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.
2020-12-23 00:13:52 +01:00
Guillaume Gomez aa7cb4ff00
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.
2020-12-23 00:13:48 +01:00
Guillaume Gomez 558926142c
Rollup merge of #80241 - pierwill:patch-12, r=lcnr
Fix typo

Fix typo in rustc_middle::ty::inhabitedness::DefIdForest docs.
2020-12-23 00:13:43 +01:00
Guillaume Gomez e116732b4b
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).
2020-12-23 00:13:41 +01:00
Guillaume Gomez f9f8446130
Rollup merge of #80223 - pierwill:patch-10, r=lcnr
docs: Fix outdated crate reference
2020-12-23 00:13:40 +01:00
Guillaume Gomez 8a35d3a08e
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.
2020-12-23 00:13:34 +01:00
Guillaume Gomez f84ec97485
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).
2020-12-23 00:13:33 +01:00
Tyson Nottingham 03eb75f759 rustc_query_system: avoid race condition when using edge_count 2020-12-22 14:12:57 -08:00
Tyson Nottingham 22ed75158b rustc_query_system: add more comments for dependency graph 2020-12-22 14:12:57 -08:00
Tyson Nottingham d6b2aaed7d rustc_query_system: rename intern_node to intern_new_node 2020-12-22 14:12:57 -08:00
Tyson Nottingham 712fcae13a rustc_query_system: remove inline annotation from edge_count
This isn't called frequently enough to justify inlining.
2020-12-22 14:12:57 -08:00
Tyson Nottingham 4f76266295 rustc_query_system: minor cleanup
Remove effectively unused parameter and delete out of date comment.
2020-12-22 14:12:57 -08:00
Tyson Nottingham dd1ab840d2 rustc_query_system: use more space-efficient edges representation
Use single vector of edges rather than per-node vector. There is a small
hit to instruction counts (< 0.5%), but the memory savings make up for it.
2020-12-22 14:12:57 -08:00
Tyson Nottingham ea47269f5f rustc_query_system: share previous graph edges with current graph
Reduce memory consumption by sharing the previous dependency graph's
edges with the current graph when it is known to be valid to do so. It
is known to be valid whenever we mark a node green because all of its
dependencies were green. It is *not* known to be valid when we mark a
node green because we re-executed its query and its result was the same
as in the previous compilation session. In that case, the dependency set
might have changed (we don't try to determine whether or not it changed
and whether or not we can share).
2020-12-22 14:12:57 -08:00
Tyson Nottingham f6d6b0c96d rustc_query_system: share previous graph data with current graph
Reduce memory consumption by taking advantage of red/green algorithm
properties to share the previous dependency graph's node data with the
current graph instead of storing node data redundantly. Red nodes can
share the `DepNode`, and green nodes can share the `DepNode` and
`Fingerprint`. Edges will be shared when possible in a later change.
2020-12-22 14:12:57 -08:00
bors 969b42d8c0 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
2020-12-22 21:51:04 +00:00
bors bb1fbbf844 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.
2020-12-22 19:02:28 +00:00
pierwill f078f7cd64 docs: Update rustc_middle::middle::region::ScopeTree
This corrects the return type in docs for yield_in_source method.

Closes #80287.
2020-12-22 10:57:05 -08:00
PankajChaudhary5 57b5f8cbb9 Improve the code quality by using matches macro 2020-12-22 20:52:38 +05:30
Nadrieril be23694622 Fix a comment 2020-12-22 15:20:24 +00:00
Nadrieril 85fdb34d3a Apply suggestions from code review
Co-authored-by: varkor <github@varkor.com>
2020-12-22 15:20:24 +00:00
Nadrieril 1c176d1150 Simplify field filtering 2020-12-22 15:20:23 +00:00
Nadrieril 53e03fb7c1 Make the special "missing patterns" constructor real 2020-12-22 15:20:23 +00:00