about summary refs log tree commit diff
path: root/compiler/rustc_mir_build
AgeCommit message (Collapse)AuthorLines
2024-07-03Auto merge of #125507 - compiler-errors:type-length-limit, r=lcnrbors-2/+3
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in #37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in #72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes #125460
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-2/+3
2024-07-02chore: remove duplicate wordshattizai-2/+2
2024-06-30Replace a magic boolean with enum `ScheduleDrops`Zalathar-18/+56
2024-06-30Replace a magic boolean with enum `EmitStorageLive`Zalathar-19/+32
The previous boolean used `true` to indicate that storage-live should _not_ be emitted, so all occurrences of `Yes` and `No` should be the logical opposite of the previous value.
2024-06-30Replace a magic boolean with enum `DeclareLetBindings`Zalathar-17/+64
The new enum `DeclareLetBindings` has three variants: - `Yes`: Declare `let` bindings as normal, for `if` conditions. - `No`: Don't declare bindings, for match guards and let-else. - `LetNotPermitted`: Assert that `let` expressions should not occur.
2024-06-29Rollup merge of #126835 - Nadrieril:reify-decision-tree, r=matthewjasperMatthias Krüger-260/+250
Simplifications in match lowering A series of small simplifications and deduplications in the MIR lowering of patterns. r? ````@matthewjasper````
2024-06-27Fix expansion of or-patternsNadrieril-0/+3
2024-06-25Rollup merge of #126932 - Zalathar:flat-pat, r=NadrierilMatthias Krüger-11/+24
Tweak `FlatPat::new` to avoid a temporarily-invalid state It was somewhat confusing that the old constructor would create a `FlatPat` in a (possibly) non-simplified state, and then simplify its contents in-place. So instead we now create its fields as local variables, perform simplification, and then create the struct afterwards. This doesn't affect correctness, but is less confusing. --- I've also included some semi-related comments that I made while trying to navigate this code.
2024-06-25Rollup merge of #126926 - Zalathar:candidate-per-arm, r=NadrierilMatthias Krüger-2/+5
Tweak a confusing comment in `create_match_candidates` This comment was accurate at the time it was written, but various later changes reshuffled things in ways that caused the existing comment to become confusing. I've therefore tried to clarify that *these* candidates are 1:1 with match arms, while also warning that that isn't the case in general.
2024-06-25Tweak `FlatPat::new` to avoid a temporarily-invalid stateZalathar-11/+24
It was somewhat confusing that the old constructor would create a `FlatPat` in a (possibly) non-simplified state, and then simplify its contents in-place. So instead we now create its fields as local variables, perform simplification, and then create the struct afterwards. This doesn't affect correctness, but is less confusing.
2024-06-25Tweak a confusing comment in `create_match_candidates`Zalathar-2/+5
2024-06-25Auto merge of #126813 - compiler-errors:SliceLike, r=lcnrbors-1/+1
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes) First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why. Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in. Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷 r? lcnr
2024-06-24Auto merge of #126784 - scottmcm:smaller-terminator, r=compiler-errorsbors-8/+10
Save 2 pointers in `TerminatorKind` (96 → 80 bytes) 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-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-1/+1
AliasTy/AliasTerm/TraitRef/projection
2024-06-23Replace `f16` and `f128` pattern matching stubs with real implementationsTrevor Gross-2/+2
This section of code depends on `rustc_apfloat` rather than our internal types, so this is one potential ICE that we should be able to melt now. This also fixes some missing range and match handling in `rustc_middle`.
2024-06-22Change comment to reflect switch to THIR unsafeckNadrieril-14/+10
2024-06-22Reuse `lower_let_expr` for `let .. else` loweringNadrieril-87/+49
2024-06-22Don't use fake wildcards when we can get the failure block directlyNadrieril-50/+59
This commit too was obtained by repeatedly inlining and simplifying.
2024-06-21Save 2 pointers in `TerminatorKind` (96 → 80 bytes)Scott McMurray-8/+10
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-21Fix remaining casesMichael Goulet-1/+1
2024-06-20[GVN] Add tests for generic pointees with PtrMetadataScott McMurray-0/+4
2024-06-19Move `lower_match_tree`Nadrieril-65/+64
2024-06-19There's nothing to bind for a wildcardNadrieril-8/+1
This commit was obtained by repeatedly inlining and simplifying.
2024-06-19Small dedupNadrieril-18/+15
2024-06-19Only one caller of `lower_match_tree` was using the fake borrowsNadrieril-31/+17
2024-06-19We can traverse bindings before `lower_match_tree` nowNadrieril-50/+98
2024-06-19Auto merge of #126679 - fmease:rollup-njrv2py, r=fmeasebors-23/+48
Rollup of 6 pull requests Successful merges: - #125447 (Allow constraining opaque types during subtyping in the trait system) - #125766 (MCDC Coverage: instrument last boolean RHS operands from condition coverage) - #125880 (Remove `src/tools/rust-demangler`) - #126154 (StorageLive: refresh storage (instead of UB) when local is already live) - #126572 (override user defined channel when using precompiled rustc) - #126662 (Unconditionally warn on usage of `wasm32-wasi`) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-19Rollup merge of #125766 - RenjiSann:fresh-mcdc-branch-on-bool, r=nnethercoteLeón Orell Valerian Liehr-23/+48
MCDC Coverage: instrument last boolean RHS operands from condition coverage Fresh PR from #124652 -- This PR ensures that the top-level boolean expressions that are not part of the control flow are correctly instrumented thanks to condition coverage. See discussion on https://github.com/rust-lang/rust/issues/124120. Depends on `@Zalathar` 's condition coverage implementation #125756.
2024-06-19Rollup merge of #126553 - Nadrieril:expand-or-pat-into-above, r=matthewjasperLeón Orell Valerian Liehr-97/+120
match lowering: expand or-candidates mixed with candidates above This PR tweaks match lowering of or-patterns. Consider this: ```rust match (x, y) { (1, true) => 1, (2, false) => 2, (1 | 2, true | false) => 3, (3 | 4, true | false) => 4, _ => 5, } ``` One might hope that this can be compiled to a single `SwitchInt` on `x` followed by some boolean checks. Before this PR, we compile this to 3 `SwitchInt`s on `x`, because an arm that contains more than one or-pattern was compiled on its own. This PR groups branch `3` with the two branches above, getting us down to 2 `SwitchInt`s on `x`. We can't in general expand or-patterns freely, because this interacts poorly with another optimization we do: or-pattern simplification. When an or-pattern doesn't involve bindings, we branch the success paths of all its alternatives to the same block. The drawback is that in a case like: ```rust match (1, true) { (1 | 2, false) => unreachable!(), (2, _) => unreachable!(), _ => {} } ``` if we used a single `SwitchInt`, by the time we test `false` we don't know whether we came from the `1` case or the `2` case, so we don't know where to go if `false` doesn't match. Hence the limitation: we can process or-pattern alternatives alongside candidates that precede it, but not candidates that follow it. (Unless the or-pattern is the only remaining match pair of its candidate, in which case we can process it alongside whatever). This PR allows the processing of or-pattern alternatives alongside candidates that precede it. One benefit is that we now process or-patterns in a single place in `mod.rs`. r? ``@matthewjasper``
2024-06-19coverage: Make MCDC take in account last RHS of condition-coverageDorian Péron-23/+48
Condition coverage extends branch coverage to treat the specific case of last operands of boolean decisions not involved in control flow. This is ultimately made for MCDC to be exhaustive on all boolean expressions. This patch adds a call to `visit_branch_coverage_operation` to track the top-level operand of the said decisions, and changes `visit_coverage_standalone_condition` so MCDC branch registration is called when enabled on these _last RHS_ cases.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-1/+1
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-3/+3
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-16Expand or-candidates mixed with candidates aboveNadrieril-97/+79
We can't mix them with candidates below them, but we can mix them with candidates above.
2024-06-16Factor out `finalize_or_candidate`Nadrieril-18/+42
2024-06-16Use `otherwise_block` for or-pattern shortcuttingNadrieril-3/+8
2024-06-16Always set `otherwise_block`sNadrieril-13/+20
2024-06-16Tweak simple or-pattern expansionNadrieril-16/+21
2024-06-15Rollup merge of #126354 - compiler-errors:variance, r=lcnrMatthias Krüger-4/+4
Use `Variance` glob imported variants everywhere Fully commit to using the globbed variance. Could be convinced the other way, and change this PR to not use the globbed variants anywhere, but I'd rather we do one or the other. r? lcnr
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-3/+5
2024-06-12Use Variance glob import everywhereMichael Goulet-4/+4
2024-06-12Add TODO comment to unsafe env modificationTobias Bucher-0/+8
Addresses https://github.com/rust-lang/rust/pull/124636#issuecomment-2132119534. I think that the diff display regresses a little, because it's no longer showing the `+` to show where the `unsafe {}` is added. I think it's still fine.
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-0/+2
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-10Rollup merge of #126159 - RalfJung:scalarint-size-mismatch, r=oli-obkMatthias Krüger-17/+13
ScalarInt: size mismatches are a bug, do not delay the panic Cc [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Why.20are.20ScalarInt.20to.20iN.2FuN.20methods.20fallible.3F) r? ``@oli-obk``
2024-06-10ScalarInt: size mismatches are a bug, do not delay the panicRalf Jung-17/+13
2024-06-10Remove some unused crate dependencies.Nicholas Nethercote-2/+0
I found these by setting the `unused_crate_dependencies` lint temporarily to `Warn`.
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-9/+14
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-1/+5
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-06Auto merge of #126056 - matthiaskrgr:rollup-ytwg62v, r=matthiaskrgrbors-34/+47
Rollup of 6 pull requests Successful merges: - #124731 (Add translation support by mdbook-i18n-helpers to bootstrap) - #125168 (Match ergonomics 2024: align implementation with RFC) - #125925 (Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fns) - #125987 (When `derive`ing, account for HRTB on `BareFn` fields) - #126045 (check_expr_struct_fields: taint context with errors if struct definit…) - #126048 (Fix typos in cargo-specifics.md) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-05Don't trigger `unsafe_op_in_unsafe_fn` for deprecated safe fnsTobias Bucher-34/+47
Fixes #125875.