From 632a22ae621079beaee6bbb155997e763c6b068d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 29 Oct 2019 13:01:33 +0100 Subject: Upgrade Chalk, make use of TypeName::Error variant --- crates/ra_hir/src/ty/traits/chalk.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index ad7c11a5a..e18c28cf6 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -66,13 +66,11 @@ impl ToChalk for Ty { } Ty::Bound(idx) => chalk_ir::Ty::BoundVar(idx as usize), Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), - // FIXME this is clearly incorrect, but probably not too incorrect - // and I'm not sure what to actually do with Ty::Unknown - // maybe an alternative would be `for T`? (meaningless in rust, but expressible in chalk's Ty) // FIXME use Chalk's Dyn/Opaque once the bugs with that are fixed Ty::Unknown | Ty::Dyn(_) | Ty::Opaque(_) => { - PlaceholderIndex { ui: UniverseIndex::ROOT, idx: usize::max_value() } - .to_ty::() + let parameters = Vec::new(); + let name = TypeName::Error; + chalk_ir::ApplicationTy { name, parameters }.cast() } } } @@ -92,6 +90,7 @@ impl ToChalk for Ty { let parameters = from_chalk(db, apply_ty.parameters); Ty::Apply(ApplicationTy { ctor, parameters }) } + TypeName::Error => Ty::Unknown, // FIXME handle TypeKindId::Trait/Type here TypeName::TypeKindId(_) => unimplemented!(), TypeName::Placeholder(idx) => { @@ -323,9 +322,9 @@ where } impl ToChalk for Arc { - type Chalk = Arc>; + type Chalk = chalk_ir::Environment; - fn to_chalk(self, db: &impl HirDatabase) -> Arc> { + fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Environment { let mut clauses = Vec::new(); for pred in &self.predicates { if pred.is_error() { @@ -340,7 +339,7 @@ impl ToChalk for Arc { fn from_chalk( _db: &impl HirDatabase, - _env: Arc>, + _env: chalk_ir::Environment, ) -> Arc { unimplemented!() } -- cgit v1.2.3