diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2022-06-22 15:36:26 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2022-07-07 12:25:56 -0700 |
| commit | 5f91614d12f1aed56c8c9ea1d9d39a6f0db98892 (patch) | |
| tree | c1273e1996da4aa0b190cf09862675a5bc5a92a3 /compiler/rustc_borrowck | |
| parent | a86fa4fa388b25c182146d29c88243325d66c130 (diff) | |
| download | rust-5f91614d12f1aed56c8c9ea1d9d39a6f0db98892.tar.gz rust-5f91614d12f1aed56c8c9ea1d9d39a6f0db98892.zip | |
Fix label on uninit binding field assignment
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index f3d9d859701..c5420cee05e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -350,36 +350,37 @@ 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 { - // 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. - "isn't fully initialized" - } else if spans - .iter() - .filter(|i| { - // We filter these to avoid misleading wording in cases like the following, - // where `x` has an `init`, but it is in the same place we're looking at: - // ``` - // let x; - // x += 1; - // ``` - !i.contains(span) + 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. + "isn't fully initialized" + } else if spans + .iter() + .filter(|i| { + // We filter these to avoid misleading wording in cases like the following, + // where `x` has an `init`, but it is in the same place we're looking at: + // ``` + // let x; + // x += 1; + // ``` + !i.contains(span) // We filter these to avoid incorrect main message on `match-cfg-fake-edges.rs` && !visitor .errors .iter() .map(|(sp, _)| *sp) .any(|sp| span < sp && !sp.contains(span)) - }) - .count() - == 0 - { - "isn't initialized" - } else { - "is possibly-uninitialized" - }; + }) + .count() + == 0 + { + "isn't initialized" + } else { + "is possibly-uninitialized" + }; let used = desired_action.as_general_verb_in_past_tense(); let mut err = |
