diff options
| author | bors <bors@rust-lang.org> | 2023-02-22 12:04:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-22 12:04:45 +0000 |
| commit | 3b4d6e080404560f63599deeb328dfa27fe081a6 (patch) | |
| tree | 0404fed1412000d50e1807cda997649437aa7220 /compiler/rustc_mir_transform/src | |
| parent | bd4a96a12d0bf6dc12edf20a45df3a33052c9d7d (diff) | |
| parent | 0d0de4971e2b134549f5e8019cbc06dadc5596ca (diff) | |
| download | rust-3b4d6e080404560f63599deeb328dfa27fe081a6.tar.gz rust-3b4d6e080404560f63599deeb328dfa27fe081a6.zip | |
Auto merge of #108339 - GuillaumeGomez:rollup-4z02kas, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #108110 (Move some `InferCtxt` methods to `EvalCtxt` in new solver) - #108168 (Fix ICE on type alias in recursion) - #108230 (Convert a hard-warning about named static lifetimes into lint "unused_lifetimes") - #108239 (Fix overlapping spans in removing extra arguments) - #108246 (Add an InstCombine for redundant casts) - #108264 (no-fail-fast support for tool testsuites) - #108310 (rustdoc: Fix duplicated attributes for first reexport) - #108318 (Remove unused FileDesc::get_cloexec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/instcombine.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/instcombine.rs b/compiler/rustc_mir_transform/src/instcombine.rs index 0534e688703..3896f0e57ea 100644 --- a/compiler/rustc_mir_transform/src/instcombine.rs +++ b/compiler/rustc_mir_transform/src/instcombine.rs @@ -30,6 +30,7 @@ impl<'tcx> MirPass<'tcx> for InstCombine { ctx.combine_bool_cmp(&statement.source_info, rvalue); ctx.combine_ref_deref(&statement.source_info, rvalue); ctx.combine_len(&statement.source_info, rvalue); + ctx.combine_cast(&statement.source_info, rvalue); } _ => {} } @@ -142,6 +143,14 @@ impl<'tcx> InstCombineContext<'tcx, '_> { } } + fn combine_cast(&self, _source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { + if let Rvalue::Cast(_kind, operand, ty) = rvalue { + if operand.ty(self.local_decls, self.tcx) == *ty { + *rvalue = Rvalue::Use(operand.clone()); + } + } + } + fn combine_primitive_clone( &self, terminator: &mut Terminator<'tcx>, |
