mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Merge #1843
1843: Upgrade Chalk r=flodiebold a=flodiebold ... and remove Ty::UnselectedProjection. It'll be handled differently. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
commit
4ed44c80db
4 changed files with 5 additions and 63 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "chalk-engine"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
|
||||
dependencies = [
|
||||
"chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -132,7 +132,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "chalk-ir"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
|
||||
dependencies = [
|
||||
"chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)",
|
||||
|
@ -142,7 +142,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "chalk-macros"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -150,7 +150,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "chalk-rust-ir"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
|
||||
dependencies = [
|
||||
"chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
|
@ -160,7 +160,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "chalk-solve"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#6a532fc2eb82275a5bda2785c7f5382d555f53f4"
|
||||
source = "git+https://github.com/rust-lang/chalk.git#b4a6b655578ee35b1b3f6b8579636269cf3b0b1a"
|
||||
dependencies = [
|
||||
"chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
"chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
|
||||
|
|
|
@ -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…
Reference in a new issue