From 050601ef7bda598e3ba289987afad7ac7ee46f7d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 May 2020 10:49:43 +0200 Subject: [PATCH] Chalk upgrade --- Cargo.lock | 24 ++++++------ crates/ra_hir_ty/Cargo.toml | 6 +-- crates/ra_hir_ty/src/traits/chalk.rs | 57 ++++++++++++++++++---------- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f94cea8143..4412b07083 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,8 +113,8 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chalk-derive" -version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "proc-macro2", "quote", @@ -124,8 +124,8 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.9.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "chalk-macros", "rustc-hash", @@ -133,8 +133,8 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "chalk-derive", "chalk-engine", @@ -143,16 +143,16 @@ dependencies = [ [[package]] name = "chalk-macros" -version = "0.1.1" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "lazy_static", ] [[package]] name = "chalk-rust-ir" -version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "chalk-derive", "chalk-engine", @@ -162,8 +162,8 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.1.0" -source = "git+https://github.com/rust-lang/chalk.git?rev=2c072cc830d04af5f10b390e6643327f85108282#2c072cc830d04af5f10b390e6643327f85108282" +version = "0.10.1-dev" +source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" dependencies = [ "chalk-derive", "chalk-engine", diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 65db6d1b08..5fc0ec5e3c 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -27,9 +27,9 @@ test_utils = { path = "../test_utils" } scoped-tls = "1" -chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" } -chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" } -chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2c072cc830d04af5f10b390e6643327f85108282" } +chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } +chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } +chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } [dev-dependencies] insta = "0.16.0" diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 1ccb7c3b4a..5870618a00 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(