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 ...'");
})
}
-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),