When using multiple transmitters with a single receiver across multiple thread, the :help message is totally bonkers. Refer the backtrace lines 10 and 16:
use std::sync::mpsc::channel;
use std::thread;
fn main() {
let (tx1, rx) = channel();
let tx2 = tx1.clone();
thread::spawn(move || {
for i in 1..10 {
tx.send(i);
}
});
thread::spawn(move || {
for i in 1..10 {
tx.send(i);
}
});
for i in 1..10 {
println!("{}", rx.recv().unwrap());
}
}
The auto-fix seems to be too ambitious at the moment by suggesting wrong fixes. Let me know if I need to file a RFC for this. JAVA's auto-fix seems smarter and Rust can definitely borrow some of it's implementation.
```
Compiling hello_world v0.1.0 (/home/jerry/rust-experiment/hello_world)
error[E0425]: cannot find value `tx` in this scope
--> src/main.rs:10:13
|
10 | tx.send(i);
| ^^ help: a local variable with a similar name exists: `rx`
error[E0425]: cannot find value `tx` in this scope
--> src/main.rs:16:13
|
16 | tx.send(i);
| ^^ help: a local variable with a similar name exists: `rx`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
error: could not compile `hello_world`.
To learn more, run the command again with --verbose.
```
When using multiple transmitters with a single receiver across multiple thread, the
:help
message is totally bonkers. Refer thebacktrace
lines 10 and 16:The auto-fix seems to be too ambitious at the moment by suggesting wrong fixes. Let me know if I need to file a RFC for this. JAVA's auto-fix seems smarter and Rust can definitely borrow some of it's implementation.
Meta
rustc --version --verbose
:Backtrace
``` Compiling hello_world v0.1.0 (/home/jerry/rust-experiment/hello_world) error[E0425]: cannot find value `tx` in this scope --> src/main.rs:10:13 | 10 | tx.send(i); | ^^ help: a local variable with a similar name exists: `rx` error[E0425]: cannot find value `tx` in this scope --> src/main.rs:16:13 | 16 | tx.send(i); | ^^ help: a local variable with a similar name exists: `rx` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`. error: could not compile `hello_world`. To learn more, run the command again with --verbose. ```