mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Upgrade Chalk
... and remove Ty::UnselectedProjection. It'll be handled differently.
This commit is contained in:
parent
b8c16ec002
commit
a61615c955
4 changed files with 5 additions and 63 deletions
|
@ -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<T>(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<impl HirDatabase>) -> 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<impl HirDatabase>) -> 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) => {
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue