about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-08-18Auto merge of #114611 - nnethercote:type-system-chess, r=compiler-errorsbors-10/+27
Speed up compilation of `type-system-chess` [`type-system-chess`](https://github.com/rust-lang/rustc-perf/pull/1680) is an unusual program that implements a compile-time chess position solver in the trait system(!) This PR is about making it compile faster. r? `@ghost`
2023-08-18Auto merge of #114951 - cuviper:rollup-iitoep5, r=cuviperbors-42/+28
Rollup of 5 pull requests Successful merges: - #113715 (Unstable Book: update `lang_items` page and split it) - #114897 (Partially revert #107200) - #114913 (Fix suggestion for attempting to define a string with single quotes) - #114931 (Revert PR #114052 to fix invalid suggestion) - #114944 (update `thiserror` to version >= 1.0.46) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-17Rollup merge of #114931 - Urgau:revert-114052, r=compiler-errorsJosh Stone-25/+17
Revert PR #114052 to fix invalid suggestion This PR reverts https://github.com/rust-lang/rust/pull/114052 to fix the invalid suggestion produced by the PR. Unfortunately the invalid suggestion cannot be improved from the current position where it's emitted since we lack enough information (is an assignment?, left or right?, ...) to be able to fix it here. Furthermore the previous wasn't wrong, just suboptimal, contrary to the current one which is just wrong. Added a regression test and commented out some code instead of removing it so we can use it later. Reopens https://github.com/rust-lang/rust/issues/114050 Fixes https://github.com/rust-lang/rust/issues/114925
2023-08-17Rollup merge of #114913 - beetrees:escape-double-quote, r=davidtwcoJosh Stone-14/+8
Fix suggestion for attempting to define a string with single quotes Currently attempting to compile `fn main() { let _ = '\\"'; }` will result in the following error message: ``` error: character literal may only contain one codepoint --> src/main.rs:1:21 | 1 | fn main() { let _ = '\\"'; } | ^^^^^ | help: if you meant to write a `str` literal, use double quotes | 1 | fn main() { let _ = "\\""; } | ~~~~~ ``` The suggestion is invalid as it fails to escape the `"`. This PR fixes the suggestion so that it now reads: ``` help: if you meant to write a `str` literal, use double quotes | 1 | fn main() { let _ = "\\\""; } | ~~~~~~ ``` The relevant test is also updated to ensure that this does not regress in future.
2023-08-17Rollup merge of #113715 - kadiwa4:lang_items_doc, r=JohnTitorJosh Stone-3/+3
Unstable Book: update `lang_items` page and split it [`lang_items` rendered](https://github.com/kadiwa4/rust/blob/lang_items_doc/src/doc/unstable-book/src/language-features/lang-items.md), [`start` rendered](https://github.com/kadiwa4/rust/blob/lang_items_doc/src/doc/unstable-book/src/language-features/start.md) Closes #110274 Rustonomicon PR: rust-lang/nomicon#413, Rust Book PR: rust-lang/book#3705 A lot of information doesn't belong on the `lang_items` page. I added a separate page for the `start` feature and moved some text into the Rustonomicon because the `lang_items` page should not be a tutorial on how to build a `#![no_std]` executable. The list of existing lang items is too long/unstable, so I removed it. The doctests still don't work. :(
2023-08-17Auto merge of #114904 - cjgillot:no-ref-debuginfo, r=wesleywiserbors-74/+14
Remove references in VarDebugInfo The codegen implementation is broken, and attempted to read uninitialized memory. Fixes https://github.com/rust-lang/rust/issues/114488
2023-08-17Auto merge of #114802 - chenyukang:yukang-fix-114979-bad-parens-dyn, r=estebankbors-20/+25
Fix bad suggestion when wrong parentheses around a dyn trait Fixes #114797
2023-08-17Revert "Implement references VarDebugInfo."Camille GILLOT-74/+14
This reverts commit 2ec007191348ef7cc13eb55e44e007b02cf75cf3.
2023-08-17Revert PR #114052 to fix invalid suggestionUrgau-25/+17
2023-08-17Rollup merge of #114876 - compiler-errors:non-lifetime-binders-sized, ↵Matthias Krüger-2/+2
r=wesleywiser Don't ICE in `is_trivially_sized` when encountering late-bound self ty We can see a bound ty var here: https://github.com/rust-lang/rust/blob/b531630f4255216fce1400c45976e04f1ab35a84/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs#L13-L34 Fixes #114872
2023-08-17Auto merge of #114892 - Zoxc:sharded-cfg-cleanup, r=cjgillotbors-49/+7
Remove conditional use of `Sharded` from query caches `Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job. r? `@cjgillot`
2023-08-16Auto merge of #111555 - cjgillot:elaborate-drops, r=tmiaskobors-1228/+1368
Only run MaybeInitializedPlaces dataflow once to elaborate drops This pass allows forward dataflow analyses to modify the CFG depending on the dataflow state. This possibility is used for the `MaybeInitializedPlace` analysis in drop elaboration, to skip the dataflow effect of dead unwinds without having to compute dataflow twice.
2023-08-16Auto merge of #108693 - Zoxc:arena-opt-funcs, r=cjgillotbors-17/+70
Optimize DroplessArena arena allocation This optimizes `DroplessArena` allocation by always ensuring that it is aligned to `usize` and adding `grow_and_alloc` and `grow_and_alloc_raw`functions which both grow and allocate, reducing code size. <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.6968s</td><td align="right">1.6887s</td><td align="right"> -0.48%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2552s</td><td align="right">0.2551s</td><td align="right"> -0.03%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9613s</td><td align="right">0.9553s</td><td align="right"> -0.62%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5402s</td><td align="right">1.5374s</td><td align="right"> -0.18%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9175s</td><td align="right">5.8813s</td><td align="right"> -0.61%</td></tr><tr><td>Total</td><td align="right">10.3710s</td><td align="right">10.3178s</td><td align="right"> -0.51%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>
2023-08-16Fix suggestion for attempting to define a string with single quotesbeetrees-14/+8
2023-08-16Do not pre-compute reachable blocks.Camille GILLOT-20/+0
2023-08-16Use Terminator::edges for backward analysis too.Camille GILLOT-1/+1
2023-08-16Update doc comment.Camille GILLOT-1/+1
2023-08-16Make dataflow const-prop handle_switch_int monotonic.Camille GILLOT-8/+11
2023-08-16Only evaluate yield place after resume in liveness.Camille GILLOT-15/+31
2023-08-16Specify that method only applies statement effects.Camille GILLOT-9/+14
2023-08-16Rename YieldResumeEffect.Camille GILLOT-6/+6
2023-08-16Make TerminatorEdge plural.Camille GILLOT-59/+59
2023-08-16Rename MaybeUnreachable.Camille GILLOT-49/+55
2023-08-16Use TerminatorEdge for dataflow-const-prop.Camille GILLOT-63/+49
2023-08-16Only run MaybeInitializedPlaces once for drop elaboration.Camille GILLOT-62/+91
2023-08-16Allow apply_terminator_effect to customize edges.Camille GILLOT-306/+300
2023-08-16Introduce MaybeUnreachable.Camille GILLOT-3/+136
2023-08-16Move domain_size to GenKillAnalysis.Camille GILLOT-14/+43
2023-08-16Move initialization dataflow impls into their own module.Camille GILLOT-749/+756
2023-08-16Create bottom on-the-fly instead of cloning it.Camille GILLOT-3/+4
2023-08-16Simplify for_each_mut_borrow.Camille GILLOT-58/+9
2023-08-16Rollup merge of #114899 - spastorino:add-missing-debug, r=compiler-errorsMatthias Krüger-0/+3
Add missing Clone/Debug impls to SMIR Trait related tys r? `@compiler-errors`
2023-08-16Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, ↵Matthias Krüger-18/+33
r=est31 Improve `invalid_reference_casting` lint This PR improves the `invalid_reference_casting` lint: - by considering an unlimited number of casts instead only const to mut ptr - by also considering ptr-to-integer and integer-to-ptr casts - by also taking into account [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast), [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast-1) and [`ptr::cast_const`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast_const) Most of this improvements comes from skimming Github Code Search result for [`&mut \*.*as \*const`](https://github.com/search?q=lang%3Arust+%2F%26mut+%5C*.*as+%5C*const%2F&type=code) r? ``@est31`` (maybe)
2023-08-16Add missing Clone/Debug impls to SMIR Trait related tysSantiago Pastorino-0/+3
2023-08-16Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkovbors-21/+53
Fix argument removal suggestion around macros Fixes #112437. Fixes #113866. Helps with #114255. The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`. This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead. Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts. This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues. ```rust let adjusted_start = start.find_ancestor_inside(shared_ancestor); let adjusted_end = end.find_ancestor_inside(shared_ancestor); let full_span = adjusted_start.to(adjusted_end) ``` To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion. Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit. [^1]: If one expansion context is the root context and the other is not.
2023-08-16Remove conditional use of `Sharded` from query cachesJohn Kåre Alsaker-49/+7
2023-08-16Rollup merge of #114859 - spastorino:add-smir-cx-trait-fns, r=compiler-errorsMatthias Krüger-0/+16
Add trait related queries to SMIR's rustc_internal r? `@oli-obk`
2023-08-16Rollup merge of #114779 - MU001999:fix/114701, r=petrochenkovMatthias Krüger-0/+1
Add check before suggest removing parens Fixes #114701
2023-08-16Rollup merge of #114746 - compiler-errors:atb-no-const, r=TaKO8KiMatthias Krüger-10/+31
Don't add associated type bound for non-types We had this fix for equality constraints (#99890), but for some reason not trait constraints :sweat_smile: Fixes #114744
2023-08-16Auto merge of #114536 - cjgillot:eval-lint-levels, r=TaKO8Kibors-1/+0
Do not mark shallow_lint_levels_on as eval_always. It does not need it. Removing it allows to skip recomputation.
2023-08-16Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomccbors-2/+0
Stabilize thread local cell methods. Closes #92122.
2023-08-16Don't ICE in is_trivially_sized when encountering late-bound self tyMichael Goulet-2/+2
2023-08-15Rollup merge of #114819 - estebank:issue-78124, r=compiler-errorsMatthias Krüger-38/+100
Point at return type when it influences non-first `match` arm When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-15Rollup merge of #114668 - compiler-errors:match-fn-def, r=petrochenkovMatthias Krüger-1/+6
Deny `FnDef` in patterns We can only see these via `const { .. }` patterns, which are unstable. cc #76001 (tracking issue for inline const pats) Fixes #114658 Fixes #114659
2023-08-15Rollup merge of #114644 - compiler-errors:lt-err, r=wesleywiserMatthias Krüger-21/+15
Point out expectation even if we have `TypeError::RegionsInsufficientlyPolymorphic` just a minor tweak, since saying "one type is more general than the other" kinda sucks if we don't actually point out two types.
2023-08-15Add trait related queries to SMIR's rustc_internalSantiago Pastorino-0/+16
2023-08-16Fix bad suggestion when wrong parentheses around a dyn traityukang-20/+25
2023-08-15Auto merge of #114852 - GuillaumeGomez:rollup-vjagxjr, r=GuillaumeGomezbors-180/+442
Rollup of 10 pull requests Successful merges: - #114711 (Infer `Lld::No` linker hint when the linker stem is a generic compiler driver) - #114772 (Add `{Local}ModDefId` to more strongly type DefIds`) - #114800 (std: add some missing repr(transparent)) - #114820 (Add test for unknown_lints from another file.) - #114825 (Upgrade std to gimli 0.28.0) - #114827 (Only consider object candidates for object-safe dyn types in new solver) - #114828 (Probe when assembling upcast candidates so they don't step on eachother's toes in new solver) - #114829 (Separate `consider_unsize_to_dyn_candidate` from other unsize candidates) - #114830 (Clean up some bad UI testing annotations) - #114831 (Check projection args before substitution in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-15Rollup merge of #114831 - ↵Guillaume Gomez-7/+15
compiler-errors:next-solver-projection-subst-compat, r=lcnr Check projection args before substitution in new solver Don't ICE when an impl has the wrong kind of GAT arguments r? lcnr
2023-08-15Rollup merge of #114829 - ↵Guillaume Gomez-54/+92
compiler-errors:next-solver-only-unsize-to-dyn-once, r=lcnr Separate `consider_unsize_to_dyn_candidate` from other unsize candidates Move the unsize candidate assembly *just for* `T -> dyn Trait` out of `assemble_candidates_via_self_ty` so that we only consider it once, instead of for every normalization step of the self ty. This makes sure that we don't assemble several candidates that are equal modulo normalization when we really don't care about normalizing the self type of an `T: Unsize<dyn Trait>` goal anyways. Fixes rust-lang/trait-system-refactor-initiative#57 r? lcnr