about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/builder/scope.rs
AgeCommit message (Collapse)AuthorLines
2025-08-07only introduce a guard scope for arms with guardsdianne-0/+14
2025-08-07add a scope for `if let` guard temporaries and bindingsdianne-8/+15
This ensures `if let` guard temporaries and bindings are dropped before the match arm's pattern's bindings.
2025-07-26`loop_match`: suggest extracting to a `const` itemFolkert de Vries-3/+26
if the expression cannot be evaluated in a straightforward way
2025-07-09Auto merge of #143472 - dianne:deref-pat-column-check, r=Nadrierilbors-0/+1
`rustc_pattern_analysis`: always check that deref patterns don't match on the same place as normal constructors In rust-lang/rust#140106, deref pattern validation was tied to the `deref_patterns` feature to temporarily avoid affecting perf. However: - As of rust-lang/rust#143414, box patterns are represented as deref patterns in `rustc_pattern_analysis`. Since they can be used by enabling `box_patterns` instead of `deref_patterns`, it was possible for them to skip validation, resulting in an ICE. This fixes that and adds a regression test. - External tooling (e.g. rust-analyzer) will also need to validate matches containing deref patterns, which was not possible. This fixes that by making `compute_match_usefulness` validate deref patterns by default. In order to avoid doing an extra pass for anything with patterns, the second commit makes `RustcPatCtxt` keep track of whether it encounters a deref pattern, so that it only does the check if so. This is purely for performance. If the perf impact of the first commit is negligible and the complexity cost introduced by the second commit is significant, it may be worth dropping the latter. r? `@Nadrieril`
2025-07-07`loop_match`: fix 'no terminator on block'Folkert de Vries-1/+3
2025-07-04only check for mixed deref/normal constructors when neededdianne-0/+1
2025-06-29mir: Add a `new` method to `statement`dianqk-16/+16
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-23Add `#[loop_match]` for improved DFA codegenbjorn3-3/+261
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
2025-05-27Avoid `fold`/`flat_map`.Nicholas Nethercote-5/+6
This pattern of iterating over scopes and drops occurs multiple times in this file, with slight variations. All of them use `for` loops except this one. This commits changes it for consistency.
2025-05-27Factor out some repeated code in `build_exit_tree`.Nicholas Nethercote-12/+6
2025-05-27Rename `DropTree::drops` as `DropTree::drop_nodes`.Nicholas Nethercote-34/+46
Because `Scope` also has a field named `drops`, and I found having two fields with the same name made this code harder to read.
2025-05-27Remove `DropNodeKey::kind`.Nicholas Nethercote-2/+1
It's not needed, because `next` and `local` fields uniquely identify the drop. This is a ~2% speed win on the very large program in #134404, and it's also a tiny bit simpler.
2025-05-12Fix typosomahs-1/+1
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-20/+139
async_drop_in_place::{closure}, scoped async drop added.
2025-04-20remove a couple clonesMatthias Krüger-1/+1
2025-03-28use `slice::contains` where applicableYotam Ofek-1/+1
2025-03-13Return blocks from DropTree::build_mirbjorn3-20/+17
Rather than requiring the user to pass in a correctly sized blocks map.
2025-03-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-2/+1
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-02-21Rename `ClearCrossCrate::assert_crate_local`.Nicholas Nethercote-2/+2
As `unwrap_crate_local`, because it follows exactly the standard form of an `unwrap` function.
2025-02-08Rustfmtbjorn3-47/+73
2025-01-24don't drop types with no drop glue when tailcallingWaffle Lapkin-0/+9
this is required as otherwise drops of `&mut` refs count as a usage of a 'two-phase temporary' causing an ICE.
2025-01-08run borrowck tests on BIDs and emit tail-expr-drop-order lints forDing Xiang Fei-3/+3
potential violations
2024-12-20Handle DropKind::ForLint in coroutines correctlyMichael Goulet-10/+10
2024-12-19Auto merge of #134486 - compiler-errors:drop-for-lint, r=nikomatsakisbors-41/+107
Make sure we handle `backwards_incompatible_lint` drops appropriately in drop elaboration In #131326, a new kind of scheduled drop (`drop_kind: DropKind::Value` + `backwards_incompatible_lint: true`) was added so that we could insert a new kind of no-op MIR statement (`backward incompatible drop`) for linting purposes. These drops were intended to have *no side-effects*, but drop elaboration code forgot to handle these drops specially and they were handled otherwise as normal drops in most of the code. This ends up being **unsound** since we insert more than one drop call for some values, which means that `Drop::drop` could be called more than once. This PR fixes this by splitting out the `DropKind::ForLint` and adjusting the code. I'm not totally certain if all of the places I've adjusted are either reachable or correct, but I'm pretty certain that it's *more* correct than it was previously. cc `@dingxiangfei2009` r? nikomatsakis Fixes #134482
2024-12-19pacify merciless fmtNiko Matsakis-5/+5
2024-12-19explain how `build_scope_drops` worksNiko Matsakis-2/+38
2024-12-19Rename Scope.id to Scope.local_id, remove trivial accessorMichael Goulet-1/+1
2024-12-19Use TypingEnv from MIR builderMichael Goulet-4/+1
2024-12-18Separate DropKind::ForLintMichael Goulet-39/+69
2024-12-17Rename `rustc_mir_build::build` to `builder`Zalathar-0/+1665