]> git.lizzy.rs Git - rust.git/commitdiff
made macro test even simpler, added a few tests
authorllogiq <bogusandre@gmail.com>
Mon, 25 May 2015 23:45:15 +0000 (01:45 +0200)
committerllogiq <bogusandre@gmail.com>
Mon, 25 May 2015 23:45:15 +0000 (01:45 +0200)
Cargo.toml
src/lib.rs
src/mut_mut.rs
src/ptr_arg.rs
tests/compile-fail/mut_mut.rs
tests/compile-test.rs
tests/run-pass.rs [new file with mode: 0644]

index 95de98e8ee5bf916309e9a53851f0ecbb7ea6771..3c7d9be64e36a894ef253e94b2ea82da1fea3089 100644 (file)
@@ -17,3 +17,5 @@ plugin = true
 
 [dev-dependencies]
 compiletest_rs = "*"
+regex = "*"
+regex_macros = "*"
index cf5def800a271ae177a3fa873ef9622bc35396f4..92cc7ef254cc7998121178e2ac0506274cb0d679 100644 (file)
@@ -1,6 +1,5 @@
 #![feature(plugin_registrar, box_syntax)]
 #![feature(rustc_private, collections)]
-
 #![allow(unused_imports)]
 
 #[macro_use]
index b1e21def574678b3d6232d0cbaa694b633c590d1..160b99a1d1510aef5d9d2d972ba00cddc6c6fbdb 100644 (file)
@@ -27,7 +27,7 @@ fn check_ty(&mut self, cx: &Context, ty: &Ty) {
 }
 
 fn check_expr_expd(cx: &Context, expr: &Expr, info: Option<&ExpnInfo>) {
-       if in_external_macro(info) { return; }
+       if in_macro(info) { return; }
 
        fn unwrap_addr(expr : &Expr) -> Option<&Expr> {
                match expr.node {
@@ -51,8 +51,8 @@ fn unwrap_addr(expr : &Expr) -> Option<&Expr> {
        })
 }
 
-fn in_external_macro(info: Option<&ExpnInfo>) -> bool {
-       info.map_or(false, |i| i.callee.span.is_some())
+fn in_macro(info: Option<&ExpnInfo>) -> bool {
+       info.is_some()
 }
 
 fn unwrap_mut(ty : &Ty) -> Option<&Ty> {
index 86b87a942be1a4cf3fd587dc3caf36bb45666e6a..64c3c84c7b6e9eea5b86d3c98272b206f0015d48 100644 (file)
@@ -27,7 +27,7 @@ fn get_lints(&self) -> LintArray {
     }
     
     fn check_item(&mut self, cx: &Context, item: &Item) {
-               if let &ItemFn(ref decl, _, _, _, _) = &item.node {
+               if let &ItemFn(ref decl, _, _, _, _, _) = &item.node {
                        check_fn(cx, decl);
                }
        }
index 65e3762e2c4025577c1a60b4e18aac2e6581ad3a..d7adc067740f4c7abddf6429e164c18df3309d56 100644 (file)
@@ -1,11 +1,18 @@
 #![feature(plugin)]
 #![plugin(clippy)]
 
+//#![plugin(regex_macros)]
+//extern crate regex;
+
 #[deny(mut_mut)]
 fn fun(x : &mut &mut u32) -> bool { //~ERROR
        **x > 0
 }
 
+macro_rules! mut_ptr {
+       ($p:expr) => { &mut $p }
+} 
+
 #[deny(mut_mut)]
 #[allow(unused_mut, unused_variables)]
 fn main() {
@@ -22,4 +29,6 @@ fn main() {
                                                                           //~^^^^ ERROR
                ***y + **x;
        }
+       
+       let mut z = mut_ptr!(&mut 3u32); //~ERROR
 }
index 04f3fc16b1b69e8ca8a7054852ebd3b46fef420e..6fcf71d38ad2996efed6ca2a7ecdc5ef4eeb75d1 100644 (file)
@@ -5,7 +5,7 @@
 fn run_mode(mode: &'static str) {
     let mut config = compiletest::default_config();
     let cfg_mode = mode.parse().ok().expect("Invalid mode");
-    config.target_rustcflags = Some("-L target/debug/".to_string());
+    config.target_rustcflags = Some("-l regex_macros -L target/debug/".to_string());
 
     config.mode = cfg_mode;
     config.src_base = PathBuf::from(format!("tests/{}", mode));
diff --git a/tests/run-pass.rs b/tests/run-pass.rs
new file mode 100644 (file)
index 0000000..bc39278
--- /dev/null
@@ -0,0 +1,11 @@
+#![feature(plugin)]
+#![plugin(clippy, regex_macros)]
+
+extern crate regex;
+
+#[test]
+#[deny(mut_mut)]
+fn test_regex() {
+       let pattern = regex!(r"^(?P<level>[#]+)\s(?P<title>.+)$");
+       assert!(pattern.is_match("# headline"));
+}