]> git.lizzy.rs Git - rust.git/blobdiff - src/mut_mut.rs
moved in_macro to (new) utils.rs
[rust.git] / src / mut_mut.rs
index 3ba9c47e7fe91a391c025b7fdcf7f02d337cdc1e..202b5600dbe46008ca67d9404cfc018b769cd15c 100644 (file)
@@ -3,6 +3,7 @@
 use rustc::lint::{Context, LintPass, LintArray, Lint};
 use rustc::middle::ty::{expr_ty, sty, ty_ptr, ty_rptr, mt};
 use syntax::codemap::{BytePos, ExpnInfo, MacroFormat, Span};
+use utils::in_macro;
 
 declare_lint!(pub MUT_MUT, Warn,
               "Warn on usage of double-mut refs, e.g. '&mut &mut ...'");
@@ -51,16 +52,6 @@ fn unwrap_addr(expr : &Expr) -> Option<&Expr> {
        })
 }
 
-pub fn in_macro(cx: &Context, opt_info: Option<&ExpnInfo>) -> bool {
-       opt_info.map_or(false, |info| {
-               info.callee.span.map_or(true, |span| {
-                       cx.sess().codemap().span_to_snippet(span).ok().map_or(true, |code| 
-                               !code.starts_with("macro_rules")
-                       )
-               })
-       })
-}
-
 fn unwrap_mut(ty : &Ty) -> Option<&Ty> {
        match ty.node {
                TyPtr(MutTy{ ty: ref pty, mutbl: MutMutable }) => Option::Some(pty),