Closed
Description
Code
struct S;
impl S {
fn foo(_: Box<Option<S>>) {}
fn bar() {
Self::foo(None)
}
}
On stable the code produces the following error as expected:
Expected result
> cargo +stable c
Checking rustc-ice v0.1.0 (E:\Projects\rust_ice)
error[E0308]: mismatched types
--> src\lib.rs:6:19
|
6 | Self::foo(None)
| ^^^^ expected struct `Box`, found enum `Option`
|
= note: expected struct `Box<Option<S>>`
found enum `Option<_>`
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
help: store this in the heap by calling `Box::new`
|
6 | Self::foo(Box::new(None))
| +++++++++ +
For more information about this error, try `rustc --explain E0308`.
error: could not compile `rustc-ice` due to previous error
Meta
rustc --version --verbose
:
binary: rustc
commit-hash: 514b3877956dc594823106b66c164f8cdbc8b3da
commit-date: 2021-10-22
host: x86_64-pc-windows-msvc
release: 1.58.0-nightly
LLVM version: 13.0.0
Error output
> rustc .\src\lib.rs --crate-type lib --edition 2021
thread 'rustc' panicked at 'attempted .def_id() on invalid res: SelfTy(None, Some((DefId(0:5 ~ lib[fb89]::{impl#0}), false)))', /rustc/514b3877956dc594823106b66c164f8cdbc8b3da\compiler\rustc_hir\src\def.rs:538:32
Backtrace
stack backtrace:
0: 0x7ffd38008c0f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
1: 0x7ffd380328ca - core::fmt::write::h8a2c40ddb66ccc71
2: 0x7ffd37ffb5b8 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hd15f09e3fd3eac54
3: 0x7ffd3800c366 - std::panicking::take_hook::hf14c76592f73c762
4: 0x7ffd3800be4c - std::panicking::take_hook::hf14c76592f73c762
5: 0x7ffd385b47fe - rustc_target::abi::call::Reg::i32::h725bc73aaf6d2b9e
6: 0x7ffd3800cc79 - std::panicking::rust_panic_with_hook::hbc0e9c80ca88eac0
7: 0x7ffd3800c71b - rust_begin_unwind
8: 0x7ffd38009547 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
9: 0x7ffd3800c679 - rust_begin_unwind
10: 0x7ffd38068de0 - core::panicking::panic_fmt::hc1b1ca620e7a2c9f
11: 0x7ffd3b0b7358 - rustc_typeck::expr_use_visitor::ExprUseVisitor::consume_body::hd16e0986a59097ad
12: 0x7ffd3aec4735 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::emit_coerce_suggestions::h52f710f2abb42311
13: 0x7ffd3aec7d73 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::demand_coerce_diag::h18560e5b118c4876
14: 0x7ffd3aee30a9 - rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::structurally_resolved_type::h135aa7bd3ccaa1dc
15: 0x7ffd3aebdc7b - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::he819edd5620c5bb6
16: 0x7ffd3aebaef3 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::he819edd5620c5bb6
17: 0x7ffd3af1c0c9 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::hce68c582f5dbfdba
18: 0x7ffd3aed3109 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
19: 0x7ffd3aee7bbf - rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_no_value::h8b3cbf26ca4028ed
20: 0x7ffd3aed3109 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
21: 0x7ffd3aed4078 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
22: 0x7ffd3b0d17a1 - <rustc_typeck::variance::terms::TermsContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_foreign_item::h121e02c865985cfa
23: 0x7ffd3aff1ce8 - <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt::h3b34db69e1363b95
24: 0x7ffd3af6380c - rustc_typeck::check::provide::h247ea963b90ea55e
25: 0x7ffd3bbcf1f1 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
26: 0x7ffd3bc82aef - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
27: 0x7ffd3b00a7ee - <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt::h3b34db69e1363b95
28: 0x7ffd3af689c3 - <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h12e9a56710d7d8ed
29: 0x7ffd3badfa55 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
30: 0x7ffd3bc7aa6c - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
31: 0x7ffd3afcc83d - <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt::h16bc6042ecec2d45
32: 0x7ffd3af8d785 - rustc_typeck::check_crate::h69fc07eebd326dcf
33: 0x7ffd38717eef - rustc_interface::passes::analysis::hdb6e2398d1c67959
34: 0x7ffd3bac8f41 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
35: 0x7ffd3bc70ef9 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
36: 0x7ffd3861d01a - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
37: 0x7ffd3861da6b - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
38: 0x7ffd385d2786 - rustc_driver::pretty::print_after_hir_lowering::hb7dd632ff4fb38d2
39: 0x7ffd3861eeb6 - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
40: 0x7ffd385d9c23 - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h7aa873eeea16c083
41: 0x7ffd38648d48 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::heb70c7870704ee76
42: 0x7ffd3801933c - std::sys::windows::thread::Thread::new::he49a5cdb1d3d1cfc
43: 0x7ffdce8a7034 - BaseThreadInitThunk
44: 0x7ffdcfc02651 - RtlUserThreadStart
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.58.0-nightly (514b38779 2021-10-22) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type lib
query stack during panic:
#0 [typeck] type-checking `<impl at .\src\lib.rs:3:1: 8:2>::bar`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: trimmed_def_paths constructed
|
= note: delayed at 0: std::backtrace::Backtrace::disabled
1: std::backtrace::Backtrace::force_capture
2: rustc_errors::Handler::delay_good_path_bug
3: <rustc_middle::ty::print::pretty::TraitRefPrintOnlyTraitName as core::fmt::Debug>::fmt
4: <rustc_span::def_id::LocalDefId as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
5: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
6: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
7: rustc_middle::ty::print::pretty::RegionHighlightMode::highlighting_bound_region
8: rustc_middle::ty::print::pretty::<impl rustc_middle::ty::context::TyCtxt>::def_path_str
9: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_region_errors
10: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_and_explain_type_error
11: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::note_type_err
12: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_and_explain_type_error
13: rustc_infer::infer::InferCtxt::report_mismatched_types
14: rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::demand_coerce_diag
15: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::structurally_resolved_type
16: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
17: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
18: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
19: rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
20: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_no_value
21: rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
22: rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
23: <rustc_typeck::variance::terms::TermsContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_foreign_item
24: <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt
25: rustc_typeck::check::provide
26: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
27: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
28: <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt
29: <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
30: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
31: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
32: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt
33: rustc_typeck::check_crate
34: rustc_interface::passes::analysis
35: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
36: <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt
37: <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt
38: <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt
39: rustc_driver::pretty::print_after_hir_lowering
40: <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt
41: <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt
42: <rustc_driver::args::Error as core::fmt::Debug>::fmt
43: std::sys::windows::thread::Thread::new
44: BaseThreadInitThunk
45: RtlUserThreadStart
thread 'rustc' panicked at 'no warnings or errors encountered even though `delayed_good_path_bugs` issued', compiler\rustc_errors\src\lib.rs:1166:13
stack backtrace:
0: 0x7ffd38008c0f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
1: 0x7ffd380328ca - core::fmt::write::h8a2c40ddb66ccc71
2: 0x7ffd37ffb5b8 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hd15f09e3fd3eac54
3: 0x7ffd3800c366 - std::panicking::take_hook::hf14c76592f73c762
4: 0x7ffd3800be4c - std::panicking::take_hook::hf14c76592f73c762
5: 0x7ffd385b47fe - rustc_target::abi::call::Reg::i32::h725bc73aaf6d2b9e
6: 0x7ffd3800cc79 - std::panicking::rust_panic_with_hook::hbc0e9c80ca88eac0
7: 0x7ffd3800c71b - rust_begin_unwind
8: 0x7ffd38009547 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
9: 0x7ffd3800c679 - rust_begin_unwind
10: 0x7ffd38068de0 - core::panicking::panic_fmt::hc1b1ca620e7a2c9f
11: 0x7ffd3cdc4817 - <rustc_errors::registry::InvalidErrorCode as core::fmt::Debug>::fmt::habc00740dca1d786
12: 0x7ffd3cdc9768 - rustc_errors::HandlerInner::delay_as_bug::hc436ffe89340a533
13: 0x7ffd3cdc545e - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h9bea109db35ed3b5
14: 0x7ffd38651ec4 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::heb70c7870704ee76
15: 0x7ffd38659f77 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::heb70c7870704ee76
16: 0x7ffd385d600d - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h7aa873eeea16c083
17: 0x7ffd385d309e - rustc_driver::pretty::print_after_hir_lowering::hb7dd632ff4fb38d2
18: 0x7ffd3cf79540 - _rust_alloc_zeroed
19: 0x7ffd3cf7898e - _rust_alloc_zeroed
20: 0x7ffd3cf74564 - _rust_alloc_zeroed
21: 0x7ffd3cf77cf5 - _rust_alloc_zeroed
22: 0x7ffd3cf74e7d - _rust_alloc_zeroed
23: 0x7ffdcfc5214f - _chkstk
24: 0x7ffdcfbe0939 - RtlUnwindEx
25: 0x7ffd3cf74a2e - _rust_alloc_zeroed
26: 0x7ffd3cf769a1 - _rust_alloc_zeroed
27: 0x7ffd3cf76db7 - _rust_alloc_zeroed
28: 0x7ffd3cf77df1 - _rust_alloc_zeroed
29: 0x7ffd3cf74e7d - _rust_alloc_zeroed
30: 0x7ffdcfc520cf - _chkstk
31: 0x7ffdcfc01454 - RtlRaiseException
32: 0x7ffdcfc011a5 - RtlRaiseException
33: 0x7ffdcd304f99 - RaiseException
34: 0x7ffd38059e08 - _udivmodti4
35: 0x7ffd3801da2e - _rust_start_panic
36: 0x7ffd3800cf1b - rust_panic
37: 0x7ffd3800cceb - std::panicking::rust_panic_with_hook::hbc0e9c80ca88eac0
38: 0x7ffd3800c71b - rust_begin_unwind
39: 0x7ffd38009547 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
40: 0x7ffd3800c679 - rust_begin_unwind
41: 0x7ffd38068de0 - core::panicking::panic_fmt::hc1b1ca620e7a2c9f
42: 0x7ffd3b0b7358 - rustc_typeck::expr_use_visitor::ExprUseVisitor::consume_body::hd16e0986a59097ad
43: 0x7ffd3aec4735 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::emit_coerce_suggestions::h52f710f2abb42311
44: 0x7ffd3aec7d73 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::demand_coerce_diag::h18560e5b118c4876
45: 0x7ffd3aee30a9 - rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::structurally_resolved_type::h135aa7bd3ccaa1dc
46: 0x7ffd3aebdc7b - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::he819edd5620c5bb6
47: 0x7ffd3aebaef3 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::he819edd5620c5bb6
48: 0x7ffd3af1c0c9 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::hce68c582f5dbfdba
49: 0x7ffd3aed3109 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
50: 0x7ffd3aee7bbf - rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_no_value::h8b3cbf26ca4028ed
51: 0x7ffd3aed3109 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
52: 0x7ffd3aed4078 - rustc_typeck::check::demand::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast::had54e29c97b08ddf
53: 0x7ffd3b0d17a1 - <rustc_typeck::variance::terms::TermsContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_foreign_item::h121e02c865985cfa
54: 0x7ffd3aff1ce8 - <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt::h3b34db69e1363b95
55: 0x7ffd3af6380c - rustc_typeck::check::provide::h247ea963b90ea55e
56: 0x7ffd3bbcf1f1 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
57: 0x7ffd3bc82aef - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
58: 0x7ffd3b00a7ee - <rustc_typeck::constrained_generic_params::Parameter as core::fmt::Debug>::fmt::h3b34db69e1363b95
59: 0x7ffd3af689c3 - <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h12e9a56710d7d8ed
60: 0x7ffd3badfa55 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
61: 0x7ffd3bc7aa6c - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
62: 0x7ffd3afcc83d - <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt::h16bc6042ecec2d45
63: 0x7ffd3af8d785 - rustc_typeck::check_crate::h69fc07eebd326dcf
64: 0x7ffd38717eef - rustc_interface::passes::analysis::hdb6e2398d1c67959
65: 0x7ffd3bac8f41 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
66: 0x7ffd3bc70ef9 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::he5db3fb64b64748a
67: 0x7ffd3861d01a - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
68: 0x7ffd3861da6b - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
69: 0x7ffd385d2786 - rustc_driver::pretty::print_after_hir_lowering::hb7dd632ff4fb38d2
70: 0x7ffd3861eeb6 - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h1c205b30aad4a3e6
71: 0x7ffd385d9c23 - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h7aa873eeea16c083
72: 0x7ffd38648d48 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::heb70c7870704ee76
73: 0x7ffd3801933c - std::sys::windows::thread::Thread::new::he49a5cdb1d3d1cfc
74: 0x7ffdce8a7034 - BaseThreadInitThunk
75: 0x7ffdcfc02651 - RtlUserThreadStart
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.58.0-nightly (514b38779 2021-10-22) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type lib
query stack during panic:
end of query stack
thread panicked while panicking. aborting.
cargo-bisect
searched nightlies: from nightly-2021-10-04 to nightly-2021-10-23
regressed nightly: nightly-2021-10-16
searched commit range: e1e9319...c102653
regressed commit: 72d6606
bisected with cargo-bisect-rustc v0.6.1
Host triple: x86_64-pc-windows-msvc
Reproduce with:
cargo bisect-rustc --start 2021-10-04 --regress ice