Safe Rust guarantees are primarily around memory safety and race conditions, not logic errors in general. So sure, Rust will compile code with logic errors -- and the same is true of every other programming language. The language can't omnipotently know what the program is supposed to do.
Not necessarily, maybe they just wrote more code that necessary because they didn't realize a certain case was impossible, or got some privacy annotations wrong and didn't expose some function that was supposed to be public.
Because enum Location variant Range have two numbers I assume this numbers means min and max range.
So, line Location::Range(_, n) => n, will return max number of Range. But at time min is 0 it should return 0, but this line is unreachable.
I think you misunderstood me. I know that locations after Location::Range(_, n) => n, is unreachable because this line fits all possible Range variants, so it should be at the end of arms.
I am only asking why Rust treats unreachable code as warning and not as error.
As quinedot wrote it is logical error, but this type of logical error is caught and most of time means a bug.
I think this type of bug should be treated the same as not exhausting all arms.
If you use not all arms (this is error in Rust) or too many arms (because of unreachable warning) it should be error and not a warning.
Because it is not necessarily an error. If you declare a variable and never use it, that's also dead code. It's not an error. It is treated as such in Go, and that annoys the hell out if people trying to debug their code by commenting out parts of it.