clippy @ 78860a71d85f87d6a5ab55d4f24e7d09b412cf86
git clone https://github.com/m4b/goblin
cd goblin
RUST_BACKTRACE=full ~/vcs/github/rust-clippy/target/debug/cargo-clippy --all-targets --all-features -vvvv -- --cap-lints warn
```
warning: the loop variableiis only used to index__tmp.
--> src/mach/load_command.rs:33:45
|
33 | #[derive(Debug, Clone, Copy, Pread, Pwrite, IOread, IOwrite, SizeWith)]
| ^^^^^^
|
= note: #[warn(clippy::needless_range_loop)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_range_loop
thread 'main' panicked at 'begin <= end (50 <= 44) when slicing#[derive(Debug, Clone, Copy, Pread, Pwrite, IOread, IOwrite, SizeWith)]`', libcore/str/mod.rs:2098:5
stack backtrace:
0: 0x7ff53ef3081f - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h6a694a6fa8ba17f1
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: 0x7ff53ef15af7 - std::sys_common::backtrace::print::h6098d2174773bf24
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: 0x7ff53ef3bd8f - std::panicking::default_hook::{{closure}}::h6a369d41f0b59dc6
at libstd/panicking.rs:211
3: 0x7ff53ef3baf4 - std::panicking::default_hook::h69e096c824399f0d
at libstd/panicking.rs:227
4: 0x7ff540f56ba1 - rustc::util::common::panic_hook::h954559df59c3b99d
5: 0x7ff53ef3c586 - std::panicking::rust_panic_with_hook::h6a769c870f26d7a5
at libstd/panicking.rs:480
6: 0x7ff53ef3c0d1 - std::panicking::continue_panic_fmt::h1e76a7a6894fe14c
at libstd/panicking.rs:390
7: 0x7ff53ef3bfb5 - rust_begin_unwind
at libstd/panicking.rs:325
8: 0x7ff53ef9de6c - core::panicking::panic_fmt::he6745b6f5d7fdc6a
at libcore/panicking.rs:77
9: 0x7ff53ef88cd1 - core::str::slice_error_fail::hf18e3c072f612c55
at libcore/str/mod.rs:0
10: 0x7ff53fd799b1 - core::str::traits::
11: 0x7ff53fd7a0c9 - rustc_errors::CodeSuggestion::splice_lines::push_trailing::h7312af60c8a7b34e
12: 0x7ff53fd5f3f5 -
13: 0x7ff53fd6d325 -
14: 0x7ff53fd53094 -
15: 0x7ff53fd7cb43 - rustc_errors::Handler::emit_db::h115eb14c816948d7
16: 0x7ff53fd68987 - rustc_errors::diagnostic_builder::DiagnosticBuilder::emit::ha4a7047a8b407aa9
17: 0x56455233435e -
at clippy_lints/src/utils/mod.rs:502
18: 0x56455230d7e4 - core::ptr::drop_in_place::h14e2a7817529e69e
at libcore/ptr.rs:194
19: 0x56455225b38c - clippy_lints::utils::span_lint_and_then::h42a7d6d7c4372d8f
at clippy_lints/src/utils/mod.rs:563
20: 0x56455224ba71 - clippy_lints::loops::check_for_loop_range::h53307629e1b4ea43
at clippy_lints/src/loops.rs:1131
21: 0x564552248d48 - clippy_lints::loops::check_for_loop::h56e8de59b5e25744
at clippy_lints/src/loops.rs:744
22: 0x5645522465ff -
at clippy_lints/src/loops.rs:452
23: 0x7ff540f2bf70 -
24: 0x7ff540f2de61 -
25: 0x7ff540f2e0ec -
26: 0x7ff540f2c03a -
27: 0x7ff540f2e0ec -
28: 0x7ff540f2c03a -
29: 0x7ff540ebff8f - rustc::hir::intravisit::walk_expr::hc63fdf174e426d73
30: 0x7ff540f2c03a -
31: 0x7ff540f2de61 -
32: 0x7ff540f2e0ec -
33: 0x7ff540f2c03a -
34: 0x7ff540f2b09f -
35: 0x7ff540f2aeda -
36: 0x7ff540f2c7c4 -
37: 0x7ff540eac86f - rustc::hir::intravisit::walk_impl_item::h1f6950020260656a
38: 0x7ff540f2f7ab -
39: 0x7ff540eafdab - rustc::hir::intravisit::walk_impl_item_ref::ha1602df357497b7f
40: 0x7ff540e8508e - rustc::hir::intravisit::walk_item::he9d61edd2c8d86e4
41: 0x7ff540f2b59b -
42: 0x7ff540f2daa0 -
43: 0x7ff540e84ed5 - rustc::hir::intravisit::walk_item::he9d61edd2c8d86e4
44: 0x7ff540f2b59b -
45: 0x7ff540f2daa0 -
46: 0x7ff540e84ed5 - rustc::hir::intravisit::walk_item::he9d61edd2c8d86e4
47: 0x7ff540f2b59b -
48: 0x7ff540f2daa0 -
49: 0x7ff540e7467e - rustc::hir::intravisit::walk_crate::hb1af66e338bade00
50: 0x7ff540f34dca - rustc::lint::context::check_crate::h59d58a2726a89b10
51: 0x7ff541c93bb5 - rustc::util::common::time::h37c011639b879a10
52: 0x7ff541d19955 - rustc::ty::context::tls::enter_context::h6950822dd08f2c59
53: 0x7ff541cd5a91 -
54: 0x7ff541d441c7 - rustc::ty::context::TyCtxt::create_and_enter::ha95c55f91512e935
55: 0x7ff541c7ce2e - rustc_driver::driver::compile_input::hcd247e03696e3fb1
56: 0x7ff541d29f09 - rustc_driver::run_compiler_with_pool::h9471c56f5248e8fa
57: 0x7ff541c7aa6b - rustc_driver::driver::spawn_thread_pool::hc38d4bef06adb0b4
58: 0x7ff541d28f47 - rustc_driver::run_compiler::h9d2a717d593d7246
59: 0x564551dc5de7 - clippy_driver::main::{{closure}}::h3070fae3d07d268d
at src/driver.rs:157
60: 0x564551dc2879 - rustc_driver::run::{{closure}}::{{closure}}::h94b4b5494fb3abc8
at librustc_driver/lib.rs:189
61: 0x564551df330f -
at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
62: 0x564551dc66aa - syntax::with_globals::{{closure}}::hf4f09544896319d8
at libsyntax/lib.rs:106
63: 0x564551df3249 -
at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
64: 0x564551dc6621 - syntax::with_globals::h96b219aa59789cfd
at libsyntax/lib.rs:105
65: 0x564551dc2848 - rustc_driver::run::{{closure}}::hb5011e7d2a16f523
at librustc_driver/lib.rs:188
66: 0x564551dc3838 - rustc_driver::monitor::{{closure}}::hc025465fd14d7f73
at librustc_driver/lib.rs:1660
67: 0x564551dccf18 -
at libstd/panic.rs:313
68: 0x564551df8a6a - std::panicking::try::do_call::h40a0b1fe1bed7da5
at libstd/panicking.rs:310
69: 0x7ff53ef49d89 - __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
70: 0x564551df88f4 - std::panicking::try::h7aa93e0933be93fc
at libstd/panicking.rs:289
71: 0x564551dccf58 - std::panic::catch_unwind::he9bd4dd23dea76ba
at libstd/panic.rs:392
72: 0x564551dc24a8 - rustc_driver::in_named_rustc_thread::hde5420c565dbaaff
at librustc_driver/lib.rs:1574
73: 0x564551dc1ed0 - rustc_driver::in_rustc_thread::h716d001069807035
at librustc_driver/lib.rs:1585
74: 0x564551dc2c58 - rustc_driver::monitor::h8b84895cf4afea9a
at librustc_driver/lib.rs:1659
75: 0x564551dc27e8 - rustc_driver::run::h9f2884da1af3e206
at librustc_driver/lib.rs:187
76: 0x564551dff5ee - clippy_driver::main::h27bda5ed578684af
at src/driver.rs:37
77: 0x564551dc1e6f - std::rt::lang_start::{{closure}}::h79cbda49d6d4a726
at libstd/rt.rs:74
78: 0x7ff53ef3bf52 - std::panicking::try::do_call::ha2b0c74d7054d335
at libstd/rt.rs:59
at libstd/panicking.rs:310
79: 0x7ff53ef49d89 - __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
80: 0x7ff53ef1003a - std::rt::lang_start_internal::h9638620ca7e1b9bd
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
81: 0x564551dc1e48 - std::rt::lang_start::h2fc573a103e6ac9a
at libstd/rt.rs:74
82: 0x564551dff669 - main
83: 0x7ff53ec91222 - __libc_start_main
84: 0x564551dad02d - _start
85: 0x0 -
query stack during panic:
end of query stack
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.31.0-nightly (77af31408 2018-10-11) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental -C target-cpu=native --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile goblin.
Caused by:
process didn't exit successfully: /home/matthias/vcs/github/rust-clippy/target/debug/clippy-driver rustc --crate-name goblin src/lib.rs --color always --crate-type lib --emit=dep-info,metadata -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="archive"' --cfg 'feature="default"' --cfg 'feature="elf32"' --cfg 'feature="elf64"' --cfg 'feature="endian_fd"' --cfg 'feature="log"' --cfg 'feature="mach32"' --cfg 'feature="mach64"' --cfg 'feature="pe32"' --cfg 'feature="pe64"' --cfg 'feature="scroll"' --cfg 'feature="std"' -C metadata=444c2f72a8efe6ed -C extra-filename=-444c2f72a8efe6ed --out-dir /tmp/goblin/target/debug/deps -C incremental=/tmp/goblin/target/debug/incremental -L dependency=/tmp/goblin/target/debug/deps --extern log=/tmp/goblin/target/debug/deps/liblog-997e20cf8ae6acad.rmeta --extern plain=/tmp/goblin/target/debug/deps/libplain-c0f5275e9e78a53e.rmeta --extern scroll=/tmp/goblin/target/debug/deps/libscroll-a5ca24c4ef6ea987.rmeta -C target-cpu=native (exit code: 101)
````
Found via #3142
Looking into this. It's turning out to be a deep rabbit hole. I'll continue to test.
I've found that this crash has probably always existed. It is reproducible with the rustc and clippy version shipped with rustup stable. Still trying to determine the root cause.
It looks like the crash is occurring because clippy is trying to create a suggestion with 2 span replacements, but because the lint triggers within a proc macro, the compiler tries to apply the replacement to the same span, and crashes.
What is the typical way of handling these scenarios? Is there a mechanism within clippy to ignore lints within macro expansions? If we removed the suggestion, it would resolve the crash, but we wouldn't want to remove the suggestion in cases where it can be applied properly.
@shssoichiro For ignoring macro expansions, you can use the in_macro() function.
It depends on the specific case whether we want to remove the suggestion or not. I would say fixing the crash is more important than suggestion correctness. We can always file a separate issue to work on the suggestion in a second step.
Did you find a small code snippet that reproduces the crash?
Yes, I do have a minified test case which I'll include in the PR.
Most helpful comment
Looking into this. It's turning out to be a deep rabbit hole. I'll continue to test.