Make sure to walk into nested const blocks in RegionResolutionVisitor
This commit is contained in:
parent
8247594932
commit
9d2e1ed6bd
2 changed files with 24 additions and 4 deletions
|
@ -420,10 +420,10 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
||||||
// properly, we can't miss any types.
|
// properly, we can't miss any types.
|
||||||
|
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
// Manually recurse over closures and inline consts, because they are the only
|
// Manually recurse over closures, because they are nested bodies
|
||||||
// case of nested bodies that share the parent environment.
|
// that share the parent environment. We handle const blocks in
|
||||||
hir::ExprKind::Closure(&hir::Closure { body, .. })
|
// `visit_inline_const`.
|
||||||
| hir::ExprKind::ConstBlock(hir::ConstBlock { body, .. }) => {
|
hir::ExprKind::Closure(&hir::Closure { body, .. }) => {
|
||||||
let body = visitor.tcx.hir().body(body);
|
let body = visitor.tcx.hir().body(body);
|
||||||
visitor.visit_body(body);
|
visitor.visit_body(body);
|
||||||
}
|
}
|
||||||
|
@ -906,6 +906,10 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
|
||||||
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) {
|
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) {
|
||||||
resolve_local(self, Some(l.pat), l.init)
|
resolve_local(self, Some(l.pat), l.init)
|
||||||
}
|
}
|
||||||
|
fn visit_inline_const(&mut self, c: &'tcx hir::ConstBlock) {
|
||||||
|
let body = self.tcx.hir().body(c.body);
|
||||||
|
self.visit_body(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
|
/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
|
||||||
|
|
16
tests/ui/inline-const/collect-scopes-in-pat.rs
Normal file
16
tests/ui/inline-const/collect-scopes-in-pat.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// @compile-flags: -Zlint-mir
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![feature(inline_const_pat)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match 1 {
|
||||||
|
const {
|
||||||
|
|| match 0 {
|
||||||
|
x => 0,
|
||||||
|
};
|
||||||
|
0
|
||||||
|
} => (),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue