Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice: When Place contains ProjectionElem::Field it's type shouldn't be {type error} #120788

Closed
matthiaskrgr opened this issue Feb 8, 2024 · 0 comments · Fixed by #120802
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

pub struct Foo {
    field: String,
}

pub type Tait = impl Sized;

pub async fn ice_cold(beverage: Tait) {
    let Foo { field } = beverage;
    _ = field;
}

fn main() {
    Ok(())
}

original:

// build-pass
// edition: 2021

#![feature(type_alias_impl_trait)]

pub struct Foo {
    /// This type must have nontrivial drop glue
    field: String,
}

pub type Tait = impl Sized;

pub async fn ice_cold(beverage: Tait) {
    // Must destructure at least one field of `Foo`
    let Foo { field } = beverage;
    _ = field;
}

fn main() {
    // double everything
    let mut input = vec![];
    io::stdin().read_to_end(&mut input)?;
    io::stdout().write_all(&input)?;
    io::stdout().write_all(&input)?;
    Ok(())
}

Version information

rustc 1.78.0-nightly (af88f7db5 2024-02-08)
binary: rustc
commit-hash: af88f7db51f6f2a1472f9279d7c7e7c822afff77
commit-date: 2024-02-08
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> /tmp/icemaker_global_tempdir.J2OTMscpw96F/rustc_testrunner_tmpdir_reporting.3uqeRMP0RnMp/mvce.rs:7:5
  |
7 | pub async fn ice_cold(beverage: Tait) {
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.J2OTMscpw96F/rustc_testrunner_tmpdir_reporting.3uqeRMP0RnMp/mvce.rs:5:17
  |
5 | pub type Tait = impl Sized;
  |                 ^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-08; consider upgrading it if it is out of date

error[E0308]: mismatched types
  --> /tmp/icemaker_global_tempdir.J2OTMscpw96F/rustc_testrunner_tmpdir_reporting.3uqeRMP0RnMp/mvce.rs:13:5
   |
12 | fn main() {
   |          - expected `()` because of default return type
13 |     Ok(())
   |     ^^^^^^ expected `()`, found `Result<(), _>`
   |
   = note: expected unit type `()`
                   found enum `Result<(), _>`

error: internal compiler error: /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/compiler/rustc_mir_dataflow/src/move_paths/builder.rs:206:45: When Place contains ProjectionElem::Field it's type shouldn't be {type error}

thread 'rustc' panicked at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/compiler/rustc_errors/src/lib.rs:922:30:
Box<dyn Any>
stack backtrace:
   0:     0x7ff6047dedd6 - std::backtrace_rs::backtrace::libunwind::trace::hf92ca961e56825b0
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ff6047dedd6 - std::backtrace_rs::backtrace::trace_unsynchronized::h23f341cc1a6c507f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff6047dedd6 - std::sys_common::backtrace::_print_fmt::ha5a5ba44893edc7f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ff6047dedd6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h667e6ba5a1d3724e
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff604831830 - core::fmt::rt::Argument::fmt::h06c91f49bef095fb
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/core/src/fmt/rt.rs:142:9
   5:     0x7ff604831830 - core::fmt::write::h8e4b31b0aa81d13f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/core/src/fmt/mod.rs:1120:17
   6:     0x7ff6047d264f - std::io::Write::write_fmt::h4c479f5c53dfe78c
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/io/mod.rs:1854:15
   7:     0x7ff6047debb4 - std::sys_common::backtrace::_print::he414f5864df55ed1
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff6047debb4 - std::sys_common::backtrace::print::h939e58bdcc61d57d
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff6047e1947 - std::panicking::default_hook::{{closure}}::h244e48e05cd664b2
  10:     0x7ff6047e16a9 - std::panicking::default_hook::hf842080c39497dac
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/panicking.rs:292:9
  11:     0x7ff6015454ac - std[f801e042bca9681]::panicking::update_hook::<alloc[1377227f5558ef79]::boxed::Box<rustc_driver_impl[65af58b05c4f91ef]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ff6047e2096 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hee9c09a26ce84f59
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2029:9
  13:     0x7ff6047e2096 - std::panicking::rust_panic_with_hook::h83c20f9191a2a712
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/panicking.rs:785:13
  14:     0x7ff601576f04 - std[f801e042bca9681]::panicking::begin_panic::<rustc_errors[89ec94d63507ad05]::ExplicitBug>::{closure#0}
  15:     0x7ff6015735f6 - std[f801e042bca9681]::sys_common::backtrace::__rust_end_short_backtrace::<std[f801e042bca9681]::panicking::begin_panic<rustc_errors[89ec94d63507ad05]::ExplicitBug>::{closure#0}, !>
  16:     0x7ff60156ea66 - std[f801e042bca9681]::panicking::begin_panic::<rustc_errors[89ec94d63507ad05]::ExplicitBug>
  17:     0x7ff601582b61 - <rustc_errors[89ec94d63507ad05]::diagnostic_builder::BugAbort as rustc_errors[89ec94d63507ad05]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7ff6019369be - <rustc_errors[89ec94d63507ad05]::DiagCtxt>::bug::<alloc[1377227f5558ef79]::string::String>
  19:     0x7ff6019d23db - rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt::<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}
  20:     0x7ff6019b990a - rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_opt::<rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff6019b9788 - rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_context_opt::<rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_opt<rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff5ff967db0 - rustc_middle[2cc1c6e52ad3d43f]::util::bug::bug_fmt
  23:     0x7ff602f454af - <rustc_mir_dataflow[6a8aeaf0a2f9293d]::move_paths::builder::Gatherer<<rustc_mir_transform[f04df7d082cb6ded]::elaborate_drops::ElaborateDrops as rustc_middle[2cc1c6e52ad3d43f]::mir::MirPass>::run_pass::{closure#0}>>::gather_move
  24:     0x7ff6030d2465 - <rustc_mir_transform[f04df7d082cb6ded]::elaborate_drops::ElaborateDrops as rustc_middle[2cc1c6e52ad3d43f]::mir::MirPass>::run_pass
  25:     0x7ff6028123e6 - rustc_mir_transform[f04df7d082cb6ded]::pass_manager::run_passes_inner
  26:     0x7ff5ffc91352 - rustc_mir_transform[f04df7d082cb6ded]::mir_drops_elaborated_and_const_checked
  27:     0x7ff6029e3675 - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7ff6029e38fa - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::VecCache<rustc_span[467c297c964200f6]::def_id::LocalDefId, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  29:     0x7ff6029e31d4 - rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ff6031d44ed - rustc_interface[c2746bee48761670]::passes::analysis
  31:     0x7ff6031d3bdf - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7ff6034a17b2 - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::SingleCache<rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  33:     0x7ff6034a1515 - rustc_query_impl[5ca841c3c79670ea]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7ff6034e2436 - rustc_interface[c2746bee48761670]::interface::run_compiler::<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}
  35:     0x7ff603160248 - std[f801e042bca9681]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c2746bee48761670]::util::run_in_thread_with_globals<rustc_interface[c2746bee48761670]::util::run_in_thread_pool_with_globals<rustc_interface[c2746bee48761670]::interface::run_compiler<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>
  36:     0x7ff603160077 - <<std[f801e042bca9681]::thread::Builder>::spawn_unchecked_<rustc_interface[c2746bee48761670]::util::run_in_thread_with_globals<rustc_interface[c2746bee48761670]::util::run_in_thread_pool_with_globals<rustc_interface[c2746bee48761670]::interface::run_compiler<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#1} as core[30be359c16b30868]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7ff6047eb735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h99757397e7c4fa77
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2015:9
  38:     0x7ff6047eb735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7e0e3d311e6447da
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2015:9
  39:     0x7ff6047eb735 - std::sys::pal::unix::thread::Thread::new::thread_start::h0eb0f22e3002fa19
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys/pal/unix/thread.rs:108:17
  40:     0x7ff5fe6aa9eb - <unknown>
  41:     0x7ff5fe72e7cc - <unknown>
  42:                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.78.0-nightly (af88f7db5 2024-02-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `ice_cold::{closure#0}`
#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, E0658, E0670.
For more information about an error, try `rustc --explain E0308`.

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 8, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 8, 2024
@bors bors closed this as completed in 30057f0 Feb 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2024
Rollup merge of rust-lang#120802 - oli-obk:drop_elab_ice, r=compiler-errors

Bail out of drop elaboration when encountering error types

fixes  rust-lang#120788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants