about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/build
AgeCommit message (Collapse)AuthorLines
2024-08-25Avoid taking reference of &TyKindMichael Goulet-1/+1
2024-08-20fix: simple typo in compiler directoryc8ef-1/+1
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-7/+7
2024-08-13Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlinbors-2/+4
miri: make vtable addresses not globally unique Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair. To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.) r? `@saethlin` Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-10Stabilize `min_exhaustive_patterns`Nadrieril-8/+5
2024-08-06miri: make vtable addresses not globally uniqueRalf Jung-2/+4
2024-08-05custom MIR: add support for tail callsRalf Jung-0/+22
2024-08-01MIR required_consts, mentioned_items: ensure we do not forget to fill these ↵Ralf Jung-2/+2
lists
2024-07-29Entirely hide `Candidate`s from outside `lower_match_tree`Nadrieril-38/+64
2024-07-29Visiting bindings is straightforward nowNadrieril-67/+14
2024-07-29Abstract out the candidate manipulation not in the main algorithmNadrieril-127/+192
2024-07-29Set up false edges in `lower_match_tree`Nadrieril-38/+42
2024-07-29Small simplificationNadrieril-14/+20
2024-07-29Reformat `use` declarations.Nicholas Nethercote-70/+82
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-25Remove an obsolete commentZalathar-6/+0
The test mentioned by this comment was deleted long ago by <https://github.com/rust-lang/rust/pull/80290>.
2024-07-25Various notes on match loweringZalathar-54/+198
2024-07-20Rollup merge of #127917 - Zalathar:after-or, r=NadrierilMatthias Krüger-91/+129
match lowering: Split `finalize_or_candidate` into more coherent methods I noticed that `finalize_or_candidate` was responsible for several different postprocessing tasks, making it difficult to understand. This PR aims to clean up some of the confusion by: - Extracting `remove_never_subcandidates` from `merge_trivial_subcandidates` - Extracting `test_remaining_match_pairs_after_or` from `finalize_or_candidate` - Taking what remains of `finalize_or_candidate`, and inlining it into its caller --- Reviewing individual commits and ignoring whitespace is recommended. Most of the large-looking changes are just moving existing code around, mostly unaltered. r? ``@Nadrieril``
2024-07-20Rollup merge of #127556 - Zalathar:autoref, r=NadrierilMatthias Krüger-81/+84
Replace a long inline "autoref" comment with method docs This comment has two problems: - It is very long, making the flow of the enclosing method hard to follow. - It starts by talking about an `autoref` flag that hasn't existed since #59114. - This makes it hard to trust that the information in the comment is accurate or relevant, even though much of it still seems to be true. This PR therefore replaces the long inline comment with a revised doc comment on `bind_matched_candidate_for_guard`, and some shorter inline comments. For readers who want more historical context, we also link to the PR that added the old comment, and the PR that removed the `autoref` flag.
2024-07-20Inline `finalize_or_candidate`Zalathar-17/+7
2024-07-20Improve `test_remaining_match_pairs_after_or`Zalathar-0/+13
2024-07-20Split out `test_remaining_match_pairs_after_or`Zalathar-43/+58
Only the last candidate can possibly have more match pairs, so this can be separate from the main or-candidate postprocessing loop.
2024-07-20Improve `merge_trivial_subcandidates`Zalathar-5/+15
2024-07-20Split out `remove_never_subcandidates`Zalathar-37/+47
2024-07-18Rollup merge of #127858 - Zalathar:pair-tree, r=NadrierilMatthias Krüger-39/+46
match lowering: Rename `MatchPair` to `MatchPairTree` In #120904, `MatchPair` became able to store other match pairs as children, forming a tree. That has made the old name confusing, so this patch renames the type to `MatchPairTree`. This PR also includes a patch renaming the `test` method to `pick_test_for_match_pair`, since it would conflict with the main change. r? `@Nadrieril`
2024-07-18pattern lowering: make sure we never call user-defined PartialEq instancesRalf Jung-28/+17
2024-07-17Rollup merge of #127472 - Zalathar:block-and-unit, r=fmeaseMatthias Krüger-73/+86
MIR building: Stop using `unpack!` for `BlockAnd<()>` This is a subset of #127416, containing only the parts related to `BlockAnd<()>`. The first patch removes the non-assigning form of the `unpack!` macro, because it is frustratingly inconsistent with the main form. We can replace it with an ordinary method that discards the `()` and returns the block. The second patch then finds all of the remaining code that was using `unpack!` with `BlockAnd<()>`, and updates it to use that new method instead. --- Changes since original review of #127416: - Renamed `fn unpack_block` → `fn into_block` - Removed `fn unpack_discard`, replacing it with `let _: BlockAnd<()> = ...` (2 occurrences) - Tweaked `arm_end_blocks` to unpack earlier and build `Vec<BasicBlock>` instead of `Vec<BlockAnd<()>>`
2024-07-17Rename `test` to `pick_test_for_match_pair`Zalathar-3/+6
2024-07-17Rename `MatchPair` to `MatchPairTree`Zalathar-37/+41
In #120904, `MatchPair` became able to store other match pairs as children, forming a tree. That has made the old name confusing, so this patch renames the type to `MatchPairTree`.
2024-07-16Rollup merge of #127707 - Zalathar:expand-until, r=NadrierilMatthias Krüger-14/+19
match lowering: Use an iterator to find `expand_until` A small cleanup that I noticed while looking at #127164. This makes it easier to see that the split point is always the index after the found item, or the whole list if no stopping point was found. r? `@Nadrieril`
2024-07-16Rollup merge of #127709 - Zalathar:pair-mod, r=NadrierilTrevor Gross-245/+272
match lowering: Move `MatchPair` tree creation to its own module This makes it easier to see that `MatchPair::new` has only one non-recursive caller, because the recursive callers are all in this module. No functional changes. --- I have used `git diff --color-moved` to verify that the moved code is identical to the old code, except for reduced visibility on the helper methods.
2024-07-16Use an iterator to find `expand_until`Zalathar-14/+19
This makes it easier to see that the split point is always the index after the found item, or the whole list if no stopping point was found.
2024-07-14Add cache for `allocate_str`Adwin White-1/+1
2024-07-14Improve internal docs for `MatchPair`Zalathar-5/+24
2024-07-14Move `MatchPair` tree creation to its own moduleZalathar-240/+248
This makes it easier to see that `MatchPair::new` has only one non-recursive caller, because the recursive callers are all in this module.
2024-07-10Replace a long inline "autoref" comment with method docsZalathar-81/+84
This comment has two problems: - It is very long, making the flow of the enclosing method hard to follow. - It starts by talking about an `autoref` flag that hasn't existed since #59114. This PR therefore replaces the long inline comment with a revised doc comment on `bind_matched_candidate_for_guard`, and some shorter inline comments. For readers who want more historical context, we also link to the PR that added the old comment, and the PR that removed the `autoref` flag.
2024-07-09Address review commentsNadrieril-4/+4
2024-07-09Return the `otherwise_block` instead of passing it as argumentNadrieril-57/+29
This saves a few blocks and matches the common `unpack!` paradigm.
2024-07-09Factor out the "process remaining candidates" casesNadrieril-44/+30
2024-07-09Don't try to save an extra blockNadrieril-13/+9
This is preparation for the next commit.
2024-07-09Move or-pattern expansion inside the main part of the algorithmNadrieril-36/+24
2024-07-09Factor out the special handling of or-patternsNadrieril-81/+104
2024-07-09Move a functionNadrieril-19/+19
2024-07-09Auto merge of #127028 - Nadrieril:fix-or-pat-expansion, r=matthewjasperbors-0/+3
Fix regression in the MIR lowering of or-patterns In https://github.com/rust-lang/rust/pull/126553 I made a silly indexing mistake and regressed the MIR lowering of or-patterns. This fixes it. r? `@compiler-errors` because I'd like this to be merged quickly :pray:
2024-07-08Auto merge of #113128 - WaffleLapkin:become_trully_unuwuable, r=oli-obk,RalfJungbors-2/+123
Support tail calls in mir via `TerminatorKind::TailCall` This is one of the interesting bits in tail call implementation — MIR support. This adds a new `TerminatorKind` which represents a tail call: ```rust TailCall { func: Operand<'tcx>, args: Vec<Operand<'tcx>>, fn_span: Span, }, ``` *Structurally* this is very similar to a normal `Call` but is missing a few fields: - `destination` — tail calls don't write to destination, instead they pass caller's destination to the callee (such that eventual `return` will write to the caller of the function that used tail call) - `target` — similarly to `destination` tail calls pass the caller's return address to the callee, so there is nothing to do - `unwind` — I _think_ this is applicable too, although it's a bit confusing - `call_source` — `become` forbids operators and is not created as a lowering of something else; tail calls always come from HIR (at least for now) It might be helpful to read the interpreter implementation to understand what `TailCall` means exactly, although I've tried documenting it too. ----- There are a few `FIXME`-questions still left, ideally we'd be able to answer them during review ':) ----- r? `@oli-obk` cc `@scottmcm` `@DrMeepster` `@JakobDegen`
2024-07-08Stop using `unpack!` for `BlockAnd<()>`Zalathar-29/+26
2024-07-08Remove the non-assigning form of `unpack!`Zalathar-44/+60
This kind of unpacking can be expressed as an ordinary method on `BlockAnd<()>`.
2024-07-07Fix conflicts after rebaseMaybe Lapkin-1/+1
- r-l/r 126784 - r-l/r 127113 - r-l/miri 3562
2024-07-07Properly handle drops for tail callsDrMeepster-18/+107
2024-07-07Support tail calls in mir via `TerminatorKind::TailCall`Maybe Waffle-2/+34
2024-07-05coverage: Rename `mir::coverage::BranchInfo` to `CoverageInfoHi`Zalathar-60/+73
This opens the door to collecting and storing coverage information that is unrelated to branch coverage or MC/DC.