Skip to content

Commit 2d7f589

Browse files
committed
Remove faulty logic for ascending test attributes for runnables
1 parent a510021 commit 2d7f589

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

crates/hir_expand/src/lib.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -699,23 +699,6 @@ impl<N: AstNode> InFile<N> {
699699
pub fn syntax(&self) -> InFile<&SyntaxNode> {
700700
self.with_value(self.value.syntax())
701701
}
702-
703-
pub fn nodes_with_attributes<'db>(
704-
self,
705-
db: &'db dyn db::AstDatabase,
706-
) -> impl Iterator<Item = InFile<N>> + 'db
707-
where
708-
N: 'db,
709-
{
710-
iter::successors(Some(self), move |node| {
711-
let InFile { file_id, value } = node.file_id.call_node(db)?;
712-
N::cast(value).map(|n| InFile::new(file_id, n))
713-
})
714-
}
715-
716-
pub fn node_with_attributes(self, db: &dyn db::AstDatabase) -> InFile<N> {
717-
self.nodes_with_attributes(db).last().unwrap()
718-
}
719702
}
720703

721704
/// In Rust, macros expand token trees to token trees. When we want to turn a

crates/ide/src/runnables.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ fn find_related_tests(
236236
.filter_map(|token| token.ancestors().find_map(ast::Fn::cast))
237237
.map(|f| hir::InFile::new(sema.hir_file_for(f.syntax()), f));
238238

239-
for fn_def in functions {
240-
// #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
241-
let InFile { value: fn_def, .. } = &fn_def.node_with_attributes(sema.db);
239+
for InFile { value: ref fn_def, .. } in functions {
242240
if let Some(runnable) = as_test_runnable(sema, fn_def) {
243241
// direct test
244242
tests.insert(runnable);
@@ -294,8 +292,7 @@ fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Optio
294292
}
295293

296294
pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) -> Option<Runnable> {
297-
// #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
298-
let func = def.source(sema.db)?.node_with_attributes(sema.db);
295+
let func = def.source(sema.db)?;
299296
let name_string = def.name(sema.db).to_string();
300297

301298
let root = def.module(sema.db).krate().root_module(sema.db);
@@ -504,8 +501,6 @@ fn has_test_function_or_multiple_test_submodules(
504501
match item {
505502
hir::ModuleDef::Function(f) => {
506503
if let Some(it) = f.source(sema.db) {
507-
// #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
508-
let it = it.node_with_attributes(sema.db);
509504
if test_related_attribute(&it.value).is_some() {
510505
return true;
511506
}

0 commit comments

Comments
 (0)