aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src/display.rs')
-rw-r--r--crates/hir/src/display.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index 44cdcc296..81f0e04e5 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -12,8 +12,8 @@ use hir_ty::display::{
12use syntax::ast::{self, NameOwner}; 12use syntax::ast::{self, NameOwner};
13 13
14use crate::{ 14use crate::{
15 Const, ConstParam, Enum, Field, Function, HasVisibility, Module, Static, Struct, Substs, Trait, 15 Adt, Const, ConstParam, Enum, Field, Function, GenericParam, HasVisibility, LifetimeParam,
16 Type, TypeAlias, TypeParam, Union, Variant, 16 Module, Static, Struct, Substs, Trait, Type, TypeAlias, TypeParam, Union, Variant,
17}; 17};
18 18
19impl HirDisplay for Function { 19impl HirDisplay for Function {
@@ -120,6 +120,16 @@ impl HirDisplay for Function {
120 } 120 }
121} 121}
122 122
123impl HirDisplay for Adt {
124 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
125 match self {
126 Adt::Struct(it) => it.hir_fmt(f),
127 Adt::Union(it) => it.hir_fmt(f),
128 Adt::Enum(it) => it.hir_fmt(f),
129 }
130 }
131}
132
123impl HirDisplay for Struct { 133impl HirDisplay for Struct {
124 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { 134 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
125 write_visibility(self.module(f.db).id, self.visibility(f.db), f)?; 135 write_visibility(self.module(f.db).id, self.visibility(f.db), f)?;
@@ -211,6 +221,16 @@ impl HirDisplay for Type {
211 } 221 }
212} 222}
213 223
224impl HirDisplay for GenericParam {
225 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
226 match self {
227 GenericParam::TypeParam(it) => it.hir_fmt(f),
228 GenericParam::LifetimeParam(it) => it.hir_fmt(f),
229 GenericParam::ConstParam(it) => it.hir_fmt(f),
230 }
231 }
232}
233
214impl HirDisplay for TypeParam { 234impl HirDisplay for TypeParam {
215 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { 235 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
216 write!(f, "{}", self.name(f.db))?; 236 write!(f, "{}", self.name(f.db))?;
@@ -224,6 +244,12 @@ impl HirDisplay for TypeParam {
224 } 244 }
225} 245}
226 246
247impl HirDisplay for LifetimeParam {
248 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
249 write!(f, "{}", self.name(f.db))
250 }
251}
252
227impl HirDisplay for ConstParam { 253impl HirDisplay for ConstParam {
228 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { 254 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
229 write!(f, "const {}: ", self.name(f.db))?; 255 write!(f, "const {}: ", self.name(f.db))?;