Remove ability for plugins to register a MIR pass
In recent months there have been a few different people investigating how to make a plugin that registers a MIR-pass – one that isn’t intended to be eventually merged into rustc proper. The interface to register MIR passes was added primarily for miri (& later was found to make prototyping of rustc-proper MIR passes a tiny bit faster). Since miri does not use this interface anymore it seems like a good time to remove this "feature". For prototyping purposes a similar interface can be added by developers themselves in their custom rustc build.
This commit is contained in:
parent
f573db4f80
commit
4ca9c97ace
@ -604,7 +604,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
|
||||
|
||||
let whitelisted_legacy_custom_derives = registry.take_whitelisted_custom_derives();
|
||||
let Registry { syntax_exts, early_lint_passes, late_lint_passes, lint_groups,
|
||||
llvm_passes, attributes, mir_passes, .. } = registry;
|
||||
llvm_passes, attributes, .. } = registry;
|
||||
|
||||
sess.track_errors(|| {
|
||||
let mut ls = sess.lint_store.borrow_mut();
|
||||
@ -620,7 +620,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
|
||||
}
|
||||
|
||||
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
|
||||
sess.mir_passes.borrow_mut().extend(mir_passes);
|
||||
*sess.plugin_attributes.borrow_mut() = attributes.clone();
|
||||
})?;
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
|
||||
use rustc::session::Session;
|
||||
|
||||
use rustc::mir::transform::MirMapPass;
|
||||
|
||||
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT, IdentTT};
|
||||
use syntax::ext::base::MacroExpanderFn;
|
||||
use syntax::symbol::Symbol;
|
||||
@ -53,9 +51,6 @@ pub struct Registry<'a> {
|
||||
#[doc(hidden)]
|
||||
pub late_lint_passes: Vec<LateLintPassObject>,
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mir_passes: Vec<Box<for<'pcx> MirMapPass<'pcx>>>,
|
||||
|
||||
#[doc(hidden)]
|
||||
pub lint_groups: HashMap<&'static str, Vec<LintId>>,
|
||||
|
||||
@ -81,7 +76,6 @@ pub fn new(sess: &'a Session, krate_span: Span) -> Registry<'a> {
|
||||
lint_groups: HashMap::new(),
|
||||
llvm_passes: vec![],
|
||||
attributes: vec![],
|
||||
mir_passes: Vec::new(),
|
||||
whitelisted_custom_derives: Vec::new(),
|
||||
}
|
||||
}
|
||||
@ -157,11 +151,6 @@ pub fn register_lint_group(&mut self, name: &'static str, to: Vec<&'static Lint>
|
||||
self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect());
|
||||
}
|
||||
|
||||
/// Register a MIR pass
|
||||
pub fn register_mir_pass(&mut self, pass: Box<for<'pcx> MirMapPass<'pcx>>) {
|
||||
self.mir_passes.push(pass);
|
||||
}
|
||||
|
||||
/// Register an LLVM pass.
|
||||
///
|
||||
/// Registration with LLVM itself is handled through static C++ objects with
|
||||
|
@ -1,55 +0,0 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// force-host
|
||||
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
extern crate rustc_const_math;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc::mir::transform::{self, MirPass, MirSource};
|
||||
use rustc::mir::{Mir, Literal, Location};
|
||||
use rustc::mir::visit::MutVisitor;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc_const_math::ConstInt;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
struct Pass;
|
||||
|
||||
impl transform::Pass for Pass {}
|
||||
|
||||
impl<'tcx> MirPass<'tcx> for Pass {
|
||||
fn run_pass<'a>(&mut self, _: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_: MirSource, mir: &mut Mir<'tcx>) {
|
||||
Visitor.visit_mir(mir)
|
||||
}
|
||||
}
|
||||
|
||||
struct Visitor;
|
||||
|
||||
impl<'tcx> MutVisitor<'tcx> for Visitor {
|
||||
fn visit_literal(&mut self, literal: &mut Literal<'tcx>, _: Location) {
|
||||
if let Literal::Value { ref mut value } = *literal {
|
||||
if let ConstVal::Integral(ConstInt::I32(ref mut i @ 11)) = *value {
|
||||
*i = 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_mir_pass(box Pass);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:dummy_mir_pass.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(dummy_mir_pass)]
|
||||
|
||||
fn math() -> i32 {
|
||||
11
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(math(), 42);
|
||||
}
|
Loading…
Reference in New Issue
Block a user