about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-26 16:30:42 +0000
committerbors <bors@rust-lang.org>2021-11-26 16:30:42 +0000
commit6d246f0c8d3063fea86abbb65a824362709541ba (patch)
tree89367aa9a510b1c1dec9bd2151cf00c9182222f9 /compiler/rustc_borrowck/src
parent454cc5fb86be180b3ec1138b6f2b480fbf3f1388 (diff)
parenta9710deebcfc0d24ea7b3510c9afa6afb40d2ae1 (diff)
downloadrust-6d246f0c8d3063fea86abbb65a824362709541ba.tar.gz
rust-6d246f0c8d3063fea86abbb65a824362709541ba.zip
Auto merge of #91253 - matthiaskrgr:rollup-dnlcjmr, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #91169 (Change cg_ssa's get_param to borrow the builder mutably)
 - #91176 (If the thread does not get the lock in the short term, yield the CPU)
 - #91212 (Fix ICE due to out-of-bounds statement index when reporting borrowck error)
 - #91225 (Fix invalid scrollbar display on source code page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs24
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()) {