You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the rule right before the rule you quoted:
Path patterns take precedence over identifier patterns.
Your example attempts to match the constant a rather than binding it as variable. If you did something like
const a:() = ();fnmain(){let a = ();}
it would have worked with a warning as now the constant a infallibly matches against the value (). It still doesn't shadow the constant.
warning: constant in pattern `a` should have an upper case name
--> src/main.rs:3:9
|
3 | let a = ();
| ^ help: convert the identifier to upper case: `A`
According to Identifier patterns,
However, the code below (Playground) doesn't compile though it doesn't contain
ref
orref mut
.In what situation can a variable without
ref
orref mut
shadow a constant?The text was updated successfully, but these errors were encountered: