Skip to content

Rust Compiler error with Linear Algebra Crate #143862

@schauma

Description

@schauma

I tried to implement some linear algebra code in rust. I started using rust today so forgive my lack of understanding for most of this. I do not know whether this bug should be reported here or in inside the sprs crate since I am making heavy use of it. I reduced the code as much as I can.

I am using sprs = "0.11.3".

Code

use sprs::{TriMat, CsMat};


pub fn main() {
    println!("Running linear algebra test...");

    let (mat,rhs) = gen_mat_rhs(5);
    
    let res = solve_with_initial(&mat, & rhs, rhs).unwrap();
}

fn gen_mat_rhs(size: usize) -> (CsMat<f64>, CsMat<f64>) {
    let mut mat = TriMat::new((size,size));
    let mut vec = vec![0.0; size];

    for i in 0..size {
        for j in 0..size {
            if i == j {
                mat.add_triplet(i, j, 2.0); // Diagonal entries
            } else if (i as isize - j as isize).abs() == 1 {
                mat.add_triplet(i, j, -1.0); // Off-diagonal entries
            }
        }
        vec[i] = i as f64; // Right-hand side
    }
    let rhs = TriMat::from_triplets((size,1),(0..size).collect(),vec![0;size],vec).to_csr();
    (mat.to_csr(), rhs)
}

fn solve_with_initial( matrix: &CsMat<f64>, rhs: &CsMat<f64>, initial_guess: CsMat<f64>) -> Result<CsMat<f64>, String> {
        
        let mut residual = rhs.clone();
            
        let numerator  =  & residual.transpose_view() * &residual; 
        let denominator = &residual.transpose_view() * &(matrix * &residual);
        let alpha = numerator.data()[0] / denominator.data()[0];

        residual = residual - &(matrix * &residual.map(|x| x * alpha));
        
        Ok(initial_guess)
        
    }

Meta

rustc --version --verbose:

rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5

Error output

RUST_BACKTRACE=1 cargo build --features minimal --no-default-features 
   Compiling FElastics v0.1.0 (/home/user/Documents/Coding/Rust/FElastics)

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/gather_locals.rs:112:17:
assertion `left == right` failed
  left: Some(?162t)
 right: None
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<core::option::Option<rustc_middle::ty::Ty>, core::option::Option<rustc_middle::ty::Ty>>
   4: <rustc_hir_typeck::gather_locals::GatherLocalsVisitor as rustc_hir::intravisit::Visitor>::visit_pat
   5: rustc_hir_typeck::check::check_fn
   6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
   7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
   8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
   9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
  15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
  18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19: rustc_hir_typeck::check::check_fn
  20: rustc_hir_typeck::typeck_with_inspect::{closure#0}
      [... omitted 1 frame ...]
  21: rustc_hir_analysis::check_crate
  22: rustc_interface::passes::run_required_analyses
  23: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  24: 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}
  25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.88.0 (6b00bc388 2025-06-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `algebra::linear::solve_with_initial`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors
Backtrace

RUST_BACKTRACE=1 cargo build --features minimal --no-default-features 
   Compiling FElastics v0.1.0 (/home/user/Documents/Coding/Rust/FElastics)

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/gather_locals.rs:112:17:
assertion `left == right` failed
  left: Some(?162t)
 right: None
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<core::option::Option<rustc_middle::ty::Ty>, core::option::Option<rustc_middle::ty::Ty>>
   4: <rustc_hir_typeck::gather_locals::GatherLocalsVisitor as rustc_hir::intravisit::Visitor>::visit_pat
   5: rustc_hir_typeck::check::check_fn
   6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
   7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
   8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
   9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
  15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
  18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19: rustc_hir_typeck::check::check_fn
  20: rustc_hir_typeck::typeck_with_inspect::{closure#0}
      [... omitted 1 frame ...]
  21: rustc_hir_analysis::check_crate
  22: rustc_interface::passes::run_required_analyses
  23: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  24: 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}
  25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.88.0 (6b00bc388 2025-06-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `algebra::linear::solve_with_initial`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: this path really should be doomed...
  --> src/algebra/linear.rs:41:29
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                             ^
   |
note: delayed at compiler/rustc_hir_typeck/src/op.rs:1003:28
         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, &str>
         4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         9: rustc_hir_typeck::check::check_fn
        10: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        12: 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>
        13: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
        14: rustc_hir_analysis::check_crate
        15: rustc_interface::passes::run_required_analyses
        16: rustc_interface::passes::analysis
        17: 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]>>
        18: 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>
        19: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        20: 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}
        21: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        22: 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}, ()>
        23: <<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}
        24: std::sys::pal::unix::thread::Thread::new::thread_start
        25: start_thread
                   at ./nptl/pthread_create.c:447:8
        26: __GI___clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  --> src/algebra/linear.rs:41:29
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                             ^

error: internal compiler error: `&CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>` overridden by `&CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>` for HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).67) in DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial)
  --> src/algebra/linear.rs:41:33
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                 ^^^^^^
   |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28
         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_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        13: rustc_hir_typeck::check::check_fn
        14: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        16: 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>
        17: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
        18: rustc_hir_analysis::check_crate
        19: rustc_interface::passes::run_required_analyses
        20: rustc_interface::passes::analysis
        21: 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]>>
        22: 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>
        23: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        24: 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}
        25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        26: 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}, ()>
        27: <<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}
        28: std::sys::pal::unix::thread::Thread::new::thread_start
        29: start_thread
                   at ./nptl/pthread_create.c:447:8
        30: __GI___clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  --> src/algebra/linear.rs:41:33
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                 ^^^^^^

error: internal compiler error: `CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>` overridden by `CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>` for HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).72) in DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial)
  --> src/algebra/linear.rs:41:43
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                           ^^^^^^^^
   |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28
         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_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        15: rustc_hir_typeck::check::check_fn
        16: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        18: 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>
        19: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
        20: rustc_hir_analysis::check_crate
        21: rustc_interface::passes::run_required_analyses
        22: rustc_interface::passes::analysis
        23: 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]>>
        24: 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>
        25: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        26: 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}
        27: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        28: 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}, ()>
        29: <<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}
        30: std::sys::pal::unix::thread::Thread::new::thread_start
        31: start_thread
                   at ./nptl/pthread_create.c:447:8
        32: __GI___clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  --> src/algebra/linear.rs:41:43
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                           ^^^^^^^^

error: internal compiler error: while adjusting Expr { hir_id: HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).72), kind: Path(Resolved(None, Path { span: src/algebra/linear.rs:41:43: 41:51 (#0), res: Local(HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).14)), segments: [PathSegment { ident: residual#0, hir_id: HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).73), res: Local(HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).14)), args: None, infer_args: true }] })), span: src/algebra/linear.rs:41:43: 41:51 (#0) }, can't compose [Borrow(Ref(Not)) -> &CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>] and [Borrow(Ref(Not)) -> &CsMatBase<f64, usize, Vec<usize>, Vec<usize>, Vec<f64>>]
  --> src/algebra/linear.rs:41:43
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                           ^^^^^^^^
   |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:348:36
         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_hir_typeck::method::confirm::ConfirmContext>::confirm
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        15: rustc_hir_typeck::check::check_fn
        16: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        18: 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>
        19: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
        20: rustc_hir_analysis::check_crate
        21: rustc_interface::passes::run_required_analyses
        22: rustc_interface::passes::analysis
        23: 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]>>
        24: 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>
        25: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        26: 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}
        27: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        28: 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}, ()>
        29: <<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}
        30: std::sys::pal::unix::thread::Thread::new::thread_start
        31: start_thread
                   at ./nptl/pthread_create.c:447:8
        32: __GI___clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  --> src/algebra/linear.rs:41:43
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                           ^^^^^^^^

error: internal compiler error: `_` overridden by `_` for HirId(DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial).82) in DefId(0:99 ~ FElastics[d797]::algebra::linear::solve_with_initial)
  --> src/algebra/linear.rs:41:57
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                                         ^
   |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28
         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: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::supplied_sig_of_closure
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
        12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_overloaded_binop
        15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        19: rustc_hir_typeck::check::check_fn
        20: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        22: 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>
        23: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
        24: rustc_hir_analysis::check_crate
        25: rustc_interface::passes::run_required_analyses
        26: rustc_interface::passes::analysis
        27: 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]>>
        28: 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>
        29: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        30: 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}
        31: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        32: 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}, ()>
        33: <<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}
        34: std::sys::pal::unix::thread::Thread::new::thread_start
        35: start_thread
                   at ./nptl/pthread_create.c:447:8
        36: __GI___clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  --> src/algebra/linear.rs:41:57
   |
41 |         residual = residual - &(matrix * &residual.map(|x| x * alpha));
   |                                                         ^

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.88.0 (6b00bc388 2025-06-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `FElastics` (bin "FElastics")

Caused by:
  process didn't exit successfully: `/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name FElastics --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=104 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="minimal"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("bevy", "default", "minimal"))' -C metadata=0cc19787b1477fe7 -C extra-filename=-521498a086653e02 --out-dir /home/user/Documents/Coding/Rust/FElastics/target/debug/deps -C incremental=/home/user/Documents/Coding/Rust/FElastics/target/debug/incremental -L dependency=/home/user/Documents/Coding/Rust/FElastics/target/debug/deps --extern ndarray=/home/user/Documents/Coding/Rust/FElastics/target/debug/deps/libndarray-525b2b766d531756.rlib --extern num_traits=/home/user/Documents/Coding/Rust/FElastics/target/debug/deps/libnum_traits-a7224bec943466f9.rlib --extern sprs=/home/user/Documents/Coding/Rust/FElastics/target/debug/deps/libsprs-5390b42860c9b636.rlib --extern thiserror=/home/user/Documents/Coding/Rust/FElastics/target/debug/deps/libthiserror-4c8361a3d054ae28.rlib` (exit status: 101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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