Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICE #3747 #3805

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}

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) {
Expand Down Expand Up @@ -178,12 +178,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;
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/crashes/ice-3747.rs
Original file line number Diff line number Diff line change
@@ -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() {}