Support labels in reference search

This commit is contained in:
Lukas Wirth 2020-12-23 17:15:01 +01:00
parent e1acb0ca5c
commit 42e3f97c30
21 changed files with 142 additions and 14 deletions

View file

@ -130,7 +130,7 @@ pub(crate) fn find_all_refs(
kind = ReferenceKind::FieldShorthandForLocal;
}
}
} else if let Definition::LifetimeParam(_) = def {
} else if matches!(def, Definition::LifetimeParam(_) | Definition::Label(_)) {
kind = ReferenceKind::Lifetime;
};
@ -1122,4 +1122,26 @@ fn main() {
"#]],
);
}
#[test]
fn test_find_labels() {
check(
r#"
fn foo<'a>() -> &'a () {
'a: loop {
'b: loop {
continue 'a<|>;
}
break 'a;
}
}
"#,
expect![[r#"
'a Label FileId(0) 29..32 29..31 Lifetime
FileId(0) 80..82 Lifetime
FileId(0) 108..110 Lifetime
"#]],
);
}
}