-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Error on DMatrix::zeros(rows, cols) #5441
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
Comments
The issue still persists, even in the latest release from Monday (which I only installed today). |
This issue still persists. The following code compiles just fine, but rust-analyzer claims an argument mismatch. fn main() {
println!("{}", nalgebra::DMatrix::<i32>::zeros(3, 3));
} |
Seem like this macro invocation expanded incorrectly. |
Wait, there are multiple version of implementation for |
This is still occurring to this day. rust-analyzer still seems to be choosing the first implementation on MatrixMN, rather than choosing the correct implementation. |
#8654 seems to be fixed, but this one still persists. I think the problem is that we don't check trait bounds of the impl during method resolution, so we just choose the first impl. |
Here's a minimized version of this test case: pub trait Trait {}
pub struct Nope;
// impl !Trait for Nope {} <- because it is not implemented in this crate
pub struct Foo<T>(T);
impl<T: Trait> Foo<T> {
pub fn foo() -> Self { panic!() }
}
impl Foo<Nope> {
pub fn foo(_: usize) -> Self { panic!() }
}
fn foo() -> Foo<Nope> {
Foo::<Nope>::foo(3)
} It looks like it's a bit different from #11803 after all. In this case the issue is that rustc will exclude the first impl since |
Yeah, that's what I meant by "we don't check trait bounds of the impl during method resolution" -- we currently only check the trait bounds after selecting the method, but we have to do a preliminary check before selecting it. |
Related: #10481. |
Having the same issue. Is there any workaround that I can use to suspend this error? Thanks! |
rls has no false positives |
when i go to definition of zeros(), it's something different |
it points to at nalgebra/src/base/construction.rs
|
This issue seems to happen on all constructor or let dm1 = DMatrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]);
let dm2 = DMatrix::from_diagonal_element(2, 3, 5.0);
let dm3 = DMatrix::<f32>::identity(2, 3);
let dm4 = DMatrix::from_fn(2, 3, |i, j| i * 3 + j); all is from official example, but it has |
I can still recreate this as well unfortunately. Let me know if you'd like more info. |
For me (on current weekly version), this version introduced a regression that causes
DMatrix
to be picked up incorrectly when usingDMatrix::zeros()
. It claims that there is no arguments:However, a
cargo check
passes just fine, and I am actually building and running this code currently as part of another program, so it is certain that it does work. In fact, the last version did not have this issue.My suspicion is that it is incorrectly picking up the first
Matrix::zeros()
. Nalgebra has four definitions ofzeros()
onMatrix
, each of which may be used depending on which dimensions areDynamic
or which implDimName
.I will let everyone know if this issue goes away on Monday.
The text was updated successfully, but these errors were encountered: