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: min_specilization When translating substitutions .. the expected specialization failed to hold #109815

Closed
matthiaskrgr opened this issue Mar 31, 2023 · 2 comments · Fixed by #111252
Assignees
Labels
C-bug Category: This is a bug. F-min_specialization `#![feature(min_specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![crate_type="lib"]
#![feature(min_specialization)]

trait X {}
trait Y: X {}
trait Z {
    type Assoc: Y;
}
struct A<T>(T);

impl<T: X> Z for A<T> {}

impl<T: X> From<<A<T> as Z>::Assoc> for T {}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (ec2f40c6b 2023-03-30)
binary: rustc
commit-hash: ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b
commit-date: 2023-03-30
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.0

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/specialize/mod.rs:104:21: When translating substitutions from DefId(0:13 ~ treereduce[d8c8]::{impl#1}) to DefId(2:2554 ~ core[ad74]::convert::{impl#4}), the expected specialization failed to hold

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7fe921565e8a - std::backtrace_rs::backtrace::libunwind::trace::h0800f724f14b9f23
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fe921565e8a - std::backtrace_rs::backtrace::trace_unsynchronized::heb729c2b48914e5d
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe921565e8a - std::sys_common::backtrace::_print_fmt::hfea18c777a6816a8
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fe921565e8a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b335f1b57b7cfd3
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fe9215c9e6f - core::fmt::write::hfc269b47768b84d6
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/core/src/fmt/mod.rs:1254:17
   5:     0x7fe9215589c5 - std::io::Write::write_fmt::h1d662a9c8dd6348d
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/io/mod.rs:1698:15
   6:     0x7fe921565c55 - std::sys_common::backtrace::_print::h077a497ebae0e284
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fe921565c55 - std::sys_common::backtrace::print::h4c1bfafb31892c37
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fe9215688fe - std::panicking::default_hook::{{closure}}::h1d180e0dd97821e1
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/panicking.rs:269:22
   9:     0x7fe9215686a5 - std::panicking::default_hook::hb57aa318320cb549
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/panicking.rs:288:9
  10:     0x7fe924884795 - rustc_driver_impl[5ba0129e8085a63c]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fe9215690f4 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3b37cd4b5b400fd5
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/alloc/src/boxed.rs:1990:9
  12:     0x7fe9215690f4 - std::panicking::rust_panic_with_hook::h9f9047c578e712fa
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/panicking.rs:694:13
  13:     0x7fe924db7381 - std[30ef443cf2df054a]::panicking::begin_panic::<rustc_errors[75c985f96908534a]::ExplicitBug>::{closure#0}
  14:     0x7fe924db4456 - std[30ef443cf2df054a]::sys_common::backtrace::__rust_end_short_backtrace::<std[30ef443cf2df054a]::panicking::begin_panic<rustc_errors[75c985f96908534a]::ExplicitBug>::{closure#0}, !>
  15:     0x7fe924d941e6 - std[30ef443cf2df054a]::panicking::begin_panic::<rustc_errors[75c985f96908534a]::ExplicitBug>
  16:     0x7fe924de8b46 - <rustc_errors[75c985f96908534a]::HandlerInner>::bug::<&alloc[241d486ef18b1517]::string::String>
  17:     0x7fe924de8810 - <rustc_errors[75c985f96908534a]::Handler>::bug::<&alloc[241d486ef18b1517]::string::String>
  18:     0x7fe924de3bcb - rustc_middle[a72f0da90161fe4d]::util::bug::opt_span_bug_fmt::<rustc_span[fd4f398dc0172457]::span_encoding::Span>::{closure#0}
  19:     0x7fe924de314a - rustc_middle[a72f0da90161fe4d]::ty::context::tls::with_opt::<rustc_middle[a72f0da90161fe4d]::util::bug::opt_span_bug_fmt<rustc_span[fd4f398dc0172457]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7fe924de3116 - rustc_middle[a72f0da90161fe4d]::ty::context::tls::with_context_opt::<rustc_middle[a72f0da90161fe4d]::ty::context::tls::with_opt<rustc_middle[a72f0da90161fe4d]::util::bug::opt_span_bug_fmt<rustc_span[fd4f398dc0172457]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7fe924de3b16 - rustc_middle[a72f0da90161fe4d]::util::bug::opt_span_bug_fmt::<rustc_span[fd4f398dc0172457]::span_encoding::Span>
  22:     0x7fe922b0a823 - rustc_middle[a72f0da90161fe4d]::util::bug::bug_fmt
  23:     0x7fe922d912e3 - rustc_trait_selection[b0fa191af389ed74]::traits::specialize::translate_substs
  24:     0x7fe923b7319e - rustc_hir_analysis[d7ef42721b387ff3]::impl_wf_check::min_specialization::check_min_specialization
  25:     0x7fe923b70bdb - rustc_hir_analysis[d7ef42721b387ff3]::impl_wf_check::check_mod_impl_wf
  26:     0x7fe923e867d1 - rustc_query_system[c2820fdbf5c6d6ca]::query::plumbing::try_execute_query::<rustc_query_impl[9d23c39401f72dce]::queries::check_mod_impl_wf, rustc_query_impl[9d23c39401f72dce]::plumbing::QueryCtxt>
  27:     0x7fe923e863f9 - <rustc_query_impl[9d23c39401f72dce]::Queries as rustc_middle[a72f0da90161fe4d]::ty::query::QueryEngine>::check_mod_impl_wf
  28:     0x7fe923ce202f - <rustc_session[173a7fb0306a5cb1]::session::Session>::track_errors::<rustc_hir_analysis[d7ef42721b387ff3]::check_crate::{closure#2}, ()>
  29:     0x7fe923cde362 - rustc_hir_analysis[d7ef42721b387ff3]::check_crate
  30:     0x7fe923cd8241 - rustc_interface[415d18af8a4706e7]::passes::analysis
  31:     0x7fe92403bb82 - rustc_query_system[c2820fdbf5c6d6ca]::query::plumbing::try_execute_query::<rustc_query_impl[9d23c39401f72dce]::queries::analysis, rustc_query_impl[9d23c39401f72dce]::plumbing::QueryCtxt>
  32:     0x7fe92403b880 - <rustc_query_impl[9d23c39401f72dce]::Queries as rustc_middle[a72f0da90161fe4d]::ty::query::QueryEngine>::analysis
  33:     0x7fe9239ff79e - <rustc_interface[415d18af8a4706e7]::queries::QueryResult<&rustc_middle[a72f0da90161fe4d]::ty::context::GlobalCtxt>>::enter::<core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>, rustc_driver_impl[5ba0129e8085a63c]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  34:     0x7fe9239fe33e - <rustc_interface[415d18af8a4706e7]::interface::Compiler>::enter::<rustc_driver_impl[5ba0129e8085a63c]::run_compiler::{closure#1}::{closure#2}, core[ad7470cf32ab1c97]::result::Result<core[ad7470cf32ab1c97]::option::Option<rustc_interface[415d18af8a4706e7]::queries::Linker>, rustc_span[fd4f398dc0172457]::ErrorGuaranteed>>
  35:     0x7fe9239fc4f1 - rustc_span[fd4f398dc0172457]::with_source_map::<core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>, rustc_interface[415d18af8a4706e7]::interface::run_compiler<core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>, rustc_driver_impl[5ba0129e8085a63c]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  36:     0x7fe9239fba9f - std[30ef443cf2df054a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[415d18af8a4706e7]::util::run_in_thread_pool_with_globals<rustc_interface[415d18af8a4706e7]::interface::run_compiler<core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>, rustc_driver_impl[5ba0129e8085a63c]::run_compiler::{closure#1}>::{closure#0}, core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>>
  37:     0x7fe92411934e - <<std[30ef443cf2df054a]::thread::Builder>::spawn_unchecked_<rustc_interface[415d18af8a4706e7]::util::run_in_thread_pool_with_globals<rustc_interface[415d18af8a4706e7]::interface::run_compiler<core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>, rustc_driver_impl[5ba0129e8085a63c]::run_compiler::{closure#1}>::{closure#0}, core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ad7470cf32ab1c97]::result::Result<(), rustc_span[fd4f398dc0172457]::ErrorGuaranteed>>::{closure#1} as core[ad7470cf32ab1c97]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fe9215731d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6e08d5234042fb15
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/alloc/src/boxed.rs:1976:9
  39:     0x7fe9215731d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2c5056bcb5d46eb1
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/alloc/src/boxed.rs:1976:9
  40:     0x7fe9215731d5 - std::sys::unix::thread::Thread::new::thread_start::hbc95b3c4a4c1dd3a
                               at /rustc/ec2f40c6b04f0e9850dd1f454e8639d319f4ed9b/library/std/src/sys/unix/thread.rs:108:17
  41:     0x7fe92130dbb5 - <unknown>
  42:     0x7fe92138fd90 - <unknown>
  43:                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.70.0-nightly (ec2f40c6b 2023-03-30) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_impl_wf] checking that impls are well-formed in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@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. requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Mar 31, 2023
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Mar 31, 2023

searched toolchains nightly-2020-03-12 through nightly-2023-03-31


Regression in nightly-2020-03-18


probably #68970

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 7, 2023
@matthewjasper
Copy link
Contributor

Without standard library code:

#![feature(min_specialization)]

trait X {}
trait Y: X {}
trait Z {
    type Assoc: Y;
}
struct A<T>(T);

impl<T: X> Z for A<T> {}

trait MyFrom<T> {
    fn from(other: T) -> Self;
}

impl<T> MyFrom<T> for T {
    fn from(other: T) -> T {
        other
    }
}

impl<T: X> MyFrom<<A<T> as Z>::Assoc> for T {}

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-min_specialization `#![feature(min_specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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.

4 participants