mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Use correct HirFileId in find_related_test
This commit is contained in:
parent
7342dcf0b0
commit
557df6ff3f
3 changed files with 14 additions and 16 deletions
|
@ -22,7 +22,7 @@ use either::Either;
|
|||
pub use mbe::{ExpandError, ExpandResult};
|
||||
pub use parser::FragmentKind;
|
||||
|
||||
use std::{hash::Hash, sync::Arc};
|
||||
use std::{hash::Hash, iter, sync::Arc};
|
||||
|
||||
use base_db::{impl_intern_key, salsa, CrateId, FileId, FileRange};
|
||||
use syntax::{
|
||||
|
@ -454,7 +454,7 @@ impl InFile<SyntaxNode> {
|
|||
self,
|
||||
db: &dyn db::AstDatabase,
|
||||
) -> impl Iterator<Item = InFile<SyntaxNode>> + '_ {
|
||||
std::iter::successors(Some(self), move |node| match node.value.parent() {
|
||||
iter::successors(Some(self), move |node| match node.value.parent() {
|
||||
Some(parent) => Some(node.with_value(parent)),
|
||||
None => {
|
||||
let parent_node = node.file_id.call_node(db)?;
|
||||
|
@ -570,19 +570,14 @@ impl<N: AstNode> InFile<N> {
|
|||
where
|
||||
N: 'db,
|
||||
{
|
||||
std::iter::successors(Some(self), move |node| {
|
||||
iter::successors(Some(self), move |node| {
|
||||
let InFile { file_id, value } = node.file_id.call_node(db)?;
|
||||
N::cast(value).map(|n| InFile::new(file_id, n))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn node_with_attributes(self, db: &dyn db::AstDatabase) -> InFile<N> {
|
||||
std::iter::successors(Some(self), move |node| {
|
||||
let InFile { file_id, value } = node.file_id.call_node(db)?;
|
||||
N::cast(value).map(|n| InFile::new(file_id, n))
|
||||
})
|
||||
.last()
|
||||
.unwrap()
|
||||
self.nodes_with_attributes(db).last().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue