Skip to content

Commit 9322790

Browse files
Merge #4479
4479: Chalk upgrade r=matklad a=flodiebold This includes the fix for `dyn Trait` super traits, but I noticed that still a lot of `db.super_trait_method()` calls don't work because the super trait isn't in scope (because it doesn't actually need to be). Somehow, I thought we handled that already, but I'll fix it in a separate PR. Also I'll see what happens if we use more of Chalk's new built-in types and traits in a separate PR. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 parents 5dcaf10 + 050601e commit 9322790

File tree

3 files changed

+53
-34
lines changed

3 files changed

+53
-34
lines changed

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_hir_ty/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ test_utils = { path = "../test_utils" }
2727

2828
scoped-tls = "1"
2929

30-
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" }
31-
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" }
32-
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" }
30+
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
31+
chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
32+
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" }
3333

3434
[dev-dependencies]
3535
insta = "0.16.0"

crates/ra_hir_ty/src/traits/chalk.rs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ impl chalk_ir::interner::Interner for Interner {
182182
Arc::new(goal)
183183
}
184184

185-
fn intern_goals(&self, data: impl IntoIterator<Item = Goal<Self>>) -> Self::InternedGoals {
185+
fn intern_goals<E>(
186+
&self,
187+
data: impl IntoIterator<Item = Result<Goal<Self>, E>>,
188+
) -> Result<Self::InternedGoals, E> {
186189
data.into_iter().collect()
187190
}
188191

@@ -222,10 +225,10 @@ impl chalk_ir::interner::Interner for Interner {
222225
clause
223226
}
224227

225-
fn intern_program_clauses(
228+
fn intern_program_clauses<E>(
226229
&self,
227-
data: impl IntoIterator<Item = chalk_ir::ProgramClause<Self>>,
228-
) -> Arc<[chalk_ir::ProgramClause<Self>]> {
230+
data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
231+
) -> Result<Arc<[chalk_ir::ProgramClause<Self>]>, E> {
229232
data.into_iter().collect()
230233
}
231234

@@ -236,10 +239,10 @@ impl chalk_ir::interner::Interner for Interner {
236239
&clauses
237240
}
238241

239-
fn intern_quantified_where_clauses(
242+
fn intern_quantified_where_clauses<E>(
240243
&self,
241-
data: impl IntoIterator<Item = chalk_ir::QuantifiedWhereClause<Self>>,
242-
) -> Self::InternedQuantifiedWhereClauses {
244+
data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
245+
) -> Result<Self::InternedQuantifiedWhereClauses, E> {
243246
data.into_iter().collect()
244247
}
245248

@@ -250,10 +253,10 @@ impl chalk_ir::interner::Interner for Interner {
250253
clauses
251254
}
252255

253-
fn intern_parameter_kinds(
256+
fn intern_parameter_kinds<E>(
254257
&self,
255-
data: impl IntoIterator<Item = chalk_ir::ParameterKind<()>>,
256-
) -> Self::InternedParameterKinds {
258+
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>,
259+
) -> Result<Self::InternedParameterKinds, E> {
257260
data.into_iter().collect()
258261
}
259262

@@ -264,10 +267,10 @@ impl chalk_ir::interner::Interner for Interner {
264267
&parameter_kinds
265268
}
266269

267-
fn intern_canonical_var_kinds(
270+
fn intern_canonical_var_kinds<E>(
268271
&self,
269-
data: impl IntoIterator<Item = chalk_ir::ParameterKind<UniverseIndex>>,
270-
) -> Self::InternedCanonicalVarKinds {
272+
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<UniverseIndex>, E>>,
273+
) -> Result<Self::InternedCanonicalVarKinds, E> {
271274
data.into_iter().collect()
272275
}
273276

@@ -460,6 +463,14 @@ impl ToChalk for TypeCtor {
460463
TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()),
461464
TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)),
462465
TypeName::OpaqueType(_) => unreachable!(),
466+
467+
TypeName::Scalar(_) => unreachable!(),
468+
TypeName::Tuple(_) => unreachable!(),
469+
TypeName::Raw(_) => unreachable!(),
470+
TypeName::Slice => unreachable!(),
471+
TypeName::Ref(_) => unreachable!(),
472+
TypeName::Str => unreachable!(),
473+
463474
TypeName::Error => {
464475
// this should not be reached, since we don't represent TypeName::Error with TypeCtor
465476
unreachable!()
@@ -862,12 +873,6 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
862873
// We don't do coherence checking (yet)
863874
unimplemented!()
864875
}
865-
fn as_struct_id(&self, id: &TypeName<Interner>) -> Option<StructId> {
866-
match id {
867-
TypeName::Struct(struct_id) => Some(*struct_id),
868-
_ => None,
869-
}
870-
}
871876
fn interner(&self) -> &Interner {
872877
&Interner
873878
}
@@ -892,6 +897,20 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
892897
) -> Arc<chalk_rust_ir::OpaqueTyDatum<Interner>> {
893898
unimplemented!()
894899
}
900+
901+
fn force_impl_for(
902+
&self,
903+
_well_known: chalk_rust_ir::WellKnownTrait,
904+
_ty: &chalk_ir::TyData<Interner>,
905+
) -> Option<bool> {
906+
// this method is mostly for rustc
907+
None
908+
}
909+
910+
fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool {
911+
// FIXME: implement actual object safety
912+
true
913+
}
895914
}
896915

897916
pub(crate) fn program_clauses_for_chalk_env_query(

0 commit comments

Comments
 (0)