]> git.lizzy.rs Git - rust.git/commitdiff
Upgrade Chalk
authorFlorian Diebold <flodiebold@gmail.com>
Fri, 10 Apr 2020 15:44:29 +0000 (17:44 +0200)
committerFlorian Diebold <flodiebold@gmail.com>
Mon, 13 Apr 2020 14:18:25 +0000 (16:18 +0200)
Cargo.lock
crates/ra_hir_ty/Cargo.toml
crates/ra_hir_ty/src/traits/chalk.rs

index 975c1aef86835efa0d24274770146933addcfd35..506efdad0275e6b3371806b10befea4fb7bc4bee 100644 (file)
@@ -114,17 +114,18 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
 [[package]]
 name = "chalk-derive"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "proc-macro2",
  "quote",
  "syn",
+ "synstructure",
 ]
 
 [[package]]
 name = "chalk-engine"
 version = "0.9.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "chalk-macros",
  "rustc-hash",
@@ -133,7 +134,7 @@ dependencies = [
 [[package]]
 name = "chalk-ir"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -143,7 +144,7 @@ dependencies = [
 [[package]]
 name = "chalk-macros"
 version = "0.1.1"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "lazy_static",
 ]
@@ -151,7 +152,7 @@ dependencies = [
 [[package]]
 name = "chalk-rust-ir"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -162,7 +163,7 @@ dependencies = [
 [[package]]
 name = "chalk-solve"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=039fc904a05f8cb3d0c682c9a57a63dda7a35356#039fc904a05f8cb3d0c682c9a57a63dda7a35356"
+source = "git+https://github.com/rust-lang/chalk.git?rev=6222e416b96892b2a86bc08de7dbc9826ff1acea#6222e416b96892b2a86bc08de7dbc9826ff1acea"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -1564,6 +1565,18 @@ dependencies = [
  "unicode-xid",
 ]
 
+[[package]]
+name = "synstructure"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "unicode-xid",
+]
+
 [[package]]
 name = "tempfile"
 version = "3.1.0"
index 59efc1c31d8c33c10de7a6536d435a3de8d16536..aaee235d89f922721a2d47b100291ce22ebe434e 100644 (file)
@@ -26,9 +26,9 @@ test_utils = { path = "../test_utils" }
 
 scoped-tls = "1"
 
-chalk-solve =   { git = "https://github.com/rust-lang/chalk.git", rev = "039fc904a05f8cb3d0c682c9a57a63dda7a35356" }
-chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "039fc904a05f8cb3d0c682c9a57a63dda7a35356" }
-chalk-ir =      { git = "https://github.com/rust-lang/chalk.git", rev = "039fc904a05f8cb3d0c682c9a57a63dda7a35356" }
+chalk-solve =   { git = "https://github.com/rust-lang/chalk.git", rev = "6222e416b96892b2a86bc08de7dbc9826ff1acea" }
+chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "6222e416b96892b2a86bc08de7dbc9826ff1acea" }
+chalk-ir =      { git = "https://github.com/rust-lang/chalk.git", rev = "6222e416b96892b2a86bc08de7dbc9826ff1acea" }
 
 [dev-dependencies]
 insta = "0.15.0"
index e05fea8430f352ca19c21d1301b89896072b2573..f6994a1f6fd8316478a60c52d0aaeb9f5efce18e 100644 (file)
@@ -32,6 +32,9 @@ impl chalk_ir::interner::Interner for Interner {
     type InternedGoal = Arc<GoalData<Self>>;
     type InternedGoals = Vec<Goal<Self>>;
     type InternedSubstitution = Vec<Parameter<Self>>;
+    type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
+    type InternedProgramClauses = Vec<chalk_ir::ProgramClause<Self>>;
+    type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
     type Identifier = TypeAliasId;
     type DefId = InternId;
 
@@ -181,6 +184,48 @@ fn substitution_data<'a>(
     ) -> &'a [Parameter<Self>] {
         substitution
     }
+
+    fn intern_program_clause(
+        &self,
+        data: chalk_ir::ProgramClauseData<Self>,
+    ) -> chalk_ir::ProgramClauseData<Self> {
+        data
+    }
+
+    fn program_clause_data<'a>(
+        &self,
+        clause: &'a chalk_ir::ProgramClauseData<Self>,
+    ) -> &'a chalk_ir::ProgramClauseData<Self> {
+        clause
+    }
+
+    fn intern_program_clauses(
+        &self,
+        data: impl IntoIterator<Item = chalk_ir::ProgramClause<Self>>,
+    ) -> Vec<chalk_ir::ProgramClause<Self>> {
+        data.into_iter().collect()
+    }
+
+    fn program_clauses_data<'a>(
+        &self,
+        clauses: &'a Vec<chalk_ir::ProgramClause<Self>>,
+    ) -> &'a [chalk_ir::ProgramClause<Self>] {
+        clauses
+    }
+
+    fn intern_quantified_where_clauses(
+        &self,
+        data: impl IntoIterator<Item = chalk_ir::QuantifiedWhereClause<Self>>,
+    ) -> Self::InternedQuantifiedWhereClauses {
+        data.into_iter().collect()
+    }
+
+    fn quantified_where_clauses_data<'a>(
+        &self,
+        clauses: &'a Self::InternedQuantifiedWhereClauses,
+    ) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
+        clauses
+    }
 }
 
 impl chalk_ir::interner::HasInterner for Interner {
@@ -238,12 +283,10 @@ fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
             Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx).intern(&Interner),
             Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
             Ty::Dyn(predicates) => {
-                let where_clauses = predicates
-                    .iter()
-                    .filter(|p| !p.is_error())
-                    .cloned()
-                    .map(|p| p.to_chalk(db))
-                    .collect();
+                let where_clauses = chalk_ir::QuantifiedWhereClauses::from(
+                    &Interner,
+                    predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)),
+                );
                 let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) };
                 chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner)
             }
@@ -281,8 +324,12 @@ fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
             chalk_ir::TyData::InferenceVar(_iv) => Ty::Unknown,
             chalk_ir::TyData::Dyn(where_clauses) => {
                 assert_eq!(where_clauses.bounds.binders.len(), 1);
-                let predicates =
-                    where_clauses.bounds.value.into_iter().map(|c| from_chalk(db, c)).collect();
+                let predicates = where_clauses
+                    .bounds
+                    .skip_binders()
+                    .iter(&Interner)
+                    .map(|c| from_chalk(db, c.clone()))
+                    .collect();
                 Ty::Dyn(predicates)
             }
         }
@@ -426,7 +473,7 @@ fn from_chalk(
     ) -> GenericPredicate {
         // we don't produce any where clauses with binders and can't currently deal with them
         match where_clause
-            .value
+            .skip_binders()
             .shifted_out(&Interner)
             .expect("unexpected bound vars in where clause")
         {
@@ -521,7 +568,7 @@ fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Environment<Interner> {
                 pred.clone().to_chalk(db).cast(&Interner);
             clauses.push(program_clause.into_from_env_clause(&Interner));
         }
-        chalk_ir::Environment::new().add_clauses(clauses)
+        chalk_ir::Environment::new(&Interner).add_clauses(&Interner, clauses)
     }
 
     fn from_chalk(
@@ -603,10 +650,10 @@ fn from_chalk(
 }
 
 fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T> {
-    chalk_ir::Binders {
+    chalk_ir::Binders::new(
+        std::iter::repeat(chalk_ir::ParameterKind::Ty(())).take(num_vars).collect(),
         value,
-        binders: std::iter::repeat(chalk_ir::ParameterKind::Ty(())).take(num_vars).collect(),
-    }
+    )
 }
 
 fn convert_where_clauses(
@@ -696,6 +743,12 @@ fn as_struct_id(&self, id: &TypeName<Interner>) -> Option<StructId> {
     fn interner(&self) -> &Interner {
         &Interner
     }
+    fn well_known_trait_id(
+        &self,
+        _well_known_trait: chalk_rust_ir::WellKnownTrait,
+    ) -> chalk_ir::TraitId<Interner> {
+        unimplemented!()
+    }
 }
 
 pub(crate) fn associated_ty_data_query(