The code below is known broken - I'd like to review the diagnostic output from Rust Analyzer (nightly) in Visual Studio Code (current release) on that:
trait SomeInteger { fn bleep(&self); }
impl SomeInteger for i8 { fn bleep(&self) {} }
impl SomeInteger for i32 { fn bleep(&self) {} }
fn bleep_it(a: Box<dyn SomeInteger>) {
a.bleep();
}
fn main() {
let number_of_yaks = 3;
bleep_it(Box::new(number_of_yaks));
print!("we have run out of {yaks} to shave");
}
The above source code yields diagnostic output in Rust Analyzer where I have highlighted the one root cause of all these diagnostics somewhere buried deep inthe middle of a pile of things:
...
rustc emits
...
error[E0425]: cannot find value `yaks` in this scope
--> src/tracing_error.rs:13:32
|
13 | print!("we have run out of {yaks} to shave");
| ^^^^^^ not found in this scope
error[E0283]: type annotations needed for `{integer}`
--> src/tracing_error.rs:12:14
|
10 | let number_of_yaks = 3;
| -------------- consider giving `number_of_yaks` a type
11 |
12 | bleep_it(Box::new(number_of_yaks));
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type `{integer}`
|
note: multiple `impl`s satisfying `{integer}: SomeInteger` found
--> src/tracing_error.rs:2:1
|
2 | impl SomeInteger for i8 { fn bleep(&self) {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^
3 | impl SomeInteger for i32 { fn bleep(&self) {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: required for the cast to the object type `dyn SomeInteger`
...
which has different ordering - and which in this case is much more applicable.
Is there a way in Rust Analyzer to, perhaps, get the diagnostic output into a better shape?