mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Validate that locals have a corresponding LocalDecl
This commit is contained in:
parent
f2a11a2537
commit
7eb1a1afcf
@ -183,6 +183,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
|
||||
if self.body.local_decls.get(*local).is_none() {
|
||||
self.fail(
|
||||
location,
|
||||
format!("local {:?} has no corresponding declaration in `body.local_decls`", local),
|
||||
);
|
||||
}
|
||||
|
||||
if self.reachable_blocks.contains(location.block) && context.is_use() {
|
||||
// Uses of locals must occur while the local's storage is allocated.
|
||||
self.storage_liveness.seek_after_primary_effect(location);
|
||||
|
Loading…
Reference in New Issue
Block a user