I don't know how else to say this, but a refactoring I am performing is absolutely breaking my compiler and I have no idea what is going on. Please bear with me, this is weird and frustrating to me and I have no way forward anymore.
What I am doing is I have moved some types from my crate A to another crate B. Literally copy-pasted them. I also added the dependency correctly. So what I am doing to refactor without breaking everything in my crate is to pub use
the types in the modules that used them.
Say I had this code in crate A:
pub struct Foo {
//fields
}
I moved this structure to crate B and changed the code in crate A to:
pub use B::Foo;
I am doing this one by one and this works perfectly fine, except for when I hit a particular struct. I don't think the struct itself is important, but here it goes:
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
pub struct UnivariateLinearRegressionSolution<F: Scalar + Float + ConstOne> {
pub slope: F,
pub intercept: F,
pub jtj_inv: OMatrix<F, U2, U2>,
pub sample_variance: F,
}
The type OMatrix
is a matrix type from nalgebra.
I can still check my code using cargo check
, but as soon as I do cargo check --tests
, I get hundreds of errors such as
error[E0599]: no method named `len` found for reference `&[F]` in the current scope
--> rdb-lib\src\regression.rs:171:33
|
171 | if independent_variable.len() < 2 {
| ^^^
|
(Note that this error is not even in test code. This is non-test code that passes cargo check)
or
error[E0599]: no method named `as_ptr` found for reference `&[f32]` in the current scope
--> rdb-lib\src\test_util.rs:25:41
There are tons of other failures. It seems it recognizes absolutely no associated functions anymore on any type, mine or foreign.
I've tried:
- doing this refactor from the beginning (this is my third time)
- cargo clean
- uninstalling and installing the Rust toolchain again
- using a different Rust toolchain (i am currently on 1.81.0)
- changing operating systems
When I continue with the refactoring it gets so bad that downstream dependencies stop building because the compiler claims it cannot find the (EDIT: this was caused by something completely unrelated). Please help and thank you.alloc
module anymore