- cd clippy_lints && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ..
after_success:
-# only test regex_macros if it compiles
-- |
- #!/bin/bash
- cargo test --no-run --features 'debugging test-regex_macros'
- if [ "$?" != 101 ]; then
- cargo test --features 'debugging test-regex_macros' compile_test
- fi
# trigger rebuild of the clippy-service, to keep it up to date with clippy itself
- |
#!/bin/bash
test = false
[dependencies]
-regex_macros = { version = "0.1.33", optional = true }
# begin automatic update
clippy_lints = { version = "0.0.77", path = "clippy_lints" }
# end automatic update
[dev-dependencies]
compiletest_rs = "0.2.0"
lazy_static = "0.1.15"
-regex = "0.1.56"
+regex = "0.1.71"
rustc-serialize = "0.3"
+mini-macro = { version = "0.1", path = "mini-macro" }
+
[features]
debugging = []
-test-regex_macros = ["regex_macros"]
--- /dev/null
+[package]
+name = "mini-macro"
+version = "0.1.0"
+authors = [
+ "Manish Goregaokar <manishsmail@gmail.com>",
+ "Andre Bogus <bogusandre@gmail.com>",
+ "Georg Brandl <georg@python.org>",
+ "Martin Carton <cartonmartin@gmail.com>",
+ "Oliver Schneider <clippy-iethah7aipeen8neex1a@oli-obk.de>"
+]
+
+[lib]
+name = "mini_macro"
+plugin = true
+
+[dependencies]
--- /dev/null
+#![feature(plugin_registrar, rustc_private)]
+
+extern crate syntax;
+extern crate rustc;
+extern crate rustc_plugin;
+
+use syntax::codemap::Span;
+use syntax::ast::TokenTree;
+use syntax::ext::base::{ExtCtxt, MacResult, MacEager};
+use syntax::ext::build::AstBuilder; // trait for expr_usize
+use rustc_plugin::Registry;
+
+fn expand_macro(cx: &mut ExtCtxt, sp: Span, _: &[TokenTree]) -> Box<MacResult + 'static> {
+ let e = cx.expr_usize(sp, 42);
+ let e = cx.expr_mut_addr_of(sp, e);
+ MacEager::expr(cx.expr_mut_addr_of(sp, e))
+}
+
+#[plugin_registrar]
+pub fn plugin_registrar(reg: &mut Registry) {
+ reg.register_macro("mini_macro", expand_macro);
+}
+++ /dev/null
-#![feature(plugin)]
-#![plugin(clippy, regex_macros)]
-
-#![allow(unused)]
-#![deny(invalid_regex, trivial_regex, regex_macro)]
-
-extern crate regex;
-
-fn main() {
- let some_regex = regex!("for real!"); //~ERROR `regex!(_)`
- let other_regex = regex!("[a-z]_[A-Z]"); //~ERROR `regex!(_)`
-}
extern crate compiletest_rs as compiletest;
use std::path::PathBuf;
-use std::env::{set_var, var, temp_dir};
+use std::env::{set_var, var};
fn run_mode(dir: &'static str, mode: &'static str) {
let mut config = compiletest::default_config();
}
config.mode = cfg_mode;
- if cfg!(windows) {
- // work around https://github.com/laumann/compiletest-rs/issues/35 on msvc windows
- config.build_base = temp_dir();
- }
config.src_base = PathBuf::from(format!("tests/{}", dir));
compiletest::run_tests(&config);
}
#[test]
-#[cfg(not(feature = "test-regex_macros"))]
fn compile_test() {
prepare_env();
run_mode("run-pass", "run-pass");
run_mode("compile-fail", "compile-fail");
}
-
-#[test]
-#[cfg(feature = "test-regex_macros")]
-fn compile_test() {
- prepare_env();
- run_mode("run-pass-regex_macros", "run-pass");
- run_mode("compile-fail-regex_macros", "compile-fail");
-}
+++ /dev/null
-#![feature(plugin)]
-#![plugin(clippy, regex_macros)]
-
-#[macro_use]
-extern crate regex;
-
-#[deny(mut_mut)]
-#[allow(regex_macro)]
-fn main() {
- let pattern = regex!(r"^(?P<level>[#]+)\s(?P<title>.+)$");
- assert!(pattern.is_match("# headline"));
-}
--- /dev/null
+#![feature(plugin)]
+#![plugin(clippy, mini_macro)]
+
+#[deny(warnings)]
+fn main() {
+ let _ = mini_macro!();
+}