aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/attrs.rs5
-rw-r--r--crates/hir/src/semantics.rs1
-rw-r--r--crates/hir/src/semantics/source_to_def.rs6
3 files changed, 10 insertions, 2 deletions
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs
index 9e6a3e155..505fc05e7 100644
--- a/crates/hir/src/attrs.rs
+++ b/crates/hir/src/attrs.rs
@@ -11,8 +11,8 @@ use hir_ty::db::HirDatabase;
11use syntax::ast; 11use syntax::ast;
12 12
13use crate::{ 13use crate::{
14 Adt, Const, ConstParam, Enum, Field, Function, GenericParam, LifetimeParam, MacroDef, Module, 14 Adt, Const, ConstParam, Enum, Field, Function, GenericParam, Impl, LifetimeParam, MacroDef,
15 ModuleDef, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant, 15 Module, ModuleDef, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
16}; 16};
17 17
18pub trait HasAttrs { 18pub trait HasAttrs {
@@ -64,6 +64,7 @@ impl_has_attrs![
64 (Adt, AdtId), 64 (Adt, AdtId),
65 (Module, ModuleId), 65 (Module, ModuleId),
66 (GenericParam, GenericParamId), 66 (GenericParam, GenericParamId),
67 (Impl, ImplId),
67]; 68];
68 69
69macro_rules! impl_has_attrs_enum { 70macro_rules! impl_has_attrs_enum {
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 03c9371b5..c7e0d0be3 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -752,6 +752,7 @@ macro_rules! to_def_impls {
752 752
753to_def_impls![ 753to_def_impls![
754 (crate::Module, ast::Module, module_to_def), 754 (crate::Module, ast::Module, module_to_def),
755 (crate::Module, ast::SourceFile, source_file_to_def),
755 (crate::Struct, ast::Struct, struct_to_def), 756 (crate::Struct, ast::Struct, struct_to_def),
756 (crate::Enum, ast::Enum, enum_to_def), 757 (crate::Enum, ast::Enum, enum_to_def),
757 (crate::Union, ast::Union, union_to_def), 758 (crate::Union, ast::Union, union_to_def),
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index e9d820140..c6ad5ecb5 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -71,6 +71,12 @@ impl SourceToDefCtx<'_, '_> {
71 Some(def_map.module_id(child_id)) 71 Some(def_map.module_id(child_id))
72 } 72 }
73 73
74 pub(super) fn source_file_to_def(&mut self, src: InFile<ast::SourceFile>) -> Option<ModuleId> {
75 let _p = profile::span("source_file_to_def");
76 let file_id = src.file_id.original_file(self.db.upcast());
77 self.file_to_def(file_id).get(0).copied()
78 }
79
74 pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { 80 pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> {
75 self.to_def(src, keys::TRAIT) 81 self.to_def(src, keys::TRAIT)
76 } 82 }