From 050601ef7bda598e3ba289987afad7ac7ee46f7d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 May 2020 10:49:43 +0200 Subject: Chalk upgrade --- crates/ra_hir_ty/src/traits/chalk.rs | 57 ++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir_ty/src/traits') diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 1ccb7c3b4..5870618a0 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -182,7 +182,10 @@ impl chalk_ir::interner::Interner for Interner { Arc::new(goal) } - fn intern_goals(&self, data: impl IntoIterator>) -> Self::InternedGoals { + fn intern_goals( + &self, + data: impl IntoIterator, E>>, + ) -> Result { data.into_iter().collect() } @@ -222,10 +225,10 @@ impl chalk_ir::interner::Interner for Interner { clause } - fn intern_program_clauses( + fn intern_program_clauses( &self, - data: impl IntoIterator>, - ) -> Arc<[chalk_ir::ProgramClause]> { + data: impl IntoIterator, E>>, + ) -> Result]>, E> { data.into_iter().collect() } @@ -236,10 +239,10 @@ impl chalk_ir::interner::Interner for Interner { &clauses } - fn intern_quantified_where_clauses( + fn intern_quantified_where_clauses( &self, - data: impl IntoIterator>, - ) -> Self::InternedQuantifiedWhereClauses { + data: impl IntoIterator, E>>, + ) -> Result { data.into_iter().collect() } @@ -250,10 +253,10 @@ impl chalk_ir::interner::Interner for Interner { clauses } - fn intern_parameter_kinds( + fn intern_parameter_kinds( &self, - data: impl IntoIterator>, - ) -> Self::InternedParameterKinds { + data: impl IntoIterator, E>>, + ) -> Result { data.into_iter().collect() } @@ -264,10 +267,10 @@ impl chalk_ir::interner::Interner for Interner { ¶meter_kinds } - fn intern_canonical_var_kinds( + fn intern_canonical_var_kinds( &self, - data: impl IntoIterator>, - ) -> Self::InternedCanonicalVarKinds { + data: impl IntoIterator, E>>, + ) -> Result { data.into_iter().collect() } @@ -460,6 +463,14 @@ impl ToChalk for TypeCtor { TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), TypeName::OpaqueType(_) => unreachable!(), + + TypeName::Scalar(_) => unreachable!(), + TypeName::Tuple(_) => unreachable!(), + TypeName::Raw(_) => unreachable!(), + TypeName::Slice => unreachable!(), + TypeName::Ref(_) => unreachable!(), + TypeName::Str => unreachable!(), + TypeName::Error => { // this should not be reached, since we don't represent TypeName::Error with TypeCtor unreachable!() @@ -862,12 +873,6 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { // We don't do coherence checking (yet) unimplemented!() } - fn as_struct_id(&self, id: &TypeName) -> Option { - match id { - TypeName::Struct(struct_id) => Some(*struct_id), - _ => None, - } - } fn interner(&self) -> &Interner { &Interner } @@ -892,6 +897,20 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { ) -> Arc> { unimplemented!() } + + fn force_impl_for( + &self, + _well_known: chalk_rust_ir::WellKnownTrait, + _ty: &chalk_ir::TyData, + ) -> Option { + // this method is mostly for rustc + None + } + + fn is_object_safe(&self, _trait_id: chalk_ir::TraitId) -> bool { + // FIXME: implement actual object safety + true + } } pub(crate) fn program_clauses_for_chalk_env_query( -- cgit v1.2.3