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: 'discriminant' called on unexpected type Alias(Opaque #116265

Closed
matthiaskrgr opened this issue Sep 29, 2023 · 5 comments · Fixed by #116415
Closed

ICE: 'discriminant' called on unexpected type Alias(Opaque #116265

matthiaskrgr opened this issue Sep 29, 2023 · 5 comments · Fixed by #116415
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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

Code

#![feature(type_alias_impl_trait)]

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    let x = move || match foo {
        None => (),
        Some((a, b)) => (),
    };
}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (c5450191f 2023-09-29)
binary: rustc
commit-hash: c5450191f313658d206dc7539311f665a274947f
commit-date: 2023-09-29
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.2

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_mir_dataflow/src/impls/initialized.rs:770:26: `discriminant` called on unexpected type Alias(Opaque, AliasTy { args: [], def_id: DefId(0:9 ~ issue_96572_unconstrained[d6d8]::enum_upvar::T::{opaque#0}) })

thread 'rustc' panicked at /rustc/c5450191f313658d206dc7539311f665a274947f/compiler/rustc_errors/src/lib.rs:1651:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f59a816433c - std::backtrace_rs::backtrace::libunwind::trace::hb568cd43caaa8089
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f59a816433c - std::backtrace_rs::backtrace::trace_unsynchronized::h0f2d13a7908f3914
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f59a816433c - std::sys_common::backtrace::_print_fmt::h6723d6b0ebd2797e
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f59a816433c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h95124a8c06b44298
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f59a81c9f9c - core::fmt::rt::Argument::fmt::h622e2c6916a5c4d5
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/core/src/fmt/rt.rs:138:9
   5:     0x7f59a81c9f9c - core::fmt::write::hcea8acdb83b538a2
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/core/src/fmt/mod.rs:1114:21
   6:     0x7f59a81570be - std::io::Write::write_fmt::hee5c75723cef4ed7
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/io/mod.rs:1763:15
   7:     0x7f59a8164124 - std::sys_common::backtrace::_print::h82b258ea59b074e4
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f59a8164124 - std::sys_common::backtrace::print::h6179e58f626913ed
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f59a8167003 - std::panicking::default_hook::{{closure}}::h9f2e56e7e949e9ef
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/panicking.rs:272:22
  10:     0x7f59a8166d24 - std::panicking::default_hook::h23bce3c6dc138bb8
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/panicking.rs:292:9
  11:     0x7f59ab2fee5f - std[b4843c1823a37d1]::panicking::update_hook::<alloc[807c770786b1efb8]::boxed::Box<rustc_driver_impl[418485cfdc98bfaa]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f59a8167831 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hec1cb47fd5eca853
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/alloc/src/boxed.rs:2021:9
  13:     0x7f59a8167831 - std::panicking::rust_panic_with_hook::h0b9e8e7a1a60c0c6
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/panicking.rs:735:13
  14:     0x7f59ab8386b4 - std[b4843c1823a37d1]::panicking::begin_panic::<rustc_errors[7cbc9798c005d993]::ExplicitBug>::{closure#0}
  15:     0x7f59ab838366 - std[b4843c1823a37d1]::sys_common::backtrace::__rust_end_short_backtrace::<std[b4843c1823a37d1]::panicking::begin_panic<rustc_errors[7cbc9798c005d993]::ExplicitBug>::{closure#0}, !>
  16:     0x7f59ab8c4086 - std[b4843c1823a37d1]::panicking::begin_panic::<rustc_errors[7cbc9798c005d993]::ExplicitBug>
  17:     0x7f59ab82dbb4 - <rustc_errors[7cbc9798c005d993]::HandlerInner>::bug::<alloc[807c770786b1efb8]::string::String>
  18:     0x7f59ab82da66 - <rustc_errors[7cbc9798c005d993]::Handler>::bug::<alloc[807c770786b1efb8]::string::String>
  19:     0x7f59ab89d9dc - rustc_middle[e970cc282ff9b1b5]::util::bug::opt_span_bug_fmt::<rustc_span[b8184c5be003882b]::span_encoding::Span>::{closure#0}
  20:     0x7f59ab89a9fa - rustc_middle[e970cc282ff9b1b5]::ty::context::tls::with_opt::<rustc_middle[e970cc282ff9b1b5]::util::bug::opt_span_bug_fmt<rustc_span[b8184c5be003882b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f59ab89a9c8 - rustc_middle[e970cc282ff9b1b5]::ty::context::tls::with_context_opt::<rustc_middle[e970cc282ff9b1b5]::ty::context::tls::with_opt<rustc_middle[e970cc282ff9b1b5]::util::bug::opt_span_bug_fmt<rustc_span[b8184c5be003882b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f59a9f84560 - rustc_middle[e970cc282ff9b1b5]::util::bug::bug_fmt
  23:     0x7f59a9985743 - <rustc_mir_dataflow[8cbe94db0a98dfe3]::impls::initialized::MaybeInitializedPlaces as rustc_mir_dataflow[8cbe94db0a98dfe3]::framework::Analysis>::apply_switch_int_edge_effects::<rustc_mir_dataflow[8cbe94db0a98dfe3]::framework::direction::ForwardSwitchIntEdgeEffectsApplier<rustc_mir_dataflow[8cbe94db0a98dfe3]::framework::lattice::MaybeReachable<rustc_index[2c090815ae444856]::bit_set::ChunkedBitSet<rustc_mir_dataflow[8cbe94db0a98dfe3]::move_paths::MovePathIndex>>, <rustc_mir_dataflow[8cbe94db0a98dfe3]::framework::engine::Engine<rustc_mir_dataflow[8cbe94db0a98dfe3]::impls::initialized::MaybeInitializedPlaces>>::iterate_to_fixpoint::{closure#0}>>
  24:     0x7f59a997f94d - <rustc_mir_dataflow[8cbe94db0a98dfe3]::framework::engine::Engine<rustc_mir_dataflow[8cbe94db0a98dfe3]::impls::initialized::MaybeInitializedPlaces>>::iterate_to_fixpoint
  25:     0x7f59a9956f74 - <rustc_mir_transform[f87aab292f3161cd]::elaborate_drops::ElaborateDrops as rustc_middle[e970cc282ff9b1b5]::mir::MirPass>::run_pass
  26:     0x7f59a95ed3fe - rustc_mir_transform[f87aab292f3161cd]::mir_drops_elaborated_and_const_checked
  27:     0x7f59a95ec71e - rustc_query_impl[4980b7cf5b7996c7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4980b7cf5b7996c7]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e970cc282ff9b1b5]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f59a95ec6ee - <rustc_query_impl[4980b7cf5b7996c7]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2} as core[951439f994106a2d]::ops::function::FnOnce<(rustc_middle[e970cc282ff9b1b5]::ty::context::TyCtxt, rustc_span[b8184c5be003882b]::def_id::LocalDefId)>>::call_once
  29:     0x7f59a9537d38 - rustc_query_system[873a9c0fbeb3d104]::query::plumbing::try_execute_query::<rustc_query_impl[4980b7cf5b7996c7]::DynamicConfig<rustc_query_system[873a9c0fbeb3d104]::query::caches::VecCache<rustc_span[b8184c5be003882b]::def_id::LocalDefId, rustc_middle[e970cc282ff9b1b5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[4980b7cf5b7996c7]::plumbing::QueryCtxt, false>
  30:     0x7f59aac63151 - rustc_query_impl[4980b7cf5b7996c7]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f59aa78151c - <rustc_session[dcce3550ca159092]::session::Session>::time::<(), rustc_interface[f0d27452ef10947b]::passes::analysis::{closure#2}>
  32:     0x7f59aa77e96b - rustc_interface[f0d27452ef10947b]::passes::analysis
  33:     0x7f59aa74e3fa - rustc_query_impl[4980b7cf5b7996c7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4980b7cf5b7996c7]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e970cc282ff9b1b5]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f59aa74e3e9 - <rustc_query_impl[4980b7cf5b7996c7]::query_impl::analysis::dynamic_query::{closure#2} as core[951439f994106a2d]::ops::function::FnOnce<(rustc_middle[e970cc282ff9b1b5]::ty::context::TyCtxt, ())>>::call_once
  35:     0x7f59aa9eca84 - rustc_query_system[873a9c0fbeb3d104]::query::plumbing::try_execute_query::<rustc_query_impl[4980b7cf5b7996c7]::DynamicConfig<rustc_query_system[873a9c0fbeb3d104]::query::caches::SingleCache<rustc_middle[e970cc282ff9b1b5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[4980b7cf5b7996c7]::plumbing::QueryCtxt, false>
  36:     0x7f59aa9ec7f9 - rustc_query_impl[4980b7cf5b7996c7]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f59aa833ce2 - <rustc_middle[e970cc282ff9b1b5]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[418485cfdc98bfaa]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>>
  38:     0x7f59aa832761 - rustc_span[b8184c5be003882b]::set_source_map::<core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>, rustc_interface[f0d27452ef10947b]::interface::run_compiler<core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>, rustc_driver_impl[418485cfdc98bfaa]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  39:     0x7f59aa82d340 - std[b4843c1823a37d1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f0d27452ef10947b]::util::run_in_thread_with_globals<rustc_interface[f0d27452ef10947b]::interface::run_compiler<core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>, rustc_driver_impl[418485cfdc98bfaa]::run_compiler::{closure#1}>::{closure#0}, core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>>
  40:     0x7f59aab5bb6e - <<std[b4843c1823a37d1]::thread::Builder>::spawn_unchecked_<rustc_interface[f0d27452ef10947b]::util::run_in_thread_with_globals<rustc_interface[f0d27452ef10947b]::interface::run_compiler<core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>, rustc_driver_impl[418485cfdc98bfaa]::run_compiler::{closure#1}>::{closure#0}, core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[951439f994106a2d]::result::Result<(), rustc_span[b8184c5be003882b]::ErrorGuaranteed>>::{closure#1} as core[951439f994106a2d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f59a8172395 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3bfe3c242a461003
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/alloc/src/boxed.rs:2007:9
  42:     0x7f59a8172395 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9293481db72dd923
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/alloc/src/boxed.rs:2007:9
  43:     0x7f59a8172395 - std::sys::unix::thread::Thread::new::thread_start::h643847fe85be950e
                               at /rustc/c5450191f313658d206dc7539311f665a274947f/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f59a7e8c9eb - <unknown>
  45:     0x7f59a7f10dfc - <unknown>
  46:                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: please attach the file at `/tmp/im/rustc-ice-2023-09-29T14:12:02.343060416Z-1922983.txt` to your bug report

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `enum_upvar::{closure#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 4 warnings emitted

@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 Sep 29, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 29, 2023
@matthiaskrgr
Copy link
Member Author

probably #115759 cc @oli-obk

@matthiaskrgr matthiaskrgr added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Sep 29, 2023
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 29, 2023
@matthiaskrgr
Copy link
Member Author

Heh, so this code is from tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs and I can't figure out why the test did not fail in ci :|

@lqd
Copy link
Member

lqd commented Sep 29, 2023

Has there been a nightly with this PR?

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Sep 29, 2023

not yet, only master[1] toolchain has it, 2023-09-29 will be the next nightly that has it, if you can wait a couple hours

[1] https://github.com/kennytm/rustup-toolchain-install-master

@lqd
Copy link
Member

lqd commented Sep 29, 2023

Yeah that's fun, the test passes on master for me. It ICEs "late" via codegen or something: a check build works (the test is a check-pass), while a build ICEs.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 5, 2023
Move subtyper below reveal_all and change reveal_all

In previous attempt rust-lang#116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? `@oli-obk`

Fixes rust-lang#116332
Fixes rust-lang#116265
Fixes rust-lang#116383
Fixes rust-lang#116333
@bors bors closed this as completed in 08cc742 Oct 5, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 5, 2023
Rollup merge of rust-lang#116415 - ouz-a:move_subtyper, r=oli-obk

Move subtyper below reveal_all and change reveal_all

In previous attempt rust-lang#116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? ``@oli-obk``

Fixes rust-lang#116332
Fixes rust-lang#116265
Fixes rust-lang#116383
Fixes rust-lang#116333
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. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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
4 participants