Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay an is_local_ever_initialized call. #66537

Merged
merged 1 commit into from Nov 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -1883,16 +1883,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let error_access;
let the_place_err;

// rust-lang/rust#21232, #54986: during period where we reject
// partial initialization, do not complain about mutability
// errors except for actual mutation (as opposed to an attempt
// to do a partial initialization).
let previously_initialized = if let PlaceBase::Local(local) = place.base {
self.is_local_ever_initialized(local, flow_state).is_some()
} else {
true
};

match kind {
Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Unique))
| Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Mut { .. }))
Expand Down Expand Up @@ -1966,8 +1956,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}

// rust-lang/rust#21232, #54986: during period where we reject
pnkfelix marked this conversation as resolved.
Show resolved Hide resolved
// partial initialization, do not complain about mutability
// errors except for actual mutation (as opposed to an attempt
// to do a partial initialization).
let previously_initialized = if let PlaceBase::Local(local) = place.base {
self.is_local_ever_initialized(local, flow_state).is_some()
} else {
true
};

// at this point, we have set up the error reporting state.
return if previously_initialized {
if previously_initialized {
self.report_mutability_error(
place,
span,
Expand All @@ -1978,7 +1978,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
true
} else {
false
};
}
}

fn is_local_ever_initialized(
Expand Down