diff options
| author | Michael Goulet <michael@errs.io> | 2021-11-25 06:48:09 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2021-11-25 16:34:30 +0000 |
| commit | 718a3b1f2d59943c90cd02b9d0b90b315e003ec0 (patch) | |
| tree | f75cb657a00fa54e48e5a901846de70585a7d525 | |
| parent | 862962b90e59c5c1e217df74de80d3a81eee42f4 (diff) | |
| download | rust-718a3b1f2d59943c90cd02b9d0b90b315e003ec0.tar.gz rust-718a3b1f2d59943c90cd02b9d0b90b315e003ec0.zip | |
Fix issue 91206
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 46e2a99a0d0..a0f8aabbe0e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -447,16 +447,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // check if the RHS is from desugaring let opt_assignment_rhs_span = self.body.find_assignments(local).first().map(|&location| { - let stmt = &self.body[location.block].statements - [location.statement_index]; - match stmt.kind { - mir::StatementKind::Assign(box ( - _, - mir::Rvalue::Use(mir::Operand::Copy(place)), - )) => { - self.body.local_decls[place.local].source_info.span - } - _ => self.body.source_info(location).span, + if let Some(mir::Statement { + source_info: _, + kind: + mir::StatementKind::Assign(box ( + _, + mir::Rvalue::Use(mir::Operand::Copy(place)), + )), + }) = self.body[location.block] + .statements + .get(location.statement_index) + { + self.body.local_decls[place.local].source_info.span + } else { + self.body.source_info(location).span } }); match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) { |
