]> git.lizzy.rs Git - rust.git/commitdiff
Merge #844
authorbors[bot] <bors[bot]@users.noreply.github.com>
Sun, 17 Feb 2019 15:38:33 +0000 (15:38 +0000)
committerbors[bot] <bors[bot]@users.noreply.github.com>
Sun, 17 Feb 2019 15:38:33 +0000 (15:38 +0000)
844: Refactor find_all_refs to return ReferenceSearchResult r=vipentti a=vipentti

This refactors `find_all_refs` to return a new `ReferenceSearchResult` based on feedback in #839.

There are few questions/notes regarding the refactor:

1. Introducing `NavigationTarget::from_bind_pat` this simply forwards the call to `NavigationTarget::from_named`, could we just expose `from_named` directly as `pub(crate)` ?
2. Added an utility method `NavigationTarget::range` since there were few places where you would use `self.focus_range.unwrap_or(self.full_range)`
3. Implementing `IntoIterator` for `ReferenceSearchResult`. This turns `ReferenceSearchResult` into an iterator over `FileRanges` and allows previous code to mostly stay as it was based on the order that `find_all_refs` previously had (declaration first and then the references). I'm not sure if there is a way of doing the conversion to `IntoIter` without the allocation of a new vector
4. Is it possible to have a binding without a name? I'm not sure if the `NavigationTarget::from_bind_pat` can cause some edge-cases that previously were ok

This fixes #835.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>

Trivial merge