4 ms·
The part complaining about missing details in the error message seems weird. You get a pretty detailed error even without using `--explain`: error[E0384]:
by CodesInChaos 6y ago
The part complaining about missing details in the error message seems weird. You get a pretty detailed error even without using `--explain`:
error[E0384]: cannot assign twice to immutable variable `x`
--> src/main.rs:4:5
|
3 | let x = 3;
| -
| |
| first assignment to `x`
| help: make this binding mutable: `mut x`
4 | x = 5;
| ^^^^^ cannot assign twice to immutable variable
error: aborting due to previous error; 2 warnings emitted
For more information about this error, try `rustc --explain E0384`.
- Item_Boring 6y agoAs someone who started learning Rust a few days ago I find its compiler errors incredibly helpful! I don’t quite understand the author‘s complaint either - the error message in the example (like most others) does state quite precisely what went wrong and how to fix it (By default, variables in Rust are immutable. To fix this error, add the keyword `mut` after the keyword `let` when declaring the variable.). I wonder what the author is wishing for?
- colejohnson66 6y agoDefault mutability like practically every large language? I’ll admit, both have their uses, but if you’re striving for less runtime errors, default immutability makes more sense.
- rowanG077 6y agoThese are not runtime errors. But regardless I rather like a runtime error instead of doing the wrong thing.
- colejohnson66 6y agoWhy would you prefer a runtime error over just not making the mistake in the first place?
- rowanG077 6y agoBecause I don't like having bombs in my software waiting to explode when you touch it. That's essentially what mutable by default is.
- colejohnson66 6y agoWell then we’re on the same page: default immutability is better. You’re wording three comments up seemed to say you prefer default mutability