Don't warn labels beginning with `_`

This commit is contained in:
Yuki Okushi 2019-11-15 03:05:03 +09:00
parent 82cf3a4486
commit 43492283b4
2 changed files with 13 additions and 1 deletions

View File

@ -1767,7 +1767,9 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
fn with_resolved_label(&mut self, label: Option<Label>, id: NodeId, f: impl FnOnce(&mut Self)) {
if let Some(label) = label {
self.diagnostic_metadata.unused_labels.insert(id, label.ident.span);
if label.ident.as_str().as_bytes()[1] != b'_' {
self.diagnostic_metadata.unused_labels.insert(id, label.ident.span);
}
self.with_label_rib(NormalRibKind, |this| {
let ident = label.ident.modern_and_legacy();
this.label_ribs.last_mut().unwrap().bindings.insert(ident, id);

View File

@ -0,0 +1,10 @@
// check-pass
#![deny(unused_labels)]
fn main() {
// `unused_label` shouldn't warn labels beginning with `_`
'_unused: loop {
break;
}
}