moved in_macro to (new) utils.rs

This commit is contained in:
llogiq
2015-06-01 22:30:34 +02:00
parent 1ee2e4ffe8
commit 30de91d3e9
4 changed files with 15 additions and 12 deletions

12
src/utils.rs Normal file
View File

@@ -0,0 +1,12 @@
use rustc::lint::Context;
use syntax::codemap::ExpnInfo;
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")
)
})
})
}