]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/plugin/registry.rs
auto merge of #15421 : catharsis/rust/doc-ffi-minor-fixes, r=alexcrichton
[rust.git] / src / librustc / plugin / registry.rs
index f6e37822325a8227c027c4281b6653a56a1d3af6..2581ba51c2e107b1830a6a5fda3b82b971eda11c 100644 (file)
 
 //! Used by plugin crates to tell `rustc` about the plugins they provide.
 
+use lint::LintPassObject;
+
 use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT};
-use syntax::ext::base::{IdentTT, ItemDecorator, ItemModifier, BasicMacroExpander};
+use syntax::ext::base::{IdentTT, LetSyntaxTT, ItemDecorator, ItemModifier, BasicMacroExpander};
 use syntax::ext::base::{MacroExpanderFn};
 use syntax::codemap::Span;
 use syntax::parse::token;
@@ -31,6 +33,9 @@ pub struct Registry {
 
     #[doc(hidden)]
     pub syntax_exts: Vec<NamedSyntaxExtension>,
+
+    #[doc(hidden)]
+    pub lint_passes: Vec<LintPassObject>,
 }
 
 impl Registry {
@@ -39,6 +44,7 @@ pub fn new(krate: &ast::Crate) -> Registry {
         Registry {
             krate_span: krate.span,
             syntax_exts: vec!(),
+            lint_passes: vec!(),
         }
     }
 
@@ -51,6 +57,8 @@ pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxEx
             IdentTT(ext, _) => IdentTT(ext, Some(self.krate_span)),
             ItemDecorator(ext) => ItemDecorator(ext),
             ItemModifier(ext) => ItemModifier(ext),
+            // there's probably a nicer way to signal this:
+            LetSyntaxTT(_, _) => fail!("can't register a new LetSyntax!"),
         }));
     }
 
@@ -67,4 +75,9 @@ pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) {
                 span: None,
             }, None));
     }
+
+    /// Register a compiler lint pass.
+    pub fn register_lint_pass(&mut self, lint_pass: LintPassObject) {
+        self.lint_passes.push(lint_pass);
+    }
 }