aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty.rs45
-rw-r--r--crates/ra_hir/src/ty/infer.rs4
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs9
3 files changed, 0 insertions, 58 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 375850b92..a223e120a 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -142,22 +142,6 @@ impl TypeWalk for ProjectionTy {
142 } 142 }
143} 143}
144 144
145#[derive(Clone, PartialEq, Eq, Debug, Hash)]
146pub struct UnselectedProjectionTy {
147 pub type_name: Name,
148 pub parameters: Substs,
149}
150
151impl TypeWalk for UnselectedProjectionTy {
152 fn walk(&self, f: &mut impl FnMut(&Ty)) {
153 self.parameters.walk(f);
154 }
155
156 fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) {
157 self.parameters.walk_mut(f);
158 }
159}
160
161/// A type. 145/// A type.
162/// 146///
163/// See also the `TyKind` enum in rustc (librustc/ty/sty.rs), which represents 147/// See also the `TyKind` enum in rustc (librustc/ty/sty.rs), which represents
@@ -176,13 +160,6 @@ pub enum Ty {
176 /// trait and all its parameters are fully known. 160 /// trait and all its parameters are fully known.
177 Projection(ProjectionTy), 161 Projection(ProjectionTy),
178 162
179 /// This is a variant of a projection in which the trait is
180 /// **not** known. It corresponds to a case where people write
181 /// `T::Item` without specifying the trait. We would then try to
182 /// figure out the trait by looking at all the traits that are in
183 /// scope.
184 UnselectedProjection(UnselectedProjectionTy),
185
186 /// A type parameter; for example, `T` in `fn f<T>(x: T) {} 163 /// A type parameter; for example, `T` in `fn f<T>(x: T) {}
187 Param { 164 Param {
188 /// The index of the parameter (starting with parameters from the 165 /// The index of the parameter (starting with parameters from the
@@ -618,11 +595,6 @@ impl TypeWalk for Ty {
618 t.walk(f); 595 t.walk(f);
619 } 596 }
620 } 597 }
621 Ty::UnselectedProjection(p_ty) => {
622 for t in p_ty.parameters.iter() {
623 t.walk(f);
624 }
625 }
626 Ty::Dyn(predicates) | Ty::Opaque(predicates) => { 598 Ty::Dyn(predicates) | Ty::Opaque(predicates) => {
627 for p in predicates.iter() { 599 for p in predicates.iter() {
628 p.walk(f); 600 p.walk(f);
@@ -641,9 +613,6 @@ impl TypeWalk for Ty {
641 Ty::Projection(p_ty) => { 613 Ty::Projection(p_ty) => {
642 p_ty.parameters.walk_mut(f); 614 p_ty.parameters.walk_mut(f);
643 } 615 }
644 Ty::UnselectedProjection(p_ty) => {
645 p_ty.parameters.walk_mut(f);
646 }
647 Ty::Dyn(predicates) | Ty::Opaque(predicates) => { 616 Ty::Dyn(predicates) | Ty::Opaque(predicates) => {
648 let mut v: Vec<_> = predicates.iter().cloned().collect(); 617 let mut v: Vec<_> = predicates.iter().cloned().collect();
649 for p in &mut v { 618 for p in &mut v {
@@ -774,25 +743,11 @@ impl HirDisplay for ProjectionTy {
774 } 743 }
775} 744}
776 745
777impl HirDisplay for UnselectedProjectionTy {
778 fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result {
779 write!(f, "{}", self.parameters[0].display(f.db))?;
780 if self.parameters.len() > 1 {
781 write!(f, "<")?;
782 f.write_joined(&self.parameters[1..], ", ")?;
783 write!(f, ">")?;
784 }
785 write!(f, "::{}", self.type_name)?;
786 Ok(())
787 }
788}
789
790impl HirDisplay for Ty { 746impl HirDisplay for Ty {
791 fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result { 747 fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result {
792 match self { 748 match self {
793 Ty::Apply(a_ty) => a_ty.hir_fmt(f)?, 749 Ty::Apply(a_ty) => a_ty.hir_fmt(f)?,
794 Ty::Projection(p_ty) => p_ty.hir_fmt(f)?, 750 Ty::Projection(p_ty) => p_ty.hir_fmt(f)?,
795 Ty::UnselectedProjection(p_ty) => p_ty.hir_fmt(f)?,
796 Ty::Param { name, .. } => write!(f, "{}", name)?, 751 Ty::Param { name, .. } => write!(f, "{}", name)?,
797 Ty::Bound(idx) => write!(f, "?{}", idx)?, 752 Ty::Bound(idx) => write!(f, "?{}", idx)?,
798 Ty::Dyn(predicates) | Ty::Opaque(predicates) => { 753 Ty::Dyn(predicates) | Ty::Opaque(predicates) => {
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 3ee083a04..bf57bb3b7 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -429,10 +429,6 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
429 let ty = self.resolve_ty_as_possible(&mut vec![], ty); 429 let ty = self.resolve_ty_as_possible(&mut vec![], ty);
430 ty.fold(&mut |ty| match ty { 430 ty.fold(&mut |ty| match ty {
431 Ty::Projection(proj_ty) => self.normalize_projection_ty(proj_ty), 431 Ty::Projection(proj_ty) => self.normalize_projection_ty(proj_ty),
432 Ty::UnselectedProjection(proj_ty) => {
433 // FIXME use Chalk's unselected projection support
434 Ty::UnselectedProjection(proj_ty)
435 }
436 _ => ty, 432 _ => ty,
437 }) 433 })
438 } 434 }
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 0367c6560..c748e9d84 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -65,14 +65,6 @@ impl ToChalk for Ty {
65 let parameters = proj_ty.parameters.to_chalk(db); 65 let parameters = proj_ty.parameters.to_chalk(db);
66 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast() 66 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast()
67 } 67 }
68 Ty::UnselectedProjection(proj_ty) => {
69 let type_name = lalrpop_intern::intern(&proj_ty.type_name.to_string());
70 let parameters = proj_ty.parameters.to_chalk(db);
71 chalk_ir::Ty::UnselectedProjection(chalk_ir::UnselectedProjectionTy {
72 type_name,
73 parameters,
74 })
75 }
76 Ty::Param { idx, .. } => { 68 Ty::Param { idx, .. } => {
77 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty() 69 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty()
78 } 70 }
@@ -113,7 +105,6 @@ impl ToChalk for Ty {
113 } 105 }
114 } 106 }
115 chalk_ir::Ty::Projection(_) => unimplemented!(), 107 chalk_ir::Ty::Projection(_) => unimplemented!(),
116 chalk_ir::Ty::UnselectedProjection(_) => unimplemented!(),
117 chalk_ir::Ty::ForAll(_) => unimplemented!(), 108 chalk_ir::Ty::ForAll(_) => unimplemented!(),
118 chalk_ir::Ty::BoundVar(idx) => Ty::Bound(idx as u32), 109 chalk_ir::Ty::BoundVar(idx) => Ty::Bound(idx as u32),
119 chalk_ir::Ty::InferenceVar(_iv) => panic!("unexpected chalk infer ty"), 110 chalk_ir::Ty::InferenceVar(_iv) => panic!("unexpected chalk infer ty"),