Skip to content

Commit cfd0d4c

Browse files
Rollup merge of rust-lang#156368 - aapoalas:reborrow-in-match-statement, r=Nadrieril
Fix invalid unreachable in is_known_valid_scrutinee for Reborrow Fixes rust-lang#156304 Part of the Reborrow traits experiment rust-lang#145612
2 parents 4d2f9ca + 5c0718b commit cfd0d4c

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,8 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
363363
| UpvarRef { .. }
364364
| VarRef { .. }
365365
| ZstLiteral { .. }
366-
| Yield { .. } => true,
367-
ExprKind::Reborrow { .. } => {
368-
// FIXME(reborrow): matching on a Reborrow expression should be impossible
369-
// currently. Whether this remains to be true, and if the reborrow result then is a
370-
// known valid scrutinee requires further thought.
371-
unreachable!("Reborrow expression in match")
372-
}
366+
| Yield { .. }
367+
| Reborrow { .. } => true,
373368
}
374369
}
375370

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ check-pass
2+
#![feature(reborrow)]
3+
4+
use std::marker::Reborrow;
5+
6+
#[allow(unused)]
7+
struct Thing<'a>(&'a ());
8+
9+
impl<'a> Reborrow for Thing<'a> {}
10+
11+
fn main() {
12+
let x = Thing(&());
13+
let _y: Thing<'_> = x;
14+
}

0 commit comments

Comments
 (0)