about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/build/custom/parse
AgeCommit message (Collapse)AuthorLines
2024-12-17Rename `rustc_mir_build::build` to `builder`Zalathar-400/+0
2024-12-09Introduce `default_field_values` featureEsteban Küber-1/+1
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-11-20Rollup merge of #132708 - estebank:const-as-binding, r=NadrierilMatthias Krüger-6/+14
Point at `const` definition when used instead of a binding in a `let` statement Modify `PatKind::InlineConstant` to be `ExpandedConstant` standing in not only for inline `const` blocks but also for `const` items. This allows us to track named `const`s used in patterns when the pattern is a single binding. When we detect that there is a refutable pattern involving a `const` that could have been a binding instead, we point at the `const` item, and suggest renaming. We do this for both `let` bindings and `match` expressions missing a catch-all arm if there's at least one single binding pattern referenced. After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ pattern `1_u32..=u32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` help: introduce a variable instead | LL | let PAT_var = v1; | ~~~~~~~ ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` CC #132582.
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-2/+2
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-17Account for `ExpandedConstant` in `parse_match`Esteban Küber-6/+14
2024-11-17Unify expanded constants and named constants in `PatKind`Esteban Küber-1/+1
2024-11-17Fold `PatKind::NamedConstant` into `PatKind::Constant`Esteban Küber-3/+1
2024-11-17Point at `const` definition when used instead of a binding in a `let` statementEsteban Küber-1/+3
After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ```
2024-10-30compiler: Switch to rustc_abi in hir_pretty, lint_defs, and mir_buildJubilee Young-1/+1
Completely abandon usage of rustc_target in these crates, as they need no special knowledge of rustc's target tuples.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-1/+1
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-2/+2
2024-08-05custom MIR: add support for tail callsRalf Jung-0/+22
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-21Save 2 pointers in `TerminatorKind` (96 → 80 bytes)Scott McMurray-1/+1
These things don't need to be `Vec`s; boxed slices are enough. The frequent one here is call arguments, but MIR building knows the number of arguments from the THIR, so the collect is always getting the allocation right in the first place, and thus this shouldn't ever add the shrink-in-place overhead.
2024-06-20[GVN] Add tests for generic pointees with PtrMetadataScott McMurray-0/+4
2024-06-04Reduce `pub` exposure.Nicholas Nethercote-3/+3
A lot of errors don't need to be visible outside the crate, and some other things as well.
2024-05-28Add custom mir support for `PtrMetadata`Scott McMurray-0/+1
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-3/+9
2024-01-22Add Assume custom MIR.Camille GILLOT-0/+4
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-1/+4
To enable improved accuracy of diagnostics in upcoming commits.
2023-12-26custom mir: make it clear what the return block isRalf Jung-2/+10
2023-11-14Custom MIR: Support cleanup blocksTomasz Miąsko-24/+59
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-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-4/+4
2023-09-20the Const::eval_bits methods don't need to be given the TyRalf Jung-2/+2
2023-09-19move ConstValue into mirRalf Jung-1/+1
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-01Support debuginfo for custom MIR.Camille GILLOT-1/+1
2023-08-19custom_mir: change Call() terminator syntax to something more readableRalf Jung-10/+9
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-2/+2
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-3/+3
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-1/+3
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-0/+1
2023-05-15Add CopyForDeref to custom MIRAndy Wang-0/+1
2023-04-11Add Offset binary op to custom mirAndy Wang-0/+5
2023-04-06Fix new usage of old apiGary Guo-2/+2
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-1/+1
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-2/+2
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+4
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-20Use builtin_index instead of matchAndy Wang-5/+2
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2023-03-20Support aggregate expressionsAndy Wang-0/+25
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-8/+0
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-8/+0
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-07Custom MIR: Support as castsAndy Wang-1/+8
2023-01-26Custom mir: Add support for some remaining, easy to support constructsJakob Degen-0/+14
2023-01-26Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obkMatthias Krüger-0/+6
Custom MIR: Support binary and unary operations Lower binary and unary operations directly to corresponding unchecked MIR operations. Ultimately this might not be syntax we want, but it allows for experimentation in the meantime. r? ````@oli-obk```` ````@JakobDegen````
2023-01-19Custom MIR: Support binary and unary operationsTomasz Miąsko-0/+6
2023-01-19Custom MIR: Support storage statementsTomasz Miąsko-0/+6
2022-12-21Clarify that raw retags are not permitted in MirJakob Degen-3/+0
2022-12-18use &str / String literals instead of format!()Matthias Krüger-1/+1