diff options
author | Lukas Wirth <[email protected]> | 2020-12-23 16:15:01 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-12-24 14:40:18 +0000 |
commit | 42e3f97c300c24b6ff9ff96ad0c24d386d3a253b (patch) | |
tree | 4142c4c99b034035bbc4e2b35ecd0f7e185b6855 /crates/ide/src/references.rs | |
parent | e1acb0ca5ca2162be068fd6a07f7cc4ae171ed81 (diff) |
Support labels in reference search
Diffstat (limited to 'crates/ide/src/references.rs')
-rw-r--r-- | crates/ide/src/references.rs | 24 |
1 files changed, 23 insertions, 1 deletions
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( | |||
130 | kind = ReferenceKind::FieldShorthandForLocal; | 130 | kind = ReferenceKind::FieldShorthandForLocal; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } else if let Definition::LifetimeParam(_) = def { | 133 | } else if matches!(def, Definition::LifetimeParam(_) | Definition::Label(_)) { |
134 | kind = ReferenceKind::Lifetime; | 134 | kind = ReferenceKind::Lifetime; |
135 | }; | 135 | }; |
136 | 136 | ||
@@ -1122,4 +1122,26 @@ fn main() { | |||
1122 | "#]], | 1122 | "#]], |
1123 | ); | 1123 | ); |
1124 | } | 1124 | } |
1125 | |||
1126 | #[test] | ||
1127 | fn test_find_labels() { | ||
1128 | check( | ||
1129 | r#" | ||
1130 | fn foo<'a>() -> &'a () { | ||
1131 | 'a: loop { | ||
1132 | 'b: loop { | ||
1133 | continue 'a<|>; | ||
1134 | } | ||
1135 | break 'a; | ||
1136 | } | ||
1137 | } | ||
1138 | "#, | ||
1139 | expect![[r#" | ||
1140 | 'a Label FileId(0) 29..32 29..31 Lifetime | ||
1141 | |||
1142 | FileId(0) 80..82 Lifetime | ||
1143 | FileId(0) 108..110 Lifetime | ||
1144 | "#]], | ||
1145 | ); | ||
1146 | } | ||
1125 | } | 1147 | } |