rust-lang / rust-lang/rust

error performing operation: fully_perform in ascribe_user_type

Open
#138,707 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-associated-items A-type-system C-bug fixed-by-next-solver I-ICE S-bug-has-test T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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>(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>(_: R) -> LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer>
// where
//     DefaultAllocator: Allocator<R>,
// {
//     todo!()
// }

// This has no issues

// fn all_fine<D>(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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimized Rust program in the issue and reproduce the ICE using the reported nightly compiler. Trace the delayed diagnostic at compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87 and the rustc_borrowck type_check::ascribe_user_type path shown in the backtrace. Compare the listed bound and -Znext-solver variations; done means the reproducer no longer produces an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.