|
|
|
|
|
by alpaca128
1177 days ago
|
|
> If you “overwrite” a function parameter because you’re converting it, it’s a major use case of the feature. Or it's unintended and thus a bug. I personally almost never intentionally shadow variables so I turned it into warnings. > e.g. if you match on `Result<A, B>` but `B` is an uninhabited type (e.g. Infallible), should the code fail to compile? This specific example you chose is probably the least relevant here, as the Result type doesn't require you to write "Result::Err(_)" instead of just "Err(_)", both will correctly match. Which can of course also be done for custom enums by "importing" their variants ("use EnumName::*;"). But in my experience it's easy to accidentally omit the type in the match pattern and then suddenly it matches everything. I personally can't imagine a situation where this is intentional and have spent way too much time debugging this specific issue, hence I choose to turn it into an error. |
|