Closed matthiaskrgr closed 3 years ago
Possible reduced repro case, although the backtrace for this diverges after rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::haad0024fe8f5a7d2
.
struct Test {}
trait SomeTrait {
type Outer;
fn broken() -> Self::Outer;
}
struct Inner {}
impl SomeTrait for Inner {
type Outer = Test;
fn broken() -> Self::Outer {
Self::Outer{}
}
}
fn main() {}
Gives:
error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:279:17: associated type missing default
--> src/main.rs:3:3
|
3 | type Outer;
| ^^^^^^^^^^^
thread 'rustc' panicked at 'Box<Any>', /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new
note: Clippy version: clippy 0.1.52 (7dd6d5ed5 2021-02-26)
query stack during panic:
#0 [type_of] computing type of `SomeTrait::Outer`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
error: could not compile `ice6792`
I don't think this has anything to do with default_numeric_fallback
because if I disable that lint the backtrace implicates inconsistent_struct_constructor
. But I'm pretty sure this is rustc side.
As far as I can tell this comes calling self.cx.tcx.type_of(def_id)
with def_id
of DefId(0:5 ~ ice6792[1241]::SomeTrait::Outer)
There are two ways you can change the reduced example to prevent the ICE:
type Outer
a default type (and adding #![feature(associated_type_defaults)]
)fn broken() -> Self::Outer { Self::Outer{} }
to fn broken() -> Self::Outer { Test{} }
( I tried swapping other instances of Self::Outer
to Test
, but is that specific one that apparently causes the ICE )I don't think this has anything to do with default_numeric_fallback because if I disable that lint the backtrace implicates inconsistent_struct_constructor.
I think default_numeric_fallback
is involved in the ICE because it has the same problematic lines as inconsistent_struct_constructor
, the ICE is caused by here in default_numeric_fallback
and also here in inconsistent_struct_constructor
.
I suppose we could solve this issue just by replacing the lines with cx.typeck_results().expr_ty(expr)
.
And this would also fix #6793.
Hi, I'm using the nightly clippy but can still reproduce the issue, do I miss anything?
struct Test {}
trait SomeTrait {
type Outer;
fn broken() -> Self::Outer;
}
struct Inner {}
impl SomeTrait for Inner {
type Outer = Test;
fn broken() -> Self::Outer {
Self::Outer{}
}
}
fn main() {}
error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:278:17: associated type missing default
--> src/main.rs:22:3
|
22 | type Outer;
| ^^^^^^^^^^^
thread 'rustc' panicked at 'Box<Any>', /rustc/3a5d45f68cadc8fff4fbb557780f92b403b19c19/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new
note: Clippy version: clippy 0.1.52 (3a5d45f 2021-03-09)
query stack during panic:
#0 [type_of] computing type of `SomeTrait::Outer`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
error: could not compile `rust_test`
To learn more, run the command again with --verbose.
Saw this while running clippy 5c6cd87b94cb59efff08c0f0e44c376f92afa7e5 compiled with rustc
rustc 1.52.0-nightly (a8486b64b 2021-02-24)
in thealacritty
git repo:Error output
Backtrace
``` Checking alacritty v0.8.0-dev (/home/matthias/vcs/github/alacritty/alacritty) thread 'rustc' panicked at 'Not a type: DefIndex(1359)', compiler/rustc_metadata/src/rmeta/decoder.rs:908:32 stack backtrace: 0: 0x7f6069250d20 - std::backtrace_rs::backtrace::libunwind::trace::h9d49145f95eb5894 at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5 1: 0x7f6069250d20 - std::backtrace_rs::backtrace::trace_unsynchronized::hab1d020365bb6864 at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f6069250d20 - std::sys_common::backtrace::_print_fmt::h7659588431e304bd at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys_common/backtrace.rs:67:5 3: 0x7f6069250d20 -::fmt::h09f4a9e3befae3c7
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7f60692c146c - core::fmt::write::hf3fdfde304b9a088
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/core/src/fmt/mod.rs:1092:17
5: 0x7f6069244062 - std::io::Write::write_fmt::h1cb850689c7116f0
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/io/mod.rs:1568:15
6: 0x7f6069254bc5 - std::sys_common::backtrace::_print::hdbccd5aa093ba544
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7f6069254bc5 - std::sys_common::backtrace::print::hc639c4f320222558
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7f6069254bc5 - std::panicking::default_hook::{{closure}}::hdb012dd7a485bb5d
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:208:50
9: 0x7f6069254673 - std::panicking::default_hook::h75facbce77b6ba91
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:225:9
10: 0x562d8b504326 - as core::ops::function::Fn>::call::hf670d2338201faaa
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1560:9
11: 0x562d8b505386 - clippy_driver::report_clippy_ice::ha011a557ce32c801
at /home/matthias/vcs/github/rust-clippy/src/driver.rs:130:5
12: 0x562d8b507b25 - clippy_driver::ICE_HOOK::{{closure}}::{{closure}}::h81e5233532c5ccb3
at /home/matthias/vcs/github/rust-clippy/src/driver.rs:124:37
13: 0x7f605a22f526 - as core::ops::function::Fn>::call::h446469f4ecdc815b
at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1560:9
14: 0x7f605a232179 - proc_macro::bridge::client::::enter::{{closure}}::{{closure}}::h5a3b94cc035cfa07
at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:320:21
15: 0x7f60692554c6 - std::panicking::rust_panic_with_hook::hbcaa5de2cb5e22d5
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:595:17
16: 0x7f6069254fe7 - std::panicking::begin_panic_handler::{{closure}}::h4ee6cde415c8f62d
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:497:13
17: 0x7f60692511dc - std::sys_common::backtrace::__rust_end_short_backtrace::h895319f2d3f611c0
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys_common/backtrace.rs:141:18
18: 0x7f6069254f49 - rust_begin_unwind
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:493:5
19: 0x7f6069254efb - std::panicking::begin_panic_fmt::h0262e6b4d4041adf
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/panicking.rs:435:5
20: 0x7f606b404703 - rustc_metadata::rmeta::decoder::::get_type::h0f7702e8fa35bbb2
21: 0x7f606b44d90d - rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::type_of::he521e5ab693b86e7
22: 0x7f606bd01c88 - rustc_middle::dep_graph::::with_deps::haad0024fe8f5a7d2
23: 0x7f606b0d00fb - rustc_query_system::dep_graph::graph::DepGraph::with_task_impl::h5a242bc967412ecf
24: 0x7f606b0af973 - rustc_data_structures::stack::ensure_sufficient_stack::h8b47dd27a73cafbe
25: 0x7f606b08cb37 - rustc_query_system::query::plumbing::force_query_with_job::h7032cab6de61fbf2
26: 0x7f606b06f32f - rustc_query_system::query::plumbing::get_query_impl::ha96d8281a4a739f8
27: 0x7f606b0c0e4a - ::type_of::hdaa39503a441e1f1
28: 0x562d8b65df6e - rustc_middle::ty::query::TyCtxtAt::type_of::hd38e60fdbe072970
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_middle/src/ty/query/mod.rs:205:17
29: 0x562d8b65df6e - rustc_middle::ty::query::::type_of::h4173330feb6c2294
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_middle/src/ty/query/mod.rs:186:17
30: 0x562d8b65df6e - ::visit_expr::h32f67de45e3d4b1e
at /home/matthias/vcs/github/rust-clippy/clippy_lints/src/default_numeric_fallback.rs:136:30
31: 0x562d8b65d57d - ::visit_expr::h32f67de45e3d4b1e
at /home/matthias/vcs/github/rust-clippy/clippy_lints/src/default_numeric_fallback.rs:114:25
32: 0x562d8b91ca05 - rustc_hir::intravisit::walk_block::h7a2182a7c25433aa
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_hir/src/intravisit.rs:1084:5
33: 0x562d8b8b2bc4 - rustc_hir::intravisit::Visitor::visit_block::h73882cbd0875fbc4
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_hir/src/intravisit.rs:354:9
34: 0x562d8ba2dc29 - rustc_hir::intravisit::walk_expr::he36c8d266e8e3497
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_hir/src/intravisit.rs:1173:13
35: 0x562d8b65e3bd - ::visit_expr::h32f67de45e3d4b1e
at /home/matthias/vcs/github/rust-clippy/clippy_lints/src/default_numeric_fallback.rs:178:9
36: 0x562d8b9eb0b8 - rustc_hir::intravisit::walk_body::h765df2df0f9a42a5
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_hir/src/intravisit.rs:506:5
37: 0x562d8b8b2b44 - rustc_hir::intravisit::Visitor::visit_body::h97531e8750c67478
at /home/matthias/.rustup/toolchains/nightly-2021-02-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/compiler/rustc_hir/src/intravisit.rs:320:9
38: 0x562d8b65ccd5 - ::check_body::hb0631384b47e3da2
at /home/matthias/vcs/github/rust-clippy/clippy_lints/src/default_numeric_fallback.rs:54:9
39: 0x7f606a8efd92 - ::check_body::h699daf59875dce36
40: 0x7f6069b24e9b - as rustc_hir::intravisit::Visitor>::visit_nested_body::he58e9e6b24e9d9c0
41: 0x7f6069b25186 - as rustc_hir::intravisit::Visitor>::visit_fn::hac0cd372390dff45
42: 0x7f6069b6b27b - rustc_hir::intravisit::walk_impl_item::h5bb649e8ba81efef
43: 0x7f6069b262d1 - rustc_hir::intravisit::Visitor::visit_nested_impl_item::hdf136acf27ef1810
44: 0x7f6069b6b96c - rustc_hir::intravisit::walk_impl_item_ref::h39360467acb6f1e2
45: 0x7f6069b6ca7a - rustc_hir::intravisit::walk_item::h2f37f1d91082318b
46: 0x7f6069b25d25 - rustc_hir::intravisit::Visitor::visit_nested_item::hcd30d874837a4042
47: 0x7f6069b24b59 - as rustc_hir::intravisit::Visitor>::visit_stmt::hb862526b553e6363
48: 0x7f6069b6ac79 - rustc_hir::intravisit::walk_block::hb9dfb3d8deaaa8eb
49: 0x7f6069b24b99 - as rustc_hir::intravisit::Visitor>::visit_block::h69ffeb043eb0f6ec
50: 0x7f6069b24a27 - as rustc_hir::intravisit::Visitor>::visit_expr::hfe4f59005f7421e1
51: 0x7f6069b24ea6 - as rustc_hir::intravisit::Visitor>::visit_nested_body::he58e9e6b24e9d9c0
52: 0x7f6069b25186 - as rustc_hir::intravisit::Visitor>::visit_fn::hac0cd372390dff45
53: 0x7f6069b6b27b - rustc_hir::intravisit::walk_impl_item::h5bb649e8ba81efef
54: 0x7f6069b262d1 - rustc_hir::intravisit::Visitor::visit_nested_impl_item::hdf136acf27ef1810
55: 0x7f6069b6b96c - rustc_hir::intravisit::walk_impl_item_ref::h39360467acb6f1e2
56: 0x7f6069b6ca7a - rustc_hir::intravisit::walk_item::h2f37f1d91082318b
57: 0x7f6069b25d25 - rustc_hir::intravisit::Visitor::visit_nested_item::hcd30d874837a4042
58: 0x7f6069b6bf38 - rustc_hir::intravisit::walk_mod::h169a052681c2134e
59: 0x7f6069b252cf - as rustc_hir::intravisit::Visitor>::visit_mod::h50f560318c71a862
60: 0x7f6069b6cb09 - rustc_hir::intravisit::walk_item::h2f37f1d91082318b
61: 0x7f6069b25d25 - rustc_hir::intravisit::Visitor::visit_nested_item::hcd30d874837a4042
62: 0x7f6069b6bf38 - rustc_hir::intravisit::walk_mod::h169a052681c2134e
63: 0x7f6069b252cf - as rustc_hir::intravisit::Visitor>::visit_mod::h50f560318c71a862
64: 0x7f6069b6cb09 - rustc_hir::intravisit::walk_item::h2f37f1d91082318b
65: 0x7f6069b25d25 - rustc_hir::intravisit::Visitor::visit_nested_item::hcd30d874837a4042
66: 0x7f6069b6bf38 - rustc_hir::intravisit::walk_mod::h169a052681c2134e
67: 0x7f6069b252cf - as rustc_hir::intravisit::Visitor>::visit_mod::h50f560318c71a862
68: 0x7f6069b6accf - rustc_hir::intravisit::walk_crate::h56516cd5271fbde1
69: 0x7f6069b20fec - rustc_lint::late::late_lint_pass_crate::h68fca22b203b40c7
70: 0x7f606b7865ef - rustc_lint::late::late_lint_crate::h8b056da490fd5163
71: 0x7f606b7bc2d3 - rustc_data_structures::sync::join::h1e87f8b6f730a184
72: 0x7f606b7a3c85 - std::panic::catch_unwind::h52b42338dd242d3f
73: 0x7f606b78c36f - rustc_session::utils::::time::hb76d107dd0ea1521
74: 0x7f606b7920ac - rustc_interface::passes::analysis::h1be2fa253172941a
75: 0x7f606a27ea0e - rustc_middle::dep_graph::::with_deps::h85fa16d3332afce7
76: 0x7f606bccc5c9 - rustc_query_system::dep_graph::graph::DepGraph::with_task_impl::h796e12c98e2566ac
77: 0x7f606bc4165f - rustc_data_structures::stack::ensure_sufficient_stack::h76fb6483c26c7f6b
78: 0x7f606bbfc54a - rustc_query_system::query::plumbing::force_query_with_job::h90d3fef7e56f1800
79: 0x7f606bbc469b - rustc_query_system::query::plumbing::get_query_impl::hb04441add7cec8aa
80: 0x7f606bca3c6f - ::analysis::h27d2dd58d2fc9be8
81: 0x7f606b77e83b - rustc_interface::passes::QueryContext::enter::h8a95f60ada89ef7e
82: 0x7f606b74f06d - rustc_interface::queries::::enter::h39531375bcd2fda9
83: 0x7f606b77fda1 - rustc_span::with_source_map::hf3c84f193adf9eda
84: 0x7f606b75002a - rustc_interface::interface::create_compiler_and_run::he227014f8377cd9b
85: 0x7f606b74e238 - scoped_tls::ScopedKey::set::h45bce0d39c421236
86: 0x7f606b74e8fc - std::sys_common::backtrace::__rust_begin_short_backtrace::h07189c72057db042
87: 0x7f606b76d8da - core::ops::function::FnOnce::call_once{{vtable.shim}}::h58a4726aa1e9868c
88: 0x7f60692656ca - as core::ops::function::FnOnce>::call_once::hdc51fe7e73bc86bf
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/alloc/src/boxed.rs:1546:9
89: 0x7f60692656ca - as core::ops::function::FnOnce>::call_once::he605738a76b56d9d
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/alloc/src/boxed.rs:1546:9
90: 0x7f60692656ca - std::sys::unix::thread::Thread::new::thread_start::he44b12fd83e74919
at /rustc/a8486b64b0c87dabd045453b6c81500015d122d6/library/std/src/sys/unix/thread.rs:71:17
91: 0x7f6069151299 - start_thread
92: 0x7f6068f33153 - clone
93: 0x0 -
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-clippy/issues/new
note: Clippy version: clippy 0.1.52 (928e72dd1 2021-02-25)
query stack during panic:
#0 [type_of] computing type of `config::color::_::_serde::de::Visitor::Value`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `alacritty`
```
Made the issue so hopefully people see this and we don't get bombarded with "clippy crashes on my project" tickets in the upcomming days. :sweat_smile:
I'm not sure yet if we can reproduce the ice with pure rustc or if it is bound to clippy somehow. Looks like the
default_numeric_fallback
lint is involved:35: 0x562d8b65e3bd - <clippy_lints::default_numeric_fallback::NumericFallbackVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h32f67de45e3d4b1e at /home/matthias/vcs/github/rust-clippy/clippy_lints/src/default_numeric_fallback.rs:178:9
This is reproducible in rustc master now and will hit nightly
2021-02-25