]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir/src/has_source.rs
Add ConstParams to the HIR
[rust.git] / crates / hir / src / has_source.rs
index 0dc07c33e22832f2663088c8f1d0d148d59177d4..dd7c0c57067c27e9ab3d5df0157563ed2e464496 100644 (file)
@@ -10,8 +10,8 @@
 use syntax::ast;
 
 use crate::{
-    db::HirDatabase, Const, Enum, Field, FieldSource, Function, Impl, LifetimeParam, MacroDef,
-    Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
+    db::HirDatabase, Const, ConstParam, Enum, Field, FieldSource, Function, Impl, LifetimeParam,
+    MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
 };
 
 pub trait HasSource {
@@ -140,3 +140,11 @@ fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
         child_source.map(|it| it[self.id.local_id].clone())
     }
 }
+
+impl HasSource for ConstParam {
+    type Ast = ast::ConstParam;
+    fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
+        let child_source = self.id.parent.child_source(db.upcast());
+        child_source.map(|it| it[self.id.local_id].clone())
+    }
+}