Skip to content

Commit cd29740

Browse files
committed
Auto merge of #3805 - martinsp:ice-3747, r=Manishearth
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
2 parents 1233b39 + 391ee79 commit cd29740

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

clippy_lints/src/functions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
152152

153153
let nodeid = cx.tcx.hir().hir_to_node_id(hir_id);
154154
self.check_raw_ptr(cx, unsafety, decl, body, nodeid);
155-
self.check_line_number(cx, span);
155+
self.check_line_number(cx, span, body);
156156
}
157157

158158
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
@@ -183,12 +183,12 @@ impl<'a, 'tcx> Functions {
183183
}
184184
}
185185

186-
fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span) {
186+
fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span, body: &'tcx hir::Body) {
187187
if in_external_macro(cx.sess(), span) {
188188
return;
189189
}
190190

191-
let code_snippet = snippet(cx, span, "..");
191+
let code_snippet = snippet(cx, body.value.span, "..");
192192
let mut line_count: u64 = 0;
193193
let mut in_comment = false;
194194
let mut code_in_line;

tests/ui/crashes/ice-3747.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// Test for https://github.com/rust-lang/rust-clippy/issues/3747
2+
3+
macro_rules! a {
4+
( $pub:tt $($attr:tt)* ) => {
5+
$($attr)* $pub fn say_hello() {}
6+
};
7+
}
8+
9+
macro_rules! b {
10+
() => {
11+
a! { pub }
12+
};
13+
}
14+
15+
b! {}
16+
17+
fn main() {}

0 commit comments

Comments
 (0)