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
I expected to see this happen: no warning regarding to label
Instead, this happened: got warning about label shadowing
warning: label name `'l` shadows a label name that is already in scope
--> src/main.rs:7:9
|
3 | 'l : loop {
| -- first declared here
...
7 | 'l : loop {
| ^^ label `'l` already in scope
version
Build using the Nightly version: 1.56.0-nightly
(2021-08-21 d3e2578c31688619ddc0)
Thanks for the report! This is currently intentional, and a known issue. The warning could be clearer, though. Closing as a duplicate of #24278 and #31745.
This warning is very unintuitive. I got that this is intended in the links provided, but could not find out why, i.e. what harm does it do if I write it this way. @ehuss can you provide a link to the reason why this is intended that this can be discussed?
I don't think there is any information beyond what is linked in those issues. This was something added before 1.0, and it hasn't been revisited since. The why is primarily explained in https://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833, where there was an intent to add explicit syntax for labeling a region for a borrow, but that never got beyond the idea stage (AFAIK). #24278 also explains how there are macro hygiene problems.
I tried this code:
I expected to see this happen: no warning regarding to label
Instead, this happened: got warning about label shadowing
version
playground
The text was updated successfully, but these errors were encountered: