aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-09-14 09:04:56 +0100
committerFlorian Diebold <[email protected]>2019-09-14 09:04:56 +0100
commita61615c95537ec85b6b52505f42cbd9481adf89d (patch)
treeb9e0af636566398fd983bca29f3af20405c9da51
parentb8c16ec002d48f4fb9d883d091114ccd1286ba47 (diff)
Upgrade Chalk
... and remove Ty::UnselectedProjection. It'll be handled differently.
-rw-r--r--Cargo.lock10
-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
4 files changed, 5 insertions, 63 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4e08a0bd1..ae204c8ff 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
122[[package]] 122[[package]]
123name = "chalk-engine" 123name = "chalk-engine"
124version = "0.9.0" 124version = "0.9.0"
125source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4" 125source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
126dependencies = [ 126dependencies = [
127 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", 127 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)",
128 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 128 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -132,7 +132,7 @@ dependencies = [
132[[package]] 132[[package]]
133name = "chalk-ir" 133name = "chalk-ir"
134version = "0.1.0" 134version = "0.1.0"
135source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4" 135source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
136dependencies = [ 136dependencies = [
137 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", 137 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
138 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", 138 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)",
@@ -142,7 +142,7 @@ dependencies = [
142[[package]] 142[[package]]
143name = "chalk-macros" 143name = "chalk-macros"
144version = "0.1.1" 144version = "0.1.1"
145source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4" 145source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
146dependencies = [ 146dependencies = [
147 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 147 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
148] 148]
@@ -150,7 +150,7 @@ dependencies = [
150[[package]] 150[[package]]
151name = "chalk-rust-ir" 151name = "chalk-rust-ir"
152version = "0.1.0" 152version = "0.1.0"
153source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4" 153source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
154dependencies = [ 154dependencies = [
155 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", 155 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
156 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", 156 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
@@ -160,7 +160,7 @@ dependencies = [
160[[package]] 160[[package]]
161name = "chalk-solve" 161name = "chalk-solve"
162version = "0.1.0" 162version = "0.1.0"
163source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4" 163source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
164dependencies = [ 164dependencies = [
165 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", 165 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
166 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", 166 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
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"),