Skip to content

ICE: !self.intercrate #125767

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

use std::marker::Unsize;
use std::ops::CoerceUnsized;

struct Foo<T: ?Sized>();

impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}

trait Baz {}

impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> {}

original:

#![feature(Unsize, unsize)]

use std::marker::Unsize;
use std::ops::CoerceUnsized;

struct Foo<T: ?Sized>(Sized<Sized>);

impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}

struct Bar;

trait Baz {}

impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> where T: Unsize<dyn Baz> {}

fn main() {
    let foo = Foo(Box::new(Bar));
    let foobar: Foo<Bar> = foo;
}

Version information

rustc 1.80.0-nightly (32a3ed229 2024-05-30)
binary: rustc
commit-hash: 32a3ed229caaaa6476ee1b0e644dd53579454536
commit-date: 2024-05-30
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

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

Program output

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:10:50
   |
10 | impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> {}
   |                                                  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs`

error[E0658]: use of unstable library feature 'unsize'
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:1:5
  |
1 | use std::marker::Unsize;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
  = help: add `#![feature(unsize)]` to the crate attributes to enable
  = note: this compiler was built on 2024-05-30; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'coerce_unsized'
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:2:5
  |
2 | use std::ops::CoerceUnsized;
  |     ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
  = help: add `#![feature(coerce_unsized)]` to the crate attributes to enable
  = note: this compiler was built on 2024-05-30; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'unsize'
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:6:52
  |
6 | impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}
  |                                                    ^^^^^^^^^^^^^^^
  |
  = note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
  = help: add `#![feature(unsize)]` to the crate attributes to enable
  = note: this compiler was built on 2024-05-30; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'coerce_unsized'
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:6:9
  |
6 | impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}
  |         ^^^^^^^^^^^^^^^^
  |
  = note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
  = help: add `#![feature(coerce_unsized)]` to the crate attributes to enable
  = note: this compiler was built on 2024-05-30; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'coerce_unsized'
  --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:10:9
   |
10 | impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> {}
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
   = help: add `#![feature(coerce_unsized)]` to the crate attributes to enable
   = note: this compiler was built on 2024-05-30; consider upgrading it if it is out of date

error[E0392]: type parameter `T` is never used
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:4:12
  |
4 | struct Foo<T: ?Sized>();
  |            ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:6:34
  |
6 | impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}
  |                                  ^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
6 | impl<T> CoerceUnsized<T> for Foo<dyn Baz> where Sized: Unsize<dyn Baz> {}
  |                                  +++

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.Bm3NPGHQeVBY/rustc_testrunner_tmpdir_reporting.v0YvINHKPADK/mvce.rs:6:45
  |
6 | impl<T> CoerceUnsized<T> for Foo<Baz> where Sized: Unsize<dyn Baz> {}
  |                                             ^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: if this is an object-safe trait, use `dyn`
  |
6 | impl<T> CoerceUnsized<T> for Foo<Baz> where dyn Sized: Unsize<dyn Baz> {}
  |                                             +++

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs:90:13:
assertion failed: !self.intercrate
stack backtrace:
   0:     0x7782549e2cc5 - std::backtrace_rs::backtrace::libunwind::trace::h678682a49ad9b996
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7782549e2cc5 - std::backtrace_rs::backtrace::trace_unsynchronized::hee6fa95bb2553111
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7782549e2cc5 - std::sys_common::backtrace::_print_fmt::h95e0b5b079a7d050
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7782549e2cc5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5ef0519e3348f4b3
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x778254a336bb - core::fmt::rt::Argument::fmt::h351d794db9ebf8d4
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/rt.rs:165:63
   5:     0x778254a336bb - core::fmt::write::hf6a10f4e291514d0
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/fmt/mod.rs:1168:21
   6:     0x7782549d799f - std::io::Write::write_fmt::h3774e539b39c6176
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/io/mod.rs:1835:15
   7:     0x7782549e2a9e - std::sys_common::backtrace::_print::h0766b9d4e4e1a2a5
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7782549e2a9e - std::sys_common::backtrace::print::hf85a15b68fc127ec
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7782549e54d9 - std::panicking::default_hook::{{closure}}::hba9aa02e8bae00f0
  10:     0x7782549e527a - std::panicking::default_hook::h1795c37d9b50a345
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:298:9
  11:     0x778251140d00 - std[fbc7945dfe4e847c]::panicking::update_hook::<alloc[648a2435367f9e21]::boxed::Box<rustc_driver_impl[4c120566f3914dcc]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7782549e5c0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb26c638276518655
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2077:9
  13:     0x7782549e5c0b - std::panicking::rust_panic_with_hook::h9450536fa6827029
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:799:13
  14:     0x7782549e594b - std::panicking::begin_panic_handler::{{closure}}::ha4d0dbca7355d76a
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:656:13
  15:     0x7782549e3189 - std::sys_common::backtrace::__rust_end_short_backtrace::h20e49e7e3e79da68
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7782549e56b7 - rust_begin_unwind
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/panicking.rs:652:5
  17:     0x778254a2fc53 - core::panicking::panic_fmt::h731c162467d8bd18
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/panicking.rs:72:14
  18:     0x778254a2fcfc - core::panicking::panic::h326e19f9006f6a54
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/core/src/panicking.rs:146:5
  19:     0x77825027650d - <rustc_infer[94dcf74a7bd108a5]::infer::InferCtxt as rustc_trait_selection[294db240007bd44b]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  20:     0x778251cf1ffe - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::need_migrate_deref_output_trait_object
  21:     0x77825321b6f3 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::assemble_candidates_for_unsizing
  22:     0x77824f2dffc9 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  23:     0x77824f31fc30 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::candidate_from_obligation
  24:     0x7782529fda6d - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  25:     0x7782529ed6f4 - <rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::evaluation_probe::<<rustc_trait_selection[294db240007bd44b]::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}
  26:     0x7782529ec50f - rustc_trait_selection[294db240007bd44b]::traits::coherence::overlap
  27:     0x77825332451b - <rustc_middle[be94168a967605d5]::traits::specialization_graph::Children as rustc_trait_selection[294db240007bd44b]::traits::specialize::specialization_graph::ChildrenExt>::insert
  28:     0x77824f5b2198 - <rustc_middle[be94168a967605d5]::traits::specialization_graph::Graph as rustc_trait_selection[294db240007bd44b]::traits::specialize::specialization_graph::GraphExt>::insert
  29:     0x7782527cf9a9 - rustc_trait_selection[294db240007bd44b]::traits::specialize::specialization_graph_provider
  30:     0x7782527cf52f - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 8usize]>>
  31:     0x778252812127 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefIdCache<rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
  32:     0x778252b5eeca - rustc_query_impl[c0e0181520bdf354]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7782528b8a2f - rustc_hir_analysis[9feabfd3ed563fae]::coherence::coherent_trait
  34:     0x7782528b876f - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>
  35:     0x778252a307d3 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefIdCache<rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
  36:     0x778252a2f039 - rustc_query_impl[c0e0181520bdf354]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  37:     0x778252aa3d47 - rustc_hir_analysis[9feabfd3ed563fae]::check::wfcheck::check_well_formed
  38:     0x778252aa1651 - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>
  39:     0x778252aa0de6 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::VecCache<rustc_hir[ff494050faa84113]::hir_id::OwnerId, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
  40:     0x778252aa0b64 - rustc_query_impl[c0e0181520bdf354]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  41:     0x778252a9ea37 - rustc_hir_analysis[9feabfd3ed563fae]::check::wfcheck::check_mod_type_wf
  42:     0x778252a9e861 - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>
  43:     0x7782530cfef0 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::DefaultCache<rustc_span[41e37a1bb73e38bc]::def_id::LocalModDefId, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
  44:     0x7782530cfc99 - rustc_query_impl[c0e0181520bdf354]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  45:     0x778252857490 - rustc_hir_analysis[9feabfd3ed563fae]::check_crate
  46:     0x7782530275fe - rustc_interface[c870be2efde3492c]::passes::analysis
  47:     0x77825302715b - rustc_query_impl[c0e0181520bdf354]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0e0181520bdf354]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>
  48:     0x77825338f725 - rustc_query_system[a635211d769013fd]::query::plumbing::try_execute_query::<rustc_query_impl[c0e0181520bdf354]::DynamicConfig<rustc_query_system[a635211d769013fd]::query::caches::SingleCache<rustc_middle[be94168a967605d5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0e0181520bdf354]::plumbing::QueryCtxt, false>
  49:     0x77825338f48f - rustc_query_impl[c0e0181520bdf354]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  50:     0x77825322120e - rustc_interface[c870be2efde3492c]::interface::run_compiler::<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}
  51:     0x7782531e23c9 - std[fbc7945dfe4e847c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c870be2efde3492c]::util::run_in_thread_with_globals<rustc_interface[c870be2efde3492c]::util::run_in_thread_pool_with_globals<rustc_interface[c870be2efde3492c]::interface::run_compiler<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>
  52:     0x7782531e2172 - <<std[fbc7945dfe4e847c]::thread::Builder>::spawn_unchecked_<rustc_interface[c870be2efde3492c]::util::run_in_thread_with_globals<rustc_interface[c870be2efde3492c]::util::run_in_thread_pool_with_globals<rustc_interface[c870be2efde3492c]::interface::run_compiler<core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>, rustc_driver_impl[4c120566f3914dcc]::run_compiler::{closure#0}>::{closure#1}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d46e2ae36dee942]::result::Result<(), rustc_span[41e37a1bb73e38bc]::ErrorGuaranteed>>::{closure#2} as core[6d46e2ae36dee942]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7782549efbfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d22407a994a8dd7
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
  54:     0x7782549efbfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he08091f4f7e587cf
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/alloc/src/boxed.rs:2063:9
  55:     0x7782549efbfb - std::sys::pal::unix::thread::Thread::new::thread_start::h4ffcec4576023b2b
                               at /rustc/32a3ed229caaaa6476ee1b0e644dd53579454536/library/std/src/sys/pal/unix/thread.rs:108:17
  56:     0x77824deaa1cf - <unknown>
  57:     0x77824df2b6ec - <unknown>
  58:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.80.0-nightly (32a3ed229 2024-05-30) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `core::ops::unsize::CoerceUnsized`
#1 [coherent_trait] coherence checking all impls of trait `core::ops::unsize::CoerceUnsized`
end of query stack
error: aborting due to 7 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0392, E0601, E0658.
For more information about an error, try `rustc --explain E0392`.

@rustbot label +F-Unsize +F-unsize

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions