]> git.lizzy.rs Git - rust.git/commitdiff
don't depend on regex_macros anymore
authorOliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Sat, 25 Jun 2016 16:12:29 +0000 (18:12 +0200)
committerOliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Sat, 25 Jun 2016 16:12:29 +0000 (18:12 +0200)
.travis.yml
Cargo.toml
mini-macro/Cargo.toml [new file with mode: 0644]
mini-macro/src/lib.rs [new file with mode: 0644]
tests/compile-fail-regex_macros/regex.rs [deleted file]
tests/compile-test.rs
tests/run-pass-regex_macros/mut_mut_macro.rs [deleted file]
tests/run-pass/procedural_macro.rs [new file with mode: 0644]

index d33f8604bcfdcece4aca846f7f1c6d42ecb77019..34e50956cc56b8b1a4d912866bd384c4f4a465c7 100644 (file)
@@ -26,13 +26,6 @@ script:
  - 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
index d3e67bdb7e1b5a0dd1a939e35517251421d442fc..9b68a7364ff1804488e13718211a58915d98f3d9 100644 (file)
@@ -24,7 +24,6 @@ name = "cargo-clippy"
 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
@@ -32,9 +31,10 @@ clippy_lints = { version = "0.0.77", path = "clippy_lints" }
 [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"]
diff --git a/mini-macro/Cargo.toml b/mini-macro/Cargo.toml
new file mode 100644 (file)
index 0000000..171e5dd
--- /dev/null
@@ -0,0 +1,16 @@
+[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]
diff --git a/mini-macro/src/lib.rs b/mini-macro/src/lib.rs
new file mode 100644 (file)
index 0000000..699d17d
--- /dev/null
@@ -0,0 +1,22 @@
+#![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);
+}
diff --git a/tests/compile-fail-regex_macros/regex.rs b/tests/compile-fail-regex_macros/regex.rs
deleted file mode 100644 (file)
index aab196f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#![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!(_)`
-}
index 2e50f7d92415a2aded7c4897f3ad3e27a5eefb5c..d21d97509241f24c4b225c486ee30dc3b5e26736 100644 (file)
@@ -1,7 +1,7 @@
 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();
@@ -14,10 +14,6 @@ fn run_mode(dir: &'static str, mode: &'static str) {
     }
 
     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);
@@ -28,17 +24,8 @@ fn prepare_env() {
 }
 
 #[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");
-}
diff --git a/tests/run-pass-regex_macros/mut_mut_macro.rs b/tests/run-pass-regex_macros/mut_mut_macro.rs
deleted file mode 100644 (file)
index 92b44db..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#![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"));
-}
diff --git a/tests/run-pass/procedural_macro.rs b/tests/run-pass/procedural_macro.rs
new file mode 100644 (file)
index 0000000..68d86a4
--- /dev/null
@@ -0,0 +1,7 @@
+#![feature(plugin)]
+#![plugin(clippy, mini_macro)]
+
+#[deny(warnings)]
+fn main() {
+    let _ = mini_macro!();
+}