about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/build/custom
AgeCommit message (Collapse)AuthorLines
2024-12-17Rename `rustc_mir_build::build` to `builder`Zalathar-909/+0
2024-12-15Add hir::AttributeJonathan Dönszelmann-2/+1
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-5/+5
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-3/+3
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-7/+6
- 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-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-7/+5
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-2/+2
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-29Reformat `use` declarations.Nicholas Nethercote-10/+10
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-05coverage: Rename `mir::coverage::BranchInfo` to `CoverageInfoHi`Zalathar-1/+1
This opens the door to collecting and storing coverage information that is unrelated to branch coverage or MC/DC.
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-5/+5
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-23Remove `#[macro_use] extern crate tracing` from `rustc_mir_build`.Nicholas Nethercote-1/+1
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-3/+9
2024-05-13Remove `extern crate rustc_middle` from `rustc_mir_build`.Nicholas Nethercote-0/+1
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-1/+1
It is commonly used.
2024-04-03Remove MIR unsafe checkMatthew Jasper-4/+1
This also remove safety information from MIR.
2024-03-25Auto merge of #122721 - oli-obk:merge_queries, r=davidtwcobors-1/+1
Replace `mir_built` query with a hook and use mir_const everywhere instead A small perf improvement due to less dep graph handling. Mostly just a cleanup to get rid of one of our many mir queries
2024-03-20collector: recursively traverse 'mentioned' items to evaluate their constantsRalf Jung-0/+1
2024-03-20Replace `mir_built` query with a hook and use mir_const everywhere insteadOli Scherer-1/+1
2024-03-14coverage: Data structures for recording branch info during MIR buildingZalathar-0/+1
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-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-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-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-18coverage: Attach an optional `FunctionCoverageInfo` to `mir::Body`Zalathar-0/+1
This allows coverage information to be attached to the function as a whole when appropriate, instead of being smuggled through coverage statements in the function's basic blocks. As an example, this patch moves the `function_source_hash` value out of individual `CoverageKind::Counter` statements and into the per-function info. When synthesizing unused functions for coverage purposes, the absence of this info is taken to indicate that a function was not eligible for coverage and should not be synthesized.
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-05Refactor how MIR represents composite debuginfo.Camille GILLOT-0/+1
2023-09-01Support debuginfo for custom MIR.Camille GILLOT-2/+57
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-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-1/+1
r? @WaffleLapkin
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-2/+2
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-6/+4