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 during orphanck with the next solver involving opaque type "covered" by a fundamental type #136188

Open
fmease opened this issue Jan 28, 2025 · 1 comment · May be fixed by #135910
Open

ICE during orphanck with the next solver involving opaque type "covered" by a fundamental type #136188

fmease opened this issue Jan 28, 2025 · 1 comment · May be fixed by #135910
Assignees
Labels
A-coherence Area: Coherence C-bug Category: This is a bug. F-fundamental `#![feature(fundamental)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Comments

@fmease
Copy link
Member

fmease commented Jan 28, 2025

Reproducer

a.rs: rustc a.rs --crate-type=lib:

#![feature(fundamental)]

pub trait Trait {}

#[fundamental]
pub struct Wrap<T>(pub T);

b.rs: rustc b.rs --crate-type=lib --extern a -L. --edition=2021 -Znext-solver:

#![feature(type_alias_impl_trait)]

type Opaque = a::Wrap<impl Sized>;

fn define() -> Opaque { a::Wrap(()) }

impl a::Trait for Opaque {}

Compiler Output

Compiler output (includes backtrace)
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/coherence/orphan.rs:481:22:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x72865b08ea90 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2f23fd9f9d9d249c
   1:     0x72865b814f26 - core::fmt::write::hda581013c22cc38e
   2:     0x72865c778bd1 - std::io::Write::write_fmt::h7b67a2c48701ad74
   3:     0x72865b08e8f2 - std::sys::backtrace::BacktraceLock::print::hf557d5f06e408e4b
   4:     0x72865b090d72 - std::panicking::default_hook::{{closure}}::h003adb2133b1767b
   5:     0x72865b090bfa - std::panicking::default_hook::h16009a902eb48a3c
   6:     0x72865a242759 - std[b112ec976dab40f4]::panicking::update_hook::<alloc[fdb5804898039ca3]::boxed::Box<rustc_driver_impl[8694186ee707eb2f]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x72865b0918f3 - std::panicking::rust_panic_with_hook::h1d06543d16cce998
   8:     0x72865b0915b6 - std::panicking::begin_panic_handler::{{closure}}::h5b7fe21fdd65a607
   9:     0x72865b08ef79 - std::sys::backtrace::__rust_end_short_backtrace::hddbdfb95dc40ef8a
  10:     0x72865b0912ad - rust_begin_unwind
  11:     0x728657d961e0 - core::panicking::panic_fmt::h94f5d8fdec5491a8
  12:     0x72865881f19c - core::panicking::panic::hdce3ddcf69ca9a10
  13:     0x7286592923c9 - core::option::unwrap_failed::h27f2e94e7dd4b9a4
  14:     0x728658fdf279 - rustc_hir_analysis[13152efa0adca590]::coherence::orphan::orphan_check_impl
  15:     0x72865be835a5 - rustc_query_impl[1da25cef12df1694]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1da25cef12df1694]::query_impl::orphan_check_impl::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>
  16:     0x72865be83907 - rustc_query_system[35b3a8f846374855]::query::plumbing::try_execute_query::<rustc_query_impl[1da25cef12df1694]::DynamicConfig<rustc_data_structures[eb304daffe7c7b80]::vec_cache::VecCache<rustc_span[863c7cf5cfba53d9]::def_id::LocalDefId, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[35b3a8f846374855]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1da25cef12df1694]::plumbing::QueryCtxt, false>
  17:     0x72865be83334 - rustc_query_impl[1da25cef12df1694]::query_impl::orphan_check_impl::get_query_non_incr::__rust_end_short_backtrace
  18:     0x72865bf6004c - rustc_hir_analysis[13152efa0adca590]::coherence::coherent_trait
  19:     0x72865bf5f577 - rustc_query_impl[1da25cef12df1694]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1da25cef12df1694]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>
  20:     0x72865bb2ebef - rustc_query_system[35b3a8f846374855]::query::plumbing::try_execute_query::<rustc_query_impl[1da25cef12df1694]::DynamicConfig<rustc_query_system[35b3a8f846374855]::query::caches::DefIdCache<rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1da25cef12df1694]::plumbing::QueryCtxt, false>
  21:     0x72865bb2dc22 - rustc_query_impl[1da25cef12df1694]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  22:     0x72865be85b5e - rustc_hir_analysis[13152efa0adca590]::check::wfcheck::check_well_formed
  23:     0x72865be84147 - rustc_query_impl[1da25cef12df1694]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1da25cef12df1694]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>
  24:     0x72865be83be9 - rustc_query_system[35b3a8f846374855]::query::plumbing::try_execute_query::<rustc_query_impl[1da25cef12df1694]::DynamicConfig<rustc_data_structures[eb304daffe7c7b80]::vec_cache::VecCache<rustc_span[863c7cf5cfba53d9]::def_id::LocalDefId, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[35b3a8f846374855]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1da25cef12df1694]::plumbing::QueryCtxt, false>
  25:     0x72865be83646 - rustc_query_impl[1da25cef12df1694]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  26:     0x72865be8126c - rustc_hir_analysis[13152efa0adca590]::check::wfcheck::check_mod_type_wf
  27:     0x72865be8108b - rustc_query_impl[1da25cef12df1694]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1da25cef12df1694]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>
  28:     0x72865c77d3c8 - rustc_query_system[35b3a8f846374855]::query::plumbing::try_execute_query::<rustc_query_impl[1da25cef12df1694]::DynamicConfig<rustc_query_system[35b3a8f846374855]::query::caches::DefaultCache<rustc_span[863c7cf5cfba53d9]::def_id::LocalModDefId, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1da25cef12df1694]::plumbing::QueryCtxt, false>
  29:     0x72865c77d170 - rustc_query_impl[1da25cef12df1694]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  30:     0x72865bb82ce6 - rustc_hir_analysis[13152efa0adca590]::check_crate
  31:     0x72865bb7f5a2 - rustc_interface[7b6200b50ffd4527]::passes::run_required_analyses
  32:     0x72865c7742de - rustc_interface[7b6200b50ffd4527]::passes::analysis
  33:     0x72865c7742af - rustc_query_impl[1da25cef12df1694]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1da25cef12df1694]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 0usize]>>
  34:     0x72865c75bbd5 - rustc_query_system[35b3a8f846374855]::query::plumbing::try_execute_query::<rustc_query_impl[1da25cef12df1694]::DynamicConfig<rustc_query_system[35b3a8f846374855]::query::caches::SingleCache<rustc_middle[a35b023f906b1e15]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1da25cef12df1694]::plumbing::QueryCtxt, false>
  35:     0x72865c75b90e - rustc_query_impl[1da25cef12df1694]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x72865c788a29 - rustc_interface[7b6200b50ffd4527]::passes::create_and_enter_global_ctxt::<core[1c802f461cf195ce]::option::Option<rustc_interface[7b6200b50ffd4527]::queries::Linker>, rustc_driver_impl[8694186ee707eb2f]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  37:     0x72865c7c3dd3 - rustc_interface[7b6200b50ffd4527]::interface::run_compiler::<(), rustc_driver_impl[8694186ee707eb2f]::run_compiler::{closure#0}>::{closure#1}
  38:     0x72865c6857f5 - std[b112ec976dab40f4]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7b6200b50ffd4527]::util::run_in_thread_with_globals<rustc_interface[7b6200b50ffd4527]::util::run_in_thread_pool_with_globals<rustc_interface[7b6200b50ffd4527]::interface::run_compiler<(), rustc_driver_impl[8694186ee707eb2f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x72865c6854d9 - <<std[b112ec976dab40f4]::thread::Builder>::spawn_unchecked_<rustc_interface[7b6200b50ffd4527]::util::run_in_thread_with_globals<rustc_interface[7b6200b50ffd4527]::util::run_in_thread_pool_with_globals<rustc_interface[7b6200b50ffd4527]::interface::run_compiler<(), rustc_driver_impl[8694186ee707eb2f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1c802f461cf195ce]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x72865c684c6f - std::sys::pal::unix::thread::Thread::new::thread_start::hf2e53aa54a2bf93d
  41:     0x728656aa339d - <unknown>
  42:     0x728656b2849c - <unknown>
  43:                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.86.0-nightly (1e9b0177d 2025-01-24) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z next-solver

query stack during panic:
#0 [orphan_check_impl] checking whether impl `<impl at b.rs:8:1: 8:62>` follows the orphan rules
#1 [coherent_trait] coherence checking all impls of trait `a::Trait`
... and 3 other queries... use `env RUST_BACKTRACE=1` to see the full query stack

Meta

I semi-knowingly introduced this bug in #117164, see FIXMEs (I just didn't have any reproducers (this likely isn't the only one)).

@fmease fmease added A-coherence Area: Coherence C-bug Category: This is a bug. F-fundamental `#![feature(fundamental)]` 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jan 28, 2025
@fmease fmease self-assigned this Jan 28, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 28, 2025
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 28, 2025
@fmease
Copy link
Member Author

fmease commented Jan 28, 2025

Right, by using stdlib items we can shorten this to:

rustc file.rs --crate-type=lib -Znext-solver

#![feature(type_alias_impl_trait)]

type Opaque = Box<impl Sized>;

fn define() -> Opaque { Box::new(()) }

impl Copy for Opaque {}

(Box is #[fundamental] and non-local, Copy is non-local)

@fmease fmease added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Jan 28, 2025
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Mar 9, 2025
@fmease fmease linked a pull request Apr 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coherence Area: Coherence C-bug Category: This is a bug. F-fundamental `#![feature(fundamental)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants