Skip to content

Commit 472641f

Browse files
bors[bot]Veykril
andauthored
Merge #7941
7941: Fix unused definitions not being document highlit r=Veykril a=Veykril Fixes #7939 bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents ab99eff + a1f0801 commit 472641f

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,20 +1134,13 @@ pub(crate) fn handle_document_highlight(
11341134
None
11351135
};
11361136

1137-
let res = refs
1138-
.references
1139-
.get(&position.file_id)
1140-
.map(|file_refs| {
1141-
file_refs
1142-
.into_iter()
1143-
.map(|&(range, access)| DocumentHighlight {
1144-
range: to_proto::range(&line_index, range),
1145-
kind: access.map(to_proto::document_highlight_kind),
1146-
})
1147-
.chain(decl)
1148-
.collect()
1149-
})
1150-
.unwrap_or_default();
1137+
let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
1138+
let mut res = Vec::with_capacity(file_refs.len() + 1);
1139+
res.extend(decl);
1140+
res.extend(file_refs.iter().map(|&(range, access)| DocumentHighlight {
1141+
range: to_proto::range(&line_index, range),
1142+
kind: access.map(to_proto::document_highlight_kind),
1143+
}));
11511144
Ok(Some(res))
11521145
}
11531146

0 commit comments

Comments
 (0)