| Age | Commit message (Collapse) | Author | Lines |
|
|
|
This ensures `if let` guard temporaries and bindings are dropped before
the match arm's pattern's bindings.
|
|
if the expression cannot be evaluated in a straightforward way
|
|
`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`
|
|
|
|
|
|
Avoid introducing a large number of changes when adding optional initialization fields.
|
|
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
|
|
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.
|
|
|
|
Because `Scope` also has a field named `drops`, and I found having two
fields with the same name made this code harder to read.
|
|
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.
|
|
|
|
async_drop_in_place::{closure}, scoped async drop added.
|
|
|
|
|
|
Rather than requiring the user to pass in a correctly sized blocks map.
|
|
Continuing the work from #137350.
Removes the unused methods: `expect_variant`, `expect_field`,
`expect_foreign_item`.
Every method gains a `hir_` prefix.
|
|
As `unwrap_crate_local`, because it follows exactly the standard form of
an `unwrap` function.
|
|
|
|
this is required as otherwise drops of `&mut` refs count as a usage of a
'two-phase temporary' causing an ICE.
|
|
potential violations
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|