aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/code_model.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 62eccf475..a2255508e 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -5,9 +5,7 @@ use arrayvec::ArrayVec;
5use base_db::{CrateDisplayName, CrateId, Edition, FileId}; 5use base_db::{CrateDisplayName, CrateId, Edition, FileId};
6use either::Either; 6use either::Either;
7use hir_def::{ 7use hir_def::{
8 adt::ReprKind, 8 adt::{ReprKind, StructKind, VariantData},
9 adt::StructKind,
10 adt::VariantData,
11 builtin_type::BuiltinType, 9 builtin_type::BuiltinType,
12 expr::{BindingAnnotation, LabelId, Pat, PatId}, 10 expr::{BindingAnnotation, LabelId, Pat, PatId},
13 import_map, 11 import_map,
@@ -31,7 +29,7 @@ use hir_expand::{
31}; 29};
32use hir_ty::{ 30use hir_ty::{
33 autoderef, 31 autoderef,
34 display::{HirDisplayError, HirFormatter}, 32 display::{write_bounds_like_dyn_trait, HirDisplayError, HirFormatter},
35 method_resolution, 33 method_resolution,
36 traits::{FnTrait, Solution, SolutionVariables}, 34 traits::{FnTrait, Solution, SolutionVariables},
37 ApplicationTy, BoundVar, CallableDefId, Canonical, DebruijnIndex, FnSig, GenericPredicate, 35 ApplicationTy, BoundVar, CallableDefId, Canonical, DebruijnIndex, FnSig, GenericPredicate,
@@ -1293,6 +1291,20 @@ impl TypeParam {
1293 } 1291 }
1294} 1292}
1295 1293
1294impl HirDisplay for TypeParam {
1295 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
1296 write!(f, "{}", self.name(f.db))?;
1297 let bounds = f.db.generic_predicates_for_param(self.id);
1298 let substs = Substs::type_params(f.db, self.id.parent);
1299 let predicates = bounds.iter().cloned().map(|b| b.subst(&substs)).collect::<Vec<_>>();
1300 if !(predicates.is_empty() || f.omit_verbose_types()) {
1301 write!(f, ": ")?;
1302 write_bounds_like_dyn_trait(&predicates, f)?;
1303 }
1304 Ok(())
1305 }
1306}
1307
1296#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 1308#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1297pub struct LifetimeParam { 1309pub struct LifetimeParam {
1298 pub(crate) id: LifetimeParamId, 1310 pub(crate) id: LifetimeParamId,