[dev-dependencies]
compiletest_rs = "*"
+regex = "*"
+regex_macros = "*"
#![feature(plugin_registrar, box_syntax)]
#![feature(rustc_private, collections)]
-
#![allow(unused_imports)]
#[macro_use]
}
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 {
})
}
-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> {
}
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);
}
}
#![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() {
//~^^^^ ERROR
***y + **x;
}
+
+ let mut z = mut_ptr!(&mut 3u32); //~ERROR
}
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));
--- /dev/null
+#![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"));
+}