Skip to content

Commit

Permalink
Auto merge of #3805 - martinsp:ice-3747, r=Manishearth
Browse files Browse the repository at this point in the history
Fix ICE #3747

I'm not sure if this was the correct approach.

I don't know if I put tests/ui/crashses/ice-3747.rs in correct place because the test always passed when I ran it with `cargo test`, even without the fix applied.

If I run that test with `env CLIPPY_TESTS=true cargo run --bin clippy-driver -- -L ./target/debug tests/ui/crashes/ice-3747.rs` then the test correctly fails without the fix applied

fixes #3747
  • Loading branch information
bors committed Feb 25, 2019
2 parents 1233b39 + 391ee79 commit cd29740
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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) {
Expand Down Expand Up @@ -183,12 +183,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() {}

0 comments on commit cd29740

Please sign in to comment.