Open jerryajay opened 4 years ago
It's not really clear what this issue is about. Are you using RLS? I'm assuming it's displaying the suggestions in this error message?
error[E0425]: cannot find value `x` in this scope
--> src/main.rs:23:18
|
23 | let point = {x = 12; y = 45};
| ^ help: a local variable with a similar name exists: `s`
If so, that is definitely a correct error message and help
, even if the result is not what you wanted (help
is only a suggestion, not a solution, after all).
Maybe we can add extra diagnostics for syntax that looks like a C struct initializer, but I don't think too many people hit this.
Yes, RLS is being used. Rust is powerful for a blatant help message like this. I'll submit a pull request for the extra diagnostics - time permitting.
Hi, there's a auto-fix bug. I'm using VSCode. The code explains itself:
I tried this code:
I expected to see the auto-fix suggest ways to print Point correctly.
Instead, auto-fix in VSCode suggests changing x and y to s in line 23. However, the error message from rust displays fine.
Meta
rustc --version --verbose
:Backtrace
``` RUST_BACKTRACE=1 cargo build Compiling hello_world v0.1.0 (/home/jerry/rust-experiment/hello_world) error: 1 positional argument in format string, but no arguments were given --> src/main.rs:26:15 | 26 | println!("{}") | ^^ error[E0425]: cannot find value `x` in this scope --> src/main.rs:23:9 | 23 | x = 12; | ^ help: a local variable with a similar name exists: `s` error[E0425]: cannot find value `y` in this scope --> src/main.rs:24:9 | 24 | y = 45; | ^ help: a local variable with a similar name exists: `s` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. error: could not compile `hello_world`. ```