ice: ProjectionKinds Deref and Field were mismatched
#118144
Closed
Description
auto-reduced (treereduce-rust):
//
struct V<'a>((Option<&'a mut i32>,));
fn nested(v: &mut V<'_>) {
(|| {
V((_o,)) = v;
v.0 = (None,);
})();
}
original:
// Regression test for #89606. Used to ICE.
//
// check-pass
// revisions: twenty_eighteen twenty_twentyone
// [twenty_eighteen]compile-flags: --edition 2018
// [twenty_twentyone]compile-flags: --edition 2021
struct S<'a>(Option<&'a mut i32>);
fn by_ref(s: &mut S<'_>) {
(|| {
let S(_o) = s;
s.0 = None;
})();
}
fn by_value(s: S<'_>) {
(|| {
let S(ref _o) = s;
let _g = s.0;
})();
}
struct V<'a>((Option<&'a mut i32>,));
fn nested(v: &mut V<'_>) {
(|| {
struct S<'a>(Option<&'a mut i32>); V((_o,)) = v;
v.0 = (None, );
})();
}
fn main() {
let mut s = S(None);
by_ref(&mut s);
by_value(s);
let mut v = V((None, ));
nested(&mut v);
}
Version information
rustc 1.76.0-nightly (e24e5af78 2023-11-21)
binary: rustc
commit-hash: e24e5af787f7015914cbf316063ed5821f370b71
commit-date: 2023-11-21
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0425]: cannot find value `_o` in this scope
--> /tmp/icemaker_global_tempdir.4GO1XXNNDlqm/rustc_testrunner_tmpdir_reporting.Y3wqoQZ3yyr5/mvce.rs:7:12
|
7 | V((_o,)) = v;
| ^^ not found in this scope
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.4GO1XXNNDlqm/rustc_testrunner_tmpdir_reporting.Y3wqoQZ3yyr5/mvce.rs:10:2
|
10 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.4GO1XXNNDlqm/rustc_testrunner_tmpdir_reporting.Y3wqoQZ3yyr5/mvce.rs`
error[E0308]: mismatched types
--> /tmp/icemaker_global_tempdir.4GO1XXNNDlqm/rustc_testrunner_tmpdir_reporting.Y3wqoQZ3yyr5/mvce.rs:7:9
|
7 | V((_o,)) = v;
| ^^^^^^^^ - this expression has type `&mut V<'_>`
| |
| expected `&mut V<'_>`, found `V<'_>`
error: internal compiler error: compiler/rustc_hir_typeck/src/upvar.rs:704:30: ProjectionKinds Deref and Field were mismatched: (Deref, Field(0, 0))
thread 'rustc' panicked at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/compiler/rustc_errors/src/lib.rs:1660:9:
Box<dyn Any>
stack backtrace:
0: 0x7efd84810afc - std::backtrace_rs::backtrace::libunwind::trace::h0b040baf97a1a814
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7efd84810afc - std::backtrace_rs::backtrace::trace_unsynchronized::h3bb4f35c883ef0b7
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7efd84810afc - std::sys_common::backtrace::_print_fmt::h7bc4c6c40e2dea38
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7efd84810afc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha29c192b6f9a05c7
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7efd84863c80 - core::fmt::rt::Argument::fmt::hd5d7e2c681722c4a
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/fmt/rt.rs:142:9
5: 0x7efd84863c80 - core::fmt::write::h44f28bd6729c28a7
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/core/src/fmt/mod.rs:1120:17
6: 0x7efd8480491f - std::io::Write::write_fmt::h34e80b21f77f27fe
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/io/mod.rs:1762:15
7: 0x7efd848108e4 - std::sys_common::backtrace::_print::hf6fce87ec4803f0c
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7efd848108e4 - std::sys_common::backtrace::print::h2c7cd590dc94a621
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7efd84813577 - std::panicking::default_hook::{{closure}}::ha2265235df34f52e
10: 0x7efd848132df - std::panicking::default_hook::ha134722f286c6b3a
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:292:9
11: 0x7efd814f42b0 - std[9e66bc0d43e7428]::panicking::update_hook::<alloc[6053f7fa92048905]::boxed::Box<rustc_driver_impl[6d46853ed3c470a0]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7efd84813cb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3506115e7630eb0e
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2021:9
13: 0x7efd84813cb8 - std::panicking::rust_panic_with_hook::h7694bf37e5dc3efe
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/panicking.rs:783:13
14: 0x7efd8193b174 - std[9e66bc0d43e7428]::panicking::begin_panic::<rustc_errors[561fbf43990526ac]::ExplicitBug>::{closure#0}
15: 0x7efd819346d6 - std[9e66bc0d43e7428]::sys_common::backtrace::__rust_end_short_backtrace::<std[9e66bc0d43e7428]::panicking::begin_panic<rustc_errors[561fbf43990526ac]::ExplicitBug>::{closure#0}, !>
16: 0x7efd8192edc6 - std[9e66bc0d43e7428]::panicking::begin_panic::<rustc_errors[561fbf43990526ac]::ExplicitBug>
17: 0x7efd81914f14 - <rustc_errors[561fbf43990526ac]::HandlerInner>::bug::<alloc[6053f7fa92048905]::string::String>
18: 0x7efd81914c1a - <rustc_errors[561fbf43990526ac]::Handler>::bug::<alloc[6053f7fa92048905]::string::String>
19: 0x7efd819b692d - rustc_middle[999cff9f20269db6]::util::bug::opt_span_bug_fmt::<rustc_span[433598ff900853dd]::span_encoding::Span>::{closure#0}
20: 0x7efd8199dc8a - rustc_middle[999cff9f20269db6]::ty::context::tls::with_opt::<rustc_middle[999cff9f20269db6]::util::bug::opt_span_bug_fmt<rustc_span[433598ff900853dd]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21: 0x7efd8199db28 - rustc_middle[999cff9f20269db6]::ty::context::tls::with_context_opt::<rustc_middle[999cff9f20269db6]::ty::context::tls::with_opt<rustc_middle[999cff9f20269db6]::util::bug::opt_span_bug_fmt<rustc_span[433598ff900853dd]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22: 0x7efd7f93fbf0 - rustc_middle[999cff9f20269db6]::util::bug::bug_fmt
23: 0x7efd83e0551c - <[rustc_middle[999cff9f20269db6]::ty::closure::CapturedPlace]>::sort_by::<<rustc_hir_typeck[3784c5e6fa919bfa]::fn_ctxt::FnCtxt>::compute_min_captures::{closure#1}>::{closure#0}.cold.0
24: 0x7efd8345f5eb - core[4409ec5cd92597ed]::slice::sort::insertion_sort_shift_left::<rustc_middle[999cff9f20269db6]::ty::closure::CapturedPlace, <[rustc_middle[999cff9f20269db6]::ty::closure::CapturedPlace]>::sort_by<<rustc_hir_typeck[3784c5e6fa919bfa]::fn_ctxt::FnCtxt>::compute_min_captures::{closure#1}>::{closure#0}>
25: 0x7efd8345df5e - <rustc_hir_typeck[3784c5e6fa919bfa]::fn_ctxt::FnCtxt>::compute_min_captures
26: 0x7efd831e8a25 - <rustc_hir_typeck[3784c5e6fa919bfa]::fn_ctxt::FnCtxt>::analyze_closure
27: 0x7efd7f664942 - <rustc_hir_typeck[3784c5e6fa919bfa]::upvar::InferBorrowKindVisitor as rustc_hir[b19a94a0ae9cf398]::intravisit::Visitor>::visit_expr
28: 0x7efd7f66474a - <rustc_hir_typeck[3784c5e6fa919bfa]::upvar::InferBorrowKindVisitor as rustc_hir[b19a94a0ae9cf398]::intravisit::Visitor>::visit_expr
29: 0x7efd82a91d04 - <rustc_hir_typeck[3784c5e6fa919bfa]::upvar::InferBorrowKindVisitor as rustc_hir[b19a94a0ae9cf398]::intravisit::Visitor>::visit_block
30: 0x7efd82af877e - rustc_hir_typeck[3784c5e6fa919bfa]::typeck
31: 0x7efd82af7813 - rustc_query_impl[e3648600a664160f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e3648600a664160f]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[999cff9f20269db6]::query::erase::Erased<[u8; 8usize]>>
32: 0x7efd82994cc3 - rustc_query_system[68ab24f02628e1a4]::query::plumbing::try_execute_query::<rustc_query_impl[e3648600a664160f]::DynamicConfig<rustc_query_system[68ab24f02628e1a4]::query::caches::VecCache<rustc_span[433598ff900853dd]::def_id::LocalDefId, rustc_middle[999cff9f20269db6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e3648600a664160f]::plumbing::QueryCtxt, false>
33: 0x7efd82994950 - rustc_query_impl[e3648600a664160f]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
34: 0x7efd82bba240 - rustc_hir_analysis[ac2ddafd5ff93a2f]::check_crate
35: 0x7efd82b4e4d7 - rustc_interface[79d196cce7f623b3]::passes::analysis
36: 0x7efd82b4e11d - rustc_query_impl[e3648600a664160f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e3648600a664160f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[999cff9f20269db6]::query::erase::Erased<[u8; 1usize]>>
37: 0x7efd8378aac0 - rustc_query_system[68ab24f02628e1a4]::query::plumbing::try_execute_query::<rustc_query_impl[e3648600a664160f]::DynamicConfig<rustc_query_system[68ab24f02628e1a4]::query::caches::SingleCache<rustc_middle[999cff9f20269db6]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e3648600a664160f]::plumbing::QueryCtxt, false>
38: 0x7efd8378a8c7 - rustc_query_impl[e3648600a664160f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
39: 0x7efd83813678 - rustc_interface[79d196cce7f623b3]::interface::run_compiler::<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}
40: 0x7efd837a3054 - std[9e66bc0d43e7428]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[79d196cce7f623b3]::util::run_in_thread_with_globals<rustc_interface[79d196cce7f623b3]::util::run_in_thread_pool_with_globals<rustc_interface[79d196cce7f623b3]::interface::run_compiler<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>
41: 0x7efd837a2e7d - <<std[9e66bc0d43e7428]::thread::Builder>::spawn_unchecked_<rustc_interface[79d196cce7f623b3]::util::run_in_thread_with_globals<rustc_interface[79d196cce7f623b3]::util::run_in_thread_pool_with_globals<rustc_interface[79d196cce7f623b3]::interface::run_compiler<core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>, rustc_driver_impl[6d46853ed3c470a0]::run_compiler::{closure#0}>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4409ec5cd92597ed]::result::Result<(), rustc_span[433598ff900853dd]::ErrorGuaranteed>>::{closure#1} as core[4409ec5cd92597ed]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
42: 0x7efd8481db75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he2fe898dabd7bf63
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2007:9
43: 0x7efd8481db75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e31e36ca472739b
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/alloc/src/boxed.rs:2007:9
44: 0x7efd8481db75 - std::sys::unix::thread::Thread::new::thread_start::h72b7daa856b881db
at /rustc/e24e5af787f7015914cbf316063ed5821f370b71/library/std/src/sys/unix/thread.rs:108:17
45: 0x7efd7e6aa9eb - <unknown>
46: 0x7efd7e72e7cc - <unknown>
47: 0x0 - <unknown>
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.76.0-nightly (e24e5af78 2023-11-21) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `nested`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0308, E0425, E0601.
For more information about an error, try `rustc --explain E0308`.
Activity