From 42e3f97c300c24b6ff9ff96ad0c24d386d3a253b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Dec 2020 17:15:01 +0100 Subject: Support labels in reference search --- crates/ide/src/references.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'crates/ide/src/references.rs') diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 33b7358f7..21b2d7ca1 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -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 + "#]], + ); + } } -- cgit v1.2.3