Rollup merge of #123311 - Jules-Bertholet:andpat-everywhere, r=Nadrieril
Match ergonomics: implement "`&`pat everywhere" Implements the eat-two-layers (feature gate `and_pat_everywhere`, all editions) ~and the eat-one-layer (feature gate `and_eat_one_layer_2024`, edition 2024 only, takes priority on that edition when both feature gates are active)~ (EDIT: will be done in later PR) semantics. cc #123076 r? ``@Nadrieril`` ``@rustbot`` label A-patterns A-edition-2024
This commit is contained in:
commit
f2f8d8b722
11 changed files with 281 additions and 28 deletions
|
@ -65,7 +65,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
// we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the
|
||||
// adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted
|
||||
// gets the least-dereferenced type).
|
||||
let unadjusted_pat = self.lower_pattern_unadjusted(pat);
|
||||
let unadjusted_pat = match pat.kind {
|
||||
hir::PatKind::Ref(inner, _)
|
||||
if self.typeck_results.skipped_ref_pats().contains(pat.hir_id) =>
|
||||
{
|
||||
self.lower_pattern_unadjusted(inner)
|
||||
}
|
||||
_ => self.lower_pattern_unadjusted(pat),
|
||||
};
|
||||
self.typeck_results.pat_adjustments().get(pat.hir_id).unwrap_or(&vec![]).iter().rev().fold(
|
||||
unadjusted_pat,
|
||||
|pat: Box<_>, ref_ty| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue