[Martins Polakovs, John Firebaugh]
This commit is contained in:
Martins Polakovs 2019-02-23 19:29:30 +02:00 committed by Manish Goregaokar
parent 1fac380886
commit 5d7c24f9b7
2 changed files with 20 additions and 3 deletions

View file

@ -150,7 +150,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
let nodeid = cx.tcx.hir().hir_to_node_id(hir_id);
self.check_raw_ptr(cx, unsafety, decl, body, nodeid);
self.check_line_number(cx, span);
self.check_line_number(cx, span, body);
}
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
@ -181,12 +181,12 @@ impl<'a, 'tcx> Functions {
}
}
fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span) {
fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span, body: &'tcx hir::Body) {
if in_external_macro(cx.sess(), span) {
return;
}
let code_snippet = snippet(cx, span, "..");
let code_snippet = snippet(cx, body.value.span, "..");
let mut line_count: u64 = 0;
let mut in_comment = false;
let mut code_in_line;

View file

@ -0,0 +1,17 @@
/// Test for https://github.com/rust-lang/rust-clippy/issues/3747
macro_rules! a {
( $pub:tt $($attr:tt)* ) => {
$($attr)* $pub fn say_hello() {}
};
}
macro_rules! b {
() => {
a! { pub }
};
}
b! {}
fn main() {}