1
Fork 0

Fix label on uninit binding field assignment

This commit is contained in:
Esteban Küber 2022-06-22 15:36:26 -07:00
parent a86fa4fa38
commit 5f91614d12
3 changed files with 31 additions and 30 deletions

View file

@ -350,8 +350,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] };
visitor.visit_body(&body);
let isnt_initialized =
if let InitializationRequiringAction::PartialAssignment = desired_action {
let isnt_initialized = if let InitializationRequiringAction::PartialAssignment
| InitializationRequiringAction::Assignment = desired_action
{
// The same error is emitted for bindings that are *sometimes* initialized and the ones
// that are *partially* initialized by assigning to a field of an uninitialized
// binding. We differentiate between them for more accurate wording here.

View file

@ -1,10 +1,10 @@
error[E0381]: assigned binding `x.0` isn't initialized
error[E0381]: assigned binding `x.0` isn't fully initialized
--> $DIR/borrowck-partial-reinit-4.rs:17:5
|
LL | let mut x : (Test2, Test2);
| ----- binding declared here but left uninitialized
LL | (x.0).0 = Some(Test);
| ^^^^^^^ `x.0` assigned here but it isn't initialized
| ^^^^^^^ `x.0` assigned here but it isn't fully initialized
error: aborting due to previous error

View file

@ -1,18 +1,18 @@
error[E0381]: assigned binding `d` isn't initialized
error[E0381]: assigned binding `d` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:28:5
|
LL | let d: D;
| - binding declared here but left uninitialized
LL | d.x = 10;
| ^^^^^^^^ `d` assigned here but it isn't initialized
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
error[E0381]: assigned binding `d` isn't initialized
error[E0381]: assigned binding `d` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:33:5
|
LL | let mut d: D;
| ----- binding declared here but left uninitialized
LL | d.x = 10;
| ^^^^^^^^ `d` assigned here but it isn't initialized
| ^^^^^^^^ `d` assigned here but it isn't fully initialized
error[E0382]: assign of moved value: `d`
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:39:5