]>
git.proxmox.com Git - rustc.git/blob - src/librustc_mir/transform/no_landing_pads.rs
1 //! This pass removes the unwind branch of all the terminators when the no-landing-pads option is
4 use crate::transform
::{MirPass, MirSource}
;
5 use rustc_middle
::mir
::visit
::MutVisitor
;
6 use rustc_middle
::mir
::*;
7 use rustc_middle
::ty
::TyCtxt
;
9 pub struct NoLandingPads
<'tcx
> {
13 impl<'tcx
> NoLandingPads
<'tcx
> {
14 pub fn new(tcx
: TyCtxt
<'tcx
>) -> Self {
19 impl<'tcx
> MirPass
<'tcx
> for NoLandingPads
<'tcx
> {
20 fn run_pass(&self, tcx
: TyCtxt
<'tcx
>, _
: MirSource
<'tcx
>, body
: &mut BodyAndCache
<'tcx
>) {
21 no_landing_pads(tcx
, body
)
25 pub fn no_landing_pads
<'tcx
>(tcx
: TyCtxt
<'tcx
>, body
: &mut BodyAndCache
<'tcx
>) {
26 if tcx
.sess
.no_landing_pads() {
27 NoLandingPads
::new(tcx
).visit_body(body
);
31 impl<'tcx
> MutVisitor
<'tcx
> for NoLandingPads
<'tcx
> {
32 fn tcx(&self) -> TyCtxt
<'tcx
> {
36 fn visit_terminator_kind(&mut self, kind
: &mut TerminatorKind
<'tcx
>, location
: Location
) {
37 if let Some(unwind
) = kind
.unwind_mut() {
40 self.super_terminator_kind(kind
, location
);