diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-22 13:36:56 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2020-03-30 10:52:29 +0200 |
| commit | 9bba047c2e425fce03b039bcb8ccd60ddcbc80a0 (patch) | |
| tree | 955fb13c65c6a29f4ad8535485f91c2c77b7233b /src/librustc_mir/dataflow | |
| parent | 8926bb497d9b127eb318aea5aed0e745d8381591 (diff) | |
| download | rust-9bba047c2e425fce03b039bcb8ccd60ddcbc80a0.tar.gz rust-9bba047c2e425fce03b039bcb8ccd60ddcbc80a0.zip | |
Use if let instead of match when only matching a single variant (clippy::single_match)
Makes code more compact and reduces nestig.
Diffstat (limited to 'src/librustc_mir/dataflow')
| -rw-r--r-- | src/librustc_mir/dataflow/framework/graphviz.rs | 36 | ||||
| -rw-r--r-- | src/librustc_mir/dataflow/impls/mod.rs | 21 | ||||
| -rw-r--r-- | src/librustc_mir/dataflow/move_paths/builder.rs | 9 |
3 files changed, 30 insertions, 36 deletions
diff --git a/src/librustc_mir/dataflow/framework/graphviz.rs b/src/librustc_mir/dataflow/framework/graphviz.rs index a85c428d3bf..bdd41121359 100644 --- a/src/librustc_mir/dataflow/framework/graphviz.rs +++ b/src/librustc_mir/dataflow/framework/graphviz.rs @@ -229,26 +229,22 @@ where } // Write any changes caused by terminator-specific effects - match terminator.kind { - mir::TerminatorKind::Call { destination: Some(_), .. } => { - let num_state_columns = self.num_state_columns(); - self.write_row(w, "", "(on successful return)", |this, w, fmt| { - write!( - w, - r#"<td balign="left" colspan="{colspan}" {fmt} align="left">"#, - colspan = num_state_columns, - fmt = fmt, - )?; - - let state_on_unwind = this.results.get().clone(); - this.results.seek_after_assume_success(terminator_loc); - write_diff(w, this.results.analysis(), &state_on_unwind, this.results.get())?; - - write!(w, "</td>") - })?; - } - - _ => {} + if let mir::TerminatorKind::Call { destination: Some(_), .. } = terminator.kind { + let num_state_columns = self.num_state_columns(); + self.write_row(w, "", "(on successful return)", |this, w, fmt| { + write!( + w, + r#"<td balign="left" colspan="{colspan}" {fmt} align="left">"#, + colspan = num_state_columns, + fmt = fmt, + )?; + + let state_on_unwind = this.results.get().clone(); + this.results.seek_after_assume_success(terminator_loc); + write_diff(w, this.results.analysis(), &state_on_unwind, this.results.get())?; + + write!(w, "</td>") + })?; }; write!(w, "</table>") diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 3572d460274..3ffa771cb05 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -544,18 +544,15 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> { ); trans.gen_all(init_loc_map[location].iter().copied()); - match stmt.kind { - mir::StatementKind::StorageDead(local) => { - // End inits for StorageDead, so that an immutable variable can - // be reinitialized on the next iteration of the loop. - let move_path_index = rev_lookup.find_local(local); - debug!( - "stmt {:?} at loc {:?} clears the ever initialized status of {:?}", - stmt, location, &init_path_map[move_path_index] - ); - trans.kill_all(init_path_map[move_path_index].iter().copied()); - } - _ => {} + if let mir::StatementKind::StorageDead(local) = stmt.kind { + // End inits for StorageDead, so that an immutable variable can + // be reinitialized on the next iteration of the loop. + let move_path_index = rev_lookup.find_local(local); + debug!( + "stmt {:?} at loc {:?} clears the ever initialized status of {:?}", + stmt, location, &init_path_map[move_path_index] + ); + trans.kill_all(init_path_map[move_path_index].iter().copied()); } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 6918d165a2b..1f4455318a4 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -144,15 +144,16 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { }, )); } - ty::Array(..) => match elem { - ProjectionElem::Index(..) => { + + ty::Array(..) => { + if let ProjectionElem::Index(..) = elem { return Err(MoveError::cannot_move_out_of( self.loc, InteriorOfSliceOrArray { ty: place_ty, is_index: true }, )); } - _ => {} - }, + } + _ => {} }; |
