]> git.lizzy.rs Git - rust.git/commitdiff
Remove faulty logic for ascending test attributes for runnables
authorLukas Wirth <lukastw97@gmail.com>
Thu, 11 Nov 2021 17:47:24 +0000 (18:47 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Thu, 11 Nov 2021 17:47:24 +0000 (18:47 +0100)
crates/hir_expand/src/lib.rs
crates/ide/src/runnables.rs

index a0a79b2b4c16c222c0728371ebe1a358ea791079..0c4fdfa0fe59c248fa893b9856010252069bcecc 100644 (file)
@@ -699,23 +699,6 @@ pub fn original_ast_node(self, db: &dyn db::AstDatabase) -> Option<InFile<N>> {
     pub fn syntax(&self) -> InFile<&SyntaxNode> {
         self.with_value(self.value.syntax())
     }
-
-    pub fn nodes_with_attributes<'db>(
-        self,
-        db: &'db dyn db::AstDatabase,
-    ) -> impl Iterator<Item = InFile<N>> + 'db
-    where
-        N: 'db,
-    {
-        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> {
-        self.nodes_with_attributes(db).last().unwrap()
-    }
 }
 
 /// In Rust, macros expand token trees to token trees. When we want to turn a
index 093449176336e97e99b03ef5d55692cd0603398f..40c6b2115988c7158559c24307e366acf36d2a5a 100644 (file)
@@ -236,9 +236,7 @@ fn find_related_tests(
                 .filter_map(|token| token.ancestors().find_map(ast::Fn::cast))
                 .map(|f| hir::InFile::new(sema.hir_file_for(f.syntax()), f));
 
-            for fn_def in functions {
-                // #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
-                let InFile { value: fn_def, .. } = &fn_def.node_with_attributes(sema.db);
+            for InFile { value: ref fn_def, .. } in functions {
                 if let Some(runnable) = as_test_runnable(sema, fn_def) {
                     // direct test
                     tests.insert(runnable);
@@ -294,8 +292,7 @@ fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Optio
 }
 
 pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) -> Option<Runnable> {
-    // #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
-    let func = def.source(sema.db)?.node_with_attributes(sema.db);
+    let func = def.source(sema.db)?;
     let name_string = def.name(sema.db).to_string();
 
     let root = def.module(sema.db).krate().root_module(sema.db);
@@ -504,8 +501,6 @@ fn has_test_function_or_multiple_test_submodules(
         match item {
             hir::ModuleDef::Function(f) => {
                 if let Some(it) = f.source(sema.db) {
-                    // #[test/bench] expands to just the item causing us to lose the attribute, so recover them by going out of the attribute
-                    let it = it.node_with_attributes(sema.db);
                     if test_related_attribute(&it.value).is_some() {
                         return true;
                     }