Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/traits.rs')
-rw-r--r--crates/ide-db/src/traits.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ide-db/src/traits.rs b/crates/ide-db/src/traits.rs
index 0f67496d09..61e28386d0 100644
--- a/crates/ide-db/src/traits.rs
+++ b/crates/ide-db/src/traits.rs
@@ -1,9 +1,9 @@
//! Functionality for obtaining data related to traits from the DB.
-use crate::{defs::Definition, RootDatabase};
-use hir::{db::HirDatabase, AsAssocItem, Semantics};
+use crate::{RootDatabase, defs::Definition};
+use hir::{AsAssocItem, Semantics, db::HirDatabase};
use rustc_hash::FxHashSet;
-use syntax::{ast, AstNode};
+use syntax::{AstNode, ast};
/// Given the `impl` block, attempts to find the trait this `impl` corresponds to.
pub fn resolve_target_trait(
@@ -113,7 +113,7 @@ fn assoc_item_of_trait(
#[cfg(test)]
mod tests {
- use expect_test::{expect, Expect};
+ use expect_test::{Expect, expect};
use hir::FilePosition;
use hir::Semantics;
use span::Edition;
@@ -126,8 +126,8 @@ mod tests {
pub(crate) fn position(
#[rust_analyzer::rust_fixture] ra_fixture: &str,
) -> (RootDatabase, FilePosition) {
- let change_fixture = ChangeFixture::parse(ra_fixture);
let mut database = RootDatabase::default();
+ let change_fixture = ChangeFixture::parse(&database, ra_fixture);
database.apply_change(change_fixture.change);
let (file_id, range_or_offset) =
change_fixture.file_position.expect("expected a marker ($0)");
@@ -138,6 +138,7 @@ mod tests {
fn check_trait(#[rust_analyzer::rust_fixture] ra_fixture: &str, expect: Expect) {
let (db, position) = position(ra_fixture);
let sema = Semantics::new(&db);
+
let file = sema.parse(position.file_id);
let impl_block: ast::Impl =
sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap();
@@ -152,6 +153,7 @@ mod tests {
fn check_missing_assoc(#[rust_analyzer::rust_fixture] ra_fixture: &str, expect: Expect) {
let (db, position) = position(ra_fixture);
let sema = Semantics::new(&db);
+
let file = sema.parse(position.file_id);
let impl_block: ast::Impl =
sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap();