summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-02-08lexer: Avoid some span arithmetic in `emit_unescape_error`Vadim Petrochenkov-7/+7
2021-02-05Rename `panic_fmt` lint to `non_fmt_panic`.Mara Bos-5/+6
2021-02-05Auto merge of #81257 - ↵bors-295/+158
pnkfelix:issue-80949-short-term-resolution-via-revert-of-pr-78373, r=matthewjasper Revert 78373 ("dont leak return value after panic in drop") Short term resolution for issue #80949. Reopen #47949 after this lands. (We plan to fine-tune PR #78373 to not run into this problem.)
2021-02-04Rollup merge of #81556 - nikomatsakis:forbidden-lint-groups-lint, r=pnkfelixMara Bos-31/+136
introduce future-compatibility warning for forbidden lint groups We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218). This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect. r? ``@Mark-Simulacrum``
2021-02-04Rollup merge of #81532 - estebank:ice-ice-baby, r=pnkfelixMara Bos-1/+0
Remove incorrect `delay_span_bug` The following code is supposed to compile ```rust use std::ops::BitOr; pub trait IntWrapper { type InternalStorage; } impl<T> BitOr for dyn IntWrapper<InternalStorage = T> where Self: Sized, T: BitOr + BitOr<Output = T>, { type Output = Self; fn bitor(self, _other: Self) -> Self { todo!() } } ``` Before this change it would ICE. In #70998 the removed logic was added to provide better suggestions, and the `delay_span_bug` guard was added to protect against a potential logic error when returning traits. As it happens, there are cases, like the one above, where traits can indeed be returned, so valid code was being rejected. Fix (but not close) #80207.
2021-02-04Auto merge of #81055 - matthewjasper:non-fatal-overflow, r=nikomatsakisbors-12/+3
Make hitting the recursion limit in projection non-fatal This change was originally made in #80246 to avoid future (effectively) infinite loop bugs in projections, but wundergraph relies on rustc recovering here. cc #80953 r? `@nikomatsakis`
2020-12-31Prevent caching projections in the case of cyclesMatthew Jasper-7/+27
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. Fixes #79714, a regresion from #79305 caused by the removal of `get_paranoid_cache_value_obligation`.
2020-12-31Make recursion limit fatal in projectMatthew Jasper-1/+8
This avoid the hang/oom from #79714
2020-12-25Auto merge of #80235 - RalfJung:validate-promoteds, r=oli-obkbors-27/+25
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-25Auto merge of #80296 - ↵bors-16/+98
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-25Auto merge of #80187 - 0dvictor:nativelib, r=bjorn3bors-7/+24
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-25Auto merge of #80364 - Dylan-DPC:rollup-0y96okz, r=Dylan-DPCbors-49/+83
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-25Rollup merge of #80342 - pierwill:patch-1, r=lcnrDylan DPC-1/+1
Fix typo
2020-12-25Rollup merge of #80330 - eltociear:patch-2, r=lcnrDylan DPC-1/+1
Fix typo in simplify_try.rs assigment -> assignment
2020-12-25Rollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomezDylan DPC-4/+1
Updated the match with the matches macro r?````@GuillaumeGomez````
2020-12-25Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkovDylan DPC-28/+31
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-25Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwcoDylan DPC-4/+32
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-25Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obkDylan DPC-11/+17
Refactored verbose print into a function Also handle Tuple and Array separately, which was not explicitly checked. Fixes #79799.
2020-12-25Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinembors-2/+6
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-24Auto merge of #80295 - GuillaumeGomez:beautify-rework, r=petrochenkovbors-36/+38
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-24Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwcobors-3/+4
Added better error message for shared borrow treated as unique for purposes of lifetimes Part of Issue #76630 r? `@jyn514`
2020-12-24Auto merge of #79589 - tgnottingham:shared_dep_graph, r=michaelwoeristerbors-246/+686
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-23Fix typopierwill-1/+1
2020-12-23Fixed formattingYenlin Chen-3/+1
2020-12-23Addressed feedbacksYenlin Chen-17/+3
Also updated the mir-opt test output files.
2020-12-23Fix typo in simplify_try.rsIkko Ashimine-1/+1
assigment -> assignment
2020-12-23Updated the match with the matches macroPankajChaudhary5-4/+1
2020-12-23Exclude unnecessary info from CodegenResultsVictor Ding-7/+24
`foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults.
2020-12-23Auto merge of #80314 - GuillaumeGomez:rollup-9rc48vx, r=GuillaumeGomezbors-56/+94
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-23Rollup merge of #80302 - pierwill:fix-80287, r=lcnrGuillaume Gomez-4/+2
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-23Rollup merge of #80299 - LingMan:helper, r=lcnrGuillaume Gomez-18/+22
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-23Rollup merge of #80298 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomezGuillaume Gomez-8/+2
Improve the code quality by using matches macro Improved the code quality by using matches macro r? `@GuillaumeGomez`
2020-12-23Rollup merge of #80297 - jyn514:more-docs, r=bjorn3Guillaume Gomez-5/+13
Add some intra-doc links to compiler docs r? `@pierwill`
2020-12-23Rollup merge of #80286 - pierwill:rustc-middle-privacy, r=petrochenkovGuillaume Gomez-4/+6
docs: Edit rustc_middle::middle::privacy Add descriptions of `AccessLevel` and `AccessLevels`. Add missing punctuation.
2020-12-23Rollup merge of #80272 - petrochenkov:kwed, r=oli-obkGuillaume Gomez-11/+32
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-23Rollup merge of #80241 - pierwill:patch-12, r=lcnrGuillaume Gomez-1/+1
Fix typo Fix typo in rustc_middle::ty::inhabitedness::DefIdForest docs.
2020-12-23Rollup merge of #80225 - pierwill:patch-11, r=lcnrGuillaume Gomez-0/+11
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-23Rollup merge of #80223 - pierwill:patch-10, r=lcnrGuillaume Gomez-1/+1
docs: Fix outdated crate reference
2020-12-23Rollup merge of #80204 - pierwill:pierwill-rustcmiddle-ondisk, r=varkorGuillaume Gomez-2/+2
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-23Rollup merge of #80203 - pierwill:pierwill-rustcmiddle-lint, r=oli-obkGuillaume Gomez-2/+2
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-22rustc_query_system: avoid race condition when using edge_countTyson Nottingham-11/+6
2020-12-22rustc_query_system: add more comments for dependency graphTyson Nottingham-1/+33
2020-12-22rustc_query_system: rename intern_node to intern_new_nodeTyson Nottingham-3/+3
2020-12-22rustc_query_system: remove inline annotation from edge_countTyson Nottingham-1/+0
This isn't called frequently enough to justify inlining.
2020-12-22rustc_query_system: minor cleanupTyson Nottingham-17/+3
Remove effectively unused parameter and delete out of date comment.
2020-12-22rustc_query_system: use more space-efficient edges representationTyson Nottingham-52/+103
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-22rustc_query_system: share previous graph edges with current graphTyson Nottingham-65/+159
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-22rustc_query_system: share previous graph data with current graphTyson Nottingham-216/+499
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-22Auto merge of #80242 - Nadrieril:explain-and-factor-splitting, r=varkorbors-759/+824
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-22Auto merge of #80177 - tgnottingham:foreign_defpathhash_registration, ↵bors-63/+54
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.