about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2023-11-22Separate `PatStack` and `MatrixRow`Nadrieril-42/+90
This disentangles the row-specific tracking of `parent_row` etc from the logical operation of specialization. This means `wildcard_row` doesn't need to provide dummy values for `parent_row` etc anymore.
2023-11-22Clarify the `Wildcard`/`Missing` situationNadrieril-43/+59
2023-11-22Cleanup span passingNadrieril-30/+31
2023-11-22Store wildcard row in the matrixNadrieril-39/+48
2023-11-22Fully rework the algorithm and its explanationNadrieril-638/+748
2023-11-22Keep rows with guards in the matrixNadrieril-46/+38
2023-11-22Respect `split` invariants for `Opaque`sNadrieril-25/+59
2023-11-22Abstract over the list of `WitnessStack`sNadrieril-69/+106
2023-11-22Tweak `lower_pattern`Nadrieril-2/+4
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-86/+79
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-19Rollup merge of #117832 - RalfJung:interpret-shift, r=cjgillotMichael Goulet-4/+5
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
2023-11-17rename bound region instantiationlcnr-1/+1
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-15Re-format code with new rustfmtMark Rousskov-5/+7
2023-11-14Rollup merge of #117686 - compiler-errors:gen-body, r=wesleywiserMatthias Krüger-11/+1
Build pre-coroutine-transform coroutine body on error I was accidentally building the post-transform coroutine body, rather than the pre-transform coroutine body. There's no pinning expected here yet, and the return type isn't yet transformed into `CoroutineState`. Fixes #117670
2023-11-14Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillotbors-36/+108
Custom MIR: Support cleanup blocks Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-14Custom MIR: Support cleanup blocksTomasz Miąsko-36/+108
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-1/+1
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-12interpret: simplify handling of shifts by no longer trying to handle signed ↵Ralf Jung-4/+5
and unsigned shift amounts in the same branch
2023-11-09Auto merge of #117712 - lcnr:expand-coroutine, r=jackh726bors-5/+5
generator layout: ignore fake borrows fixes #117059 We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: https://github.com/rust-lang/rust/blob/fab1054e1742790c22ccc92a625736d658363677/compiler/rustc_mir_build/src/build/matches/mod.rs#L1250-L1265 These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in #117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards. Only the second commit impacts behavior, and could be backported by itself. r? types
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-5/+5
also adds some comments
2023-11-08Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwcobors-30/+31
patterns: reject raw pointers that are not just integers Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not. This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context. Also fixes https://github.com/rust-lang/rust/issues/116929. Cc `@oli-obk` `@lcnr`
2023-11-08avoid unnecessary nested conditionalsRalf Jung-11/+9
2023-11-07Build pre-coroutine-transform coroutine bodyMichael Goulet-11/+1
2023-11-07Auto merge of #117229 - matthewjasper:thir-unsafeck-fixes, r=cjgillotbors-19/+112
Thir unsafeck fixes - Recognise thread local statics in THIR unsafeck - Add suggestion for unsafe_op_in_unsafe_fn - Fix unsafe checking of let expressions
2023-11-06Build a better MIR body when errors are encounteredMichael Goulet-29/+59
2023-11-06Visit patterns in THIR let expressionsMatthew Jasper-8/+0
This fixes some THIR unsafety checking errors not being emitted for let expressions in these situations.
2023-11-06Add suggestion to THIR unsafe_op_in_unsafe_fn lintMatthew Jasper-10/+109
2023-11-06Recognise thread local statics in THIR unsafeckMatthew Jasper-1/+3
2023-11-04Suggest to set lint level on whole matchNadrieril-14/+33
2023-11-04Warn when lint level is set on a match armNadrieril-21/+46
2023-11-04Rollup merge of #117343 - Nadrieril:cleanup_check_match, r=davidtwcoTakayuki Maeda-434/+400
Cleanup `rustc_mir_build/../check_match.rs` The file had become pretty unwieldy, with a fair amount of duplication. As a bonus, I discovered that we weren't running some pattern checks in if-let chains. I recommend looking commit-by-commit. The last commit is a whim, I think it makes more sense that way but I don't hold this opinion strongly.
2023-11-03Tweak spans for "adt defined here" noteNadrieril-6/+1
2023-11-03Accumulate let chains alongside the visitNadrieril-76/+78
2023-11-03clone lessMatthias Krüger-1/+1
2023-11-02Cleanup check_match code pathsNadrieril-110/+104
2023-11-02Factor out pointing at ADT definitionNadrieril-44/+41
2023-11-02Always do all the pattern checksNadrieril-60/+60
2023-11-02Tweak diagnostic for consistencyNadrieril-4/+2
2023-11-02Check pattern error while loweringNadrieril-42/+29
2023-11-02Uncomplicate check_let_chainNadrieril-45/+35
2023-11-02ReorderNadrieril-148/+151
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-1/+1
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-11-01Auto merge of #116692 - Nadrieril:half-open-ranges, r=cjgillotbors-354/+401
Match usize/isize exhaustively with half-open ranges The long-awaited finale to the saga of [exhaustiveness checking for integers](https://github.com/rust-lang/rust/pull/50912)! ```rust match 0usize { 0.. => {} // exhaustive! } match 0usize { 0..usize::MAX => {} // helpful error message! } ``` Features: - Half-open ranges behave as expected for `usize`/`isize`; - Trying to use `0..usize::MAX` will tell you that `usize::MAX..` is missing and explain why. No more unhelpful "`_` is missing"; - Everything else stays the same. This should unblock https://github.com/rust-lang/rust/issues/37854. Review-wise: - I recommend looking commit-by-commit; - This regresses perf because of the added complexity in `IntRange`; hopefully not too much; - I measured each `#[inline]`, they all help a bit with the perf regression (tho I don't get why); - I did not touch MIR building; I expect there's an easy PR there that would skip unnecessary comparisons when the range is half-open.
2023-10-31Support enum variants in offset_of!George Bateman-1/+1
2023-10-30Some more coroutine renamingsMichael Goulet-8/+13
2023-10-30Rollup merge of #117398 - Nadrieril:fix-117378, r=compiler-errorsMatthias Krüger-1/+1
Correctly handle nested or-patterns in exhaustiveness I had assumed nested or-patterns were flattened, and they mostly are but not always. Fixes https://github.com/rust-lang/rust/issues/117378
2023-10-30Correctly handle nested or-patterns in column-wise analysesNadrieril-1/+1
2023-10-30remove some dead codeRalf Jung-10/+0
2023-10-28also lint against fn ptr and raw ptr nested inside the constRalf Jung-13/+9
2023-10-28patterns: reject raw pointers that are not just integersRalf Jung-8/+25