You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Look for similar functions that might be available when encountering type mismatch on resolved fn call argument #164647
On type mismatch on resolved associated functions, we currently output a diagnostic like the following:
[INFO] [stdout] error[E0308]: mismatched types
[INFO] [stdout] --> src/main.rs:29:3
[INFO] [stdout] |
[INFO] [stdout] 28 | let mut nns: Vec<NeuralNetwork> = Vec::from_fn(
[INFO] [stdout] | ------------ arguments to this function are incorrect
[INFO] [stdout] 29 | NUMBER_OF_NNS as u32,
[INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32`
[INFO] [stdout] |
[INFO] [stdout] note: associated function defined here
[INFO] [stdout] --> /rustc/e3feeb59cd1bdd011a2bfcc0747b55125d9b8527/library/alloc/src/vec/mod.rs:795:11
[INFO] [stdout] help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
[INFO] [stdout] |
[INFO] [stdout] 29 | (NUMBER_OF_NNS as u32).try_into().unwrap(),
[INFO] [stdout] | + +++++++++++++++++++++
although serviceable, this diagnostic doesn't account that there's a differentfrom_fn available for Vec (in that project) for which the params would have been correct. Ideally we'd provide a structured suggestion, but at the very least, when we've got enough information to point "arguments to this function are incorrect", it would be nice to look for other functions with the same/similar name within the same module/type (like detecting that foo::from_fn should have been foo::try_from_fn or foo::from_fn_in).
Activity