Description
If you have a program containing two variables named ρ
and p
(that is the Greek letter Rho and the English letter P respectively), you'll get a warning like this:
warning: identifier pair considered confusable between `p` and `ρ`
--> src/foo.rs:96:13
|
96 | let ρ = ...;
| ^
|
::: src/lib.rs:459:24
|
459 | .map(|(p, idx)| { ... })
| - this is where the previous identifier occurred
|
= note: `#[warn(confusable_idents)]` on by default
This lint is an extremely clever way to detect possible homoglyph issues. However, I think that this message could be worded better to help the programmer if the non-ascii indentifier was actually intentional.
To start, there should be more emphasis that this warning was triggered because the program contains both of the listed identifiers. As far as I know, this is the only lint that can trigger based on the names of local variables in completely non-overlapping scopes and even when they are in completely different modules. Perhaps it could read something like
warning: crate contains both
p
andρ
identifiers which might be confused
Additionally, the second code snippet annotation would be better with "other" rather than "previous" since the two usages might not be ordered with respect to each other.