1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 #![feature(plugin_registrar, rustc_private)]
14 #![feature(box_syntax)]
16 #[macro_use] extern crate rustc;
17 extern crate rustc_plugin;
18 extern crate rustc_const_math;
21 use rustc::mir::transform::{self, MirPass, MirSource};
22 use rustc::mir::repr::{Mir, Literal, Location};
23 use rustc::mir::visit::MutVisitor;
24 use rustc::ty::TyCtxt;
25 use rustc::middle::const_val::ConstVal;
26 use rustc_const_math::ConstInt;
27 use rustc_plugin::Registry;
31 impl transform::Pass for Pass {}
33 impl<'tcx> MirPass<'tcx> for Pass {
34 fn run_pass<'a>(&mut self, _: TyCtxt<'a, 'tcx, 'tcx>,
35 _: MirSource, mir: &mut Mir<'tcx>) {
36 Visitor.visit_mir(mir)
42 impl<'tcx> MutVisitor<'tcx> for Visitor {
43 fn visit_literal(&mut self, literal: &mut Literal<'tcx>, _: Location) {
44 if let Literal::Value { ref mut value } = *literal {
45 if let ConstVal::Integral(ConstInt::I32(ref mut i @ 11)) = *value {
53 pub fn plugin_registrar(reg: &mut Registry) {
54 reg.register_mir_pass(box Pass);