Skip to content

error performing operation: fully_perform in ascribe_user_type #138707

Open
@VincentVanlaer

Description

@VincentVanlaer

The following code is a minimization from some code using nalgebra.

The ICE is gone if any of the following changes are made

  • Allocator<U2> is added to the bounds of ice
  • Allocator<D> is removed from the bounds of ice
  • the associated type Buffer is not used on the From implementation
  • -Znext-solver is used

Code

use core::marker::PhantomData;

struct LeftReflector<S> {
    _phantom: PhantomData<S>,
}

struct DefaultAllocator {}

trait Allocator<R> {
    type Buffer;
}

struct U2 {}

impl Allocator<U2> for DefaultAllocator {
    type Buffer = [u8; 2];
}

impl<R> From<R> for LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer>
where
    DefaultAllocator: Allocator<R>,
{
    fn from(_: R) -> Self {
        todo!()
    }
}

fn ice<D>(a: U2)
where
    DefaultAllocator: Allocator<D>,
{
    // ICE
    let _ = LeftReflector::from(a);
}

// Uncomment the following two functions to get an error instead of an ICE

// fn error<D: Dim>(a: U2)
// where
//     DefaultAllocator: Allocator<D>,
// {
//     // Normal error, R of to_reflector is inferred as D instead of U2
//     let _ = to_reflector(a);
// }
//
// fn to_reflector<R: Dim>(_: R) -> LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer>
// where
//     DefaultAllocator: Allocator<R>,
// {
//     todo!()
// }

// This has no issues

// fn all_fine<D: Dim>(a: U2) {
//     let _ = LeftReflector::from(a);
// }

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (75530e9f7 2025-03-18)
binary: rustc
commit-hash: 75530e9f72a1990ed2305e16fd51d02f47048f12
commit-date: 2025-03-18
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Error output

error: internal compiler error: error performing operation: fully_perform
Backtrace

note: delayed at /rustc/75530e9f72a1990ed2305e16fd51d02f47048f12/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker>::ascribe_user_type
         5: rustc_borrowck::type_check::type_check
         6: rustc_borrowck::nll::compute_regions
         7: rustc_borrowck::do_mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        11: rustc_interface::passes::run_required_analyses
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        15: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: start_thread
        22: __GI___clone3

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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