about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-11-25Rollup merge of #118253 - dtolnay:issomeand, r=compiler-errorsLeón Orell Valerian Liehr-19/+16
Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)` Requested by `@fmease` in https://github.com/rust-lang/rust/pull/118226#pullrequestreview-1747432292. There is also a much larger number of `option.map_or(false, cond)` that can be changed separately if someone wants. r? fmease
2023-11-25Auto merge of #118075 - tmiasko:validate-critical-call-edges, r=cjgillotbors-2/+25
Validate there are no critical call edges in optimized MIR
2023-11-25Auto merge of #118203 - nnethercote:rustc_mir_dataflow, r=cjgillotbors-227/+132
Minor `rustc_mir_dataflow` cleanups r? `@cjgillot`
2023-11-25Auto merge of #118261 - spastorino:fix-placeholder-replacer, r=compiler-errorsbors-4/+18
Make PlaceholderReplacer shallow_resolver and recur when infer vars This makes resolve type and const infer vars resolve. Given: ```rust #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct Foo<T>(T); impl<'a> Foo<fn(&'a ())> { type Assoc = &'a (); } fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)) {} fn main() {} ``` We should normalize `for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)` to `for<'0> fn(&'1 ())` with `'1 == '0` and `'0 == 'static` constraints. We have to resolve `'1` to `'static` in the infcx associated to `PlaceholderReplacer`. This is part of https://github.com/rust-lang/rust/pull/118118 but unrelated to that PR. r? `@compiler-errors` `@lcnr`
2023-11-24Fix smir's `Ty::Ref` pretty printingCelina G. Val-2/+4
2023-11-25Auto merge of #118227 - Mark-Simulacrum:worker-local-outline, r=cjgillotbors-9/+12
Optimize QueryArena allocation This shifts the WorkerLocal wrapper to be outside the QueryArena, meaning that instead of having each query allocate distinct arenas per-worker we allocate the full set of arenas per-worker. This is primarily a code size optimization (locally, ~85 kilobytes, [perf is reporting >100 kilobytes](https://perf.rust-lang.org/compare.html?start=1fd418f92ed13db88a21865ba5d909abcf16b6cc&end=884c95a3f1fe8d28630ec3cdb0c8f95b2e539fde&stat=instructions%3Au&tab=artifact-size)), saving a bunch of code in the initialization of the arenas which was previously duplicated lots of times (per arena type). Additionally this tells LLVM that the thread count can't be zero in this code (I believe this is true?) which shaves some small amount of bytes off as well since we eliminate checks for zero in the vec allocations.
2023-11-25coverage: Assert that bcb0 starts with bb0 and has no in-edgesZalathar-0/+13
This explains why we don't have to worry about bcb0 having multiple in-edges.
2023-11-25coverage: Eliminate `BcbBranch`Zalathar-104/+69
`BcbBranch` represented an out-edge of a coverage graph node, but would silently refer to a node instead in cases where that node only had one in-edge. Instead we now refer to a graph edge as a `(from_bcb, to_bcb)` pair, or sometimes as just one of those nodes when the other node is implied by the surrounding context. The case of sole in-edges is handled by special code added directly to `get_or_make_edge_counter_operand`.
2023-11-25coverage: Extract `CoverageGraph::bcb_has_multiple_in_edges`Zalathar-9/+16
This was previously a helper method in `MakeBcbCounters`, but putting it in the graph lets us call it from `BcbBranch`, and gives us a more fine-grained borrow.
2023-11-25coverage: Simplify building coverage expressions based on sumsZalathar-71/+54
In some cases we need to prepare a coverage expression that is the sum of an arbitrary number of other terms. This patch simplifies the code paths that build those sums. This causes some churn in the mappings, because the previous code was building its sums in a somewhat idiosyncratic order.
2023-11-25coverage: Use `BcbCounter` to build coverage expressionsZalathar-19/+16
This means that we no longer have to manage the distinction between `BcbCounter` and `CovTerm` when preparing expressions.
2023-11-25coverage: Push down creation of a visited node's counterZalathar-6/+7
Now that this code path unconditionally calls `make_branch_counters`, we might as well make that method responsible for creating the node's counter as well, since it needs the resulting term anyway.
2023-11-25coverage: Push down and inline `bcb_needs_branch_counters`Zalathar-9/+10
This lets us avoid creating two copies of the node's branch list.
2023-11-25coverage: Rename parameter `branching_bcb` to `from_bcb`Zalathar-9/+7
2023-11-24Separate Nan/Inf floats with _Michael Goulet-2/+5
2023-11-25resolve: Avoid clones of `MacroData`Vadim Petrochenkov-55/+52
And move declarative macro compilation to an earlier point in def collector, which is required for #118188.
2023-11-24Reorder imports and remove re-exportCelina G. Val-13/+20
2023-11-24Unify TraitRefs and PolyTraitRefsMichael Goulet-22/+6
2023-11-24AmbiguityCause should not eagerly format stringsMichael Goulet-67/+54
2023-11-24Move the compiler interface defs to its own moduleCelina G. Val-163/+176
Separate items that are exposed in the `stable_mir` crate to be used by the compiler from items that we expect to be used by tool developers.
2023-11-24Auto merge of #118138 - Nilstrieb:one-previous-error, r=WaffleLapkinbors-3/+3
Fixes error count display is different when there's only one error left Supersedes #114759 ### What did I do? I did the small change in `rustc_errors` by hand. Then I did the other changes in `/compiler` by hand, those were just find replace on `*.rs` in the workspace. The changes in run-make are find replace for `run-make` in the workspace. All other changes are blessed using `x test TEST --bless`. I blessed the tests that were blessed in #114759. ### how to review this nightmare ping bors with an `r+`. You should check that my logic is sound and maybe quickly scroll through the diff, but fully verifying it seems fairly hard to impossible. I did my best to do this correctly. Thank you `@adrianEffe` for bringing this up and your initial implementation. cc `@flip1995,` you said you want to do a subtree sync asap cc `@RalfJung` maybe you want to do a quick subtree sync afterwards as well for Miri r? `@WaffleLapkin`
2023-11-24Break down `rustc_smir/mod.rs` fileCelina G. Val-1986/+2021
This file was getting too big and causing a lot of merge conflicts. All these changes shouldn't be visible to users since this module is private.
2023-11-24We should call eq instead of sup as we're relating Ty directly and not ↵Santiago Pastorino-4/+1
Binder<TraitRef>
2023-11-24Make PlaceholderReplacer shallow_resolver when folding const and ty and ↵Santiago Pastorino-4/+18
recur if contain infer vars
2023-11-24Move EagerResolution to rustc_infer::infer::resolveSantiago Pastorino-80/+87
2023-11-24Show number in error message even for one errorNilstrieb-3/+3
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24Auto merge of #118248 - compiler-errors:rollup-tye3vgj, r=compiler-errorsbors-83/+223
Rollup of 7 pull requests Successful merges: - #118187 (Recompile LLVM when it changes in the git sources) - #118210 (intercrate ambiguity causes: ignore candidates which don't apply) - #118215 (Add common trait for crate definitions) - #118238 (memcpy assumptions: update GCC link) - #118243 (EvalCtxt::commit_if_ok don't inherit nested goals) - #118245 (Add `Span` to `TraitBoundModifier`) - #118246 (Remove a hack for effects) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-24Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`David Tolnay-19/+16
2023-11-24Rollup merge of #118246 - fee1-dead-contrib:rm-hack, r=compiler-errorsMichael Goulet-6/+1
Remove a hack for effects Fallback was implemented in #115727, which addresses the inference errors mentioned in the comments.
2023-11-24Rollup merge of #118245 - fee1-dead-contrib:span-tilde-const, r=compiler-errorsMichael Goulet-13/+11
Add `Span` to `TraitBoundModifier` This improves diagnostics for the message "`~const` is not allowed here", and also fixes the span that we use when desugaring `~const Tr` into `Tr<host>` in effects desugaring.
2023-11-24Rollup merge of #118243 - lcnr:commit-if-ok, r=compiler-errorsMichael Goulet-9/+9
EvalCtxt::commit_if_ok don't inherit nested goals we use it to check whether an alias is rigid, so we want to avoid considering an alias rigid simply because the inference constraints from normalizing it caused another nested goal fail r? `@compiler-errors`
2023-11-24Rollup merge of #118215 - celinval:smir-def-paths, r=ouz-aMichael Goulet-53/+198
Add common trait for crate definitions In stable mir, we specialize DefId, however some functionality is the same for every definition, such as def paths, and getting their crate. Use a trait to implement those.
2023-11-24Rollup merge of #118210 - lcnr:intercrate-ambiguity-causes-uwu, ↵Michael Goulet-2/+4
r=compiler-errors intercrate ambiguity causes: ignore candidates which don't apply r? `@compiler-errors`
2023-11-24Auto merge of #117934 - Young-Flash:dev, r=petrochenkovbors-3/+12
feat: make `let_binding_suggestion` more reasonable This is my first PR for rustc, which trying to fix https://github.com/rust-lang/rust/issues/117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
2023-11-24Remove a hack for effectsDeadbeef-6/+1
2023-11-24Add `Span` to `TraitBoundModifier`Deadbeef-13/+11
2023-11-24EvalCtxt::commit_if_ok don't inherit nested goalslcnr-9/+9
2023-11-24Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercotebors-43/+92
Cache flags for `ty::Const` Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost. r? `@ghost`
2023-11-24Remove `ResultsCursor::get_with_analysis`.Nicholas Nethercote-6/+2
We can just call `ResultsCursor::state` and `ResultsCursor::analysis` separately.
2023-11-24Remove unnecessary `mut`.Nicholas Nethercote-1/+1
`mut_results` immediately below is the `&mut self` version, this one should be `&self`.
2023-11-23Move WorkerLocal out of QueryArenasMark Rousskov-4/+4
This cuts librustc_driver.so code size by ~85 kilobytes.
2023-11-23Enforce NonZeroUsize on thread countMark Rousskov-5/+8
This allows avoiding some if != 0 checks when allocating worker-local datasets.
2023-11-23Fix assertionbjorn3-13/+1
2023-11-23Exhaustively match CoroutineKind in fn_sig_for_fn_abibjorn3-60/+70
2023-11-23Improve documentation and fix the fixme commentCelina G. Val-8/+20
2023-11-23Fix fn_sig_for_fn_abi and the coroutine transform for generatorsbjorn3-9/+128
There were three issues previously: * The self argument was pinned, despite Iterator::next taking an unpinned mutable reference. * A resume argument was passed, despite Iterator::next not having one. * The return value was CoroutineState<Item, ()> rather than Option<Item> While these things just so happened to work with the LLVM backend, cg_clif does much stricter checks when trying to assign a value to a place. In addition it can't handle the mismatch between the amount of arguments specified by the FnAbi and the FnSig.
2023-11-24Remove unused arguments from `on_all_children_bits`.Nicholas Nethercote-90/+42
`on_all_children_bits` has two arguments that are unused: `tcx` and `body`. This was not detected by the compiler because it's a recursive function. This commit removes them, and removes lots of other arguments and fields that are no longer necessary.
2023-11-24Remove unused `EverInitializedPlaces::tcx` field.Nicholas Nethercote-5/+3
2023-11-24Remove unneeded derives from `MaybeLiveLocals`.Nicholas Nethercote-1/+0
2023-11-23Add an experimental feature gate for function delegationVadim Petrochenkov-0/+3
In accordance with the [process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). Detailed description of the feature can be found in the RFC repo - https://github.com/rust-lang/rfcs/pull/3530.