From a61615c95537ec85b6b52505f42cbd9481adf89d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 14 Sep 2019 10:04:56 +0200 Subject: Upgrade Chalk ... and remove Ty::UnselectedProjection. It'll be handled differently. --- crates/ra_hir/src/ty.rs | 45 ------------------------------------ crates/ra_hir/src/ty/infer.rs | 4 ---- crates/ra_hir/src/ty/traits/chalk.rs | 9 -------- 3 files changed, 58 deletions(-) (limited to 'crates') 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 { } } -#[derive(Clone, PartialEq, Eq, Debug, Hash)] -pub struct UnselectedProjectionTy { - pub type_name: Name, - pub parameters: Substs, -} - -impl TypeWalk for UnselectedProjectionTy { - fn walk(&self, f: &mut impl FnMut(&Ty)) { - self.parameters.walk(f); - } - - fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { - self.parameters.walk_mut(f); - } -} - /// A type. /// /// See also the `TyKind` enum in rustc (librustc/ty/sty.rs), which represents @@ -176,13 +160,6 @@ pub enum Ty { /// trait and all its parameters are fully known. Projection(ProjectionTy), - /// This is a variant of a projection in which the trait is - /// **not** known. It corresponds to a case where people write - /// `T::Item` without specifying the trait. We would then try to - /// figure out the trait by looking at all the traits that are in - /// scope. - UnselectedProjection(UnselectedProjectionTy), - /// A type parameter; for example, `T` in `fn f(x: T) {} Param { /// The index of the parameter (starting with parameters from the @@ -618,11 +595,6 @@ impl TypeWalk for Ty { t.walk(f); } } - Ty::UnselectedProjection(p_ty) => { - for t in p_ty.parameters.iter() { - t.walk(f); - } - } Ty::Dyn(predicates) | Ty::Opaque(predicates) => { for p in predicates.iter() { p.walk(f); @@ -641,9 +613,6 @@ impl TypeWalk for Ty { Ty::Projection(p_ty) => { p_ty.parameters.walk_mut(f); } - Ty::UnselectedProjection(p_ty) => { - p_ty.parameters.walk_mut(f); - } Ty::Dyn(predicates) | Ty::Opaque(predicates) => { let mut v: Vec<_> = predicates.iter().cloned().collect(); for p in &mut v { @@ -774,25 +743,11 @@ impl HirDisplay for ProjectionTy { } } -impl HirDisplay for UnselectedProjectionTy { - fn hir_fmt(&self, f: &mut HirFormatter) -> fmt::Result { - write!(f, "{}", self.parameters[0].display(f.db))?; - if self.parameters.len() > 1 { - write!(f, "<")?; - f.write_joined(&self.parameters[1..], ", ")?; - write!(f, ">")?; - } - write!(f, "::{}", self.type_name)?; - Ok(()) - } -} - impl HirDisplay for Ty { fn hir_fmt(&self, f: &mut HirFormatter) -> fmt::Result { match self { Ty::Apply(a_ty) => a_ty.hir_fmt(f)?, Ty::Projection(p_ty) => p_ty.hir_fmt(f)?, - Ty::UnselectedProjection(p_ty) => p_ty.hir_fmt(f)?, Ty::Param { name, .. } => write!(f, "{}", name)?, Ty::Bound(idx) => write!(f, "?{}", idx)?, 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> { let ty = self.resolve_ty_as_possible(&mut vec![], ty); ty.fold(&mut |ty| match ty { Ty::Projection(proj_ty) => self.normalize_projection_ty(proj_ty), - Ty::UnselectedProjection(proj_ty) => { - // FIXME use Chalk's unselected projection support - Ty::UnselectedProjection(proj_ty) - } _ => ty, }) } 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 { let parameters = proj_ty.parameters.to_chalk(db); chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast() } - Ty::UnselectedProjection(proj_ty) => { - let type_name = lalrpop_intern::intern(&proj_ty.type_name.to_string()); - let parameters = proj_ty.parameters.to_chalk(db); - chalk_ir::Ty::UnselectedProjection(chalk_ir::UnselectedProjectionTy { - type_name, - parameters, - }) - } Ty::Param { idx, .. } => { PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty() } @@ -113,7 +105,6 @@ impl ToChalk for Ty { } } chalk_ir::Ty::Projection(_) => unimplemented!(), - chalk_ir::Ty::UnselectedProjection(_) => unimplemented!(), chalk_ir::Ty::ForAll(_) => unimplemented!(), chalk_ir::Ty::BoundVar(idx) => Ty::Bound(idx as u32), chalk_ir::Ty::InferenceVar(_iv) => panic!("unexpected chalk infer ty"), -- cgit v1.2.3