]> git.lizzy.rs Git - rust.git/commitdiff
Upgrade Chalk
authorFlorian Diebold <florian.diebold@freiheit.com>
Fri, 27 Mar 2020 13:50:08 +0000 (14:50 +0100)
committerFlorian Diebold <flodiebold@gmail.com>
Sun, 5 Apr 2020 17:23:18 +0000 (19:23 +0200)
Cargo.lock
crates/ra_hir_ty/Cargo.toml
crates/ra_hir_ty/src/traits.rs
crates/ra_hir_ty/src/traits/chalk.rs

index d3ca9684b5e7f031b5f4f7fa51d885e09b590db9..c46bf944834d535cdd921986a90b19c2cf38cdff 100644 (file)
@@ -114,7 +114,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
 [[package]]
 name = "chalk-derive"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -124,7 +124,7 @@ dependencies = [
 [[package]]
 name = "chalk-engine"
 version = "0.9.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "chalk-macros",
  "rustc-hash",
@@ -133,7 +133,7 @@ dependencies = [
 [[package]]
 name = "chalk-ir"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -143,7 +143,7 @@ dependencies = [
 [[package]]
 name = "chalk-macros"
 version = "0.1.1"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "lazy_static",
 ]
@@ -151,7 +151,7 @@ dependencies = [
 [[package]]
 name = "chalk-rust-ir"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -162,7 +162,7 @@ dependencies = [
 [[package]]
 name = "chalk-solve"
 version = "0.1.0"
-source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
+source = "git+https://github.com/rust-lang/chalk.git?rev=d383af7333cc6014e9d9e3e77668b5d5b0a5b40e#d383af7333cc6014e9d9e3e77668b5d5b0a5b40e"
 dependencies = [
  "chalk-derive",
  "chalk-engine",
@@ -170,7 +170,7 @@ dependencies = [
  "chalk-macros",
  "chalk-rust-ir",
  "ena",
- "itertools 0.8.2",
+ "itertools",
  "petgraph",
  "rustc-hash",
 ]
@@ -505,15 +505,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "itertools"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
-dependencies = [
- "either",
-]
-
 [[package]]
 name = "itertools"
 version = "0.9.0"
@@ -873,7 +864,7 @@ name = "ra_assists"
 version = "0.1.0"
 dependencies = [
  "either",
- "itertools 0.9.0",
+ "itertools",
  "ra_db",
  "ra_fmt",
  "ra_hir",
@@ -927,7 +918,7 @@ dependencies = [
 name = "ra_fmt"
 version = "0.1.0"
 dependencies = [
- "itertools 0.9.0",
+ "itertools",
  "ra_syntax",
 ]
 
@@ -937,7 +928,7 @@ version = "0.1.0"
 dependencies = [
  "arrayvec",
  "either",
- "itertools 0.9.0",
+ "itertools",
  "log",
  "ra_db",
  "ra_hir_def",
@@ -1015,7 +1006,7 @@ dependencies = [
  "either",
  "indexmap",
  "insta",
- "itertools 0.9.0",
+ "itertools",
  "log",
  "ra_assists",
  "ra_cfg",
@@ -1127,7 +1118,7 @@ name = "ra_syntax"
 version = "0.1.0"
 dependencies = [
  "arrayvec",
- "itertools 0.9.0",
+ "itertools",
  "once_cell",
  "ra_parser",
  "ra_text_edit",
@@ -1305,7 +1296,7 @@ dependencies = [
  "crossbeam-channel",
  "env_logger",
  "globset",
- "itertools 0.9.0",
+ "itertools",
  "jod-thread",
  "log",
  "lsp-server",
index 5a58d70cf09fda9d44b6286085b6be17a607e8cd..2cbab800dff8481f740d211538b9e4b2ca275f80 100644 (file)
@@ -23,9 +23,9 @@ ra_prof = { path = "../ra_prof" }
 ra_syntax = { path = "../ra_syntax" }
 test_utils = { path = "../test_utils" }
 
-chalk-solve =   { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
-chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
-chalk-ir =      { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
+chalk-solve =   { git = "https://github.com/rust-lang/chalk.git", rev = "d383af7333cc6014e9d9e3e77668b5d5b0a5b40e" }
+chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "d383af7333cc6014e9d9e3e77668b5d5b0a5b40e" }
+chalk-ir =      { git = "https://github.com/rust-lang/chalk.git", rev = "d383af7333cc6014e9d9e3e77668b5d5b0a5b40e" }
 
 [dev-dependencies]
 insta = "0.15.0"
index a1ca33c985bfc5dd524fa4c10685cd742699a563..80eae4eca570d508877420a2d93577ef3b432f96 100644 (file)
@@ -153,7 +153,7 @@ pub(crate) fn trait_solve_query(
         }
     }
 
-    let canonical = goal.to_chalk(db).cast();
+    let canonical = goal.to_chalk(db).cast(&Interner);
 
     // We currently don't deal with universes (I think / hope they're not yet
     // relevant for our use cases?)
@@ -194,8 +194,8 @@ fn solution_from_chalk(
     let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<Interner>>| {
         let value = subst
             .value
-            .into_iter()
-            .map(|p| match p.ty() {
+            .iter(&Interner)
+            .map(|p| match p.ty(&Interner) {
                 Some(ty) => from_chalk(db, ty.clone()),
                 None => unimplemented!(),
             })
index 943d5f125998b5d03f9720baadce83ff43fb4bba..ab4cb33b4aacd5a1cfd68ffeb7b4e5df18a149b2 100644 (file)
@@ -59,53 +59,126 @@ fn debug_alias(
         None
     }
 
+    fn debug_ty(_ty: &chalk_ir::Ty<Self>, _fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_lifetime(
+        _lifetime: &chalk_ir::Lifetime<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_parameter(
+        _parameter: &Parameter<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_goal(_goal: &Goal<Self>, _fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_goals(
+        _goals: &chalk_ir::Goals<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_program_clause_implication(
+        _pci: &chalk_ir::ProgramClauseImplication<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_application_ty(
+        _application_ty: &chalk_ir::ApplicationTy<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_substitution(
+        _substitution: &chalk_ir::Substitution<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
+    fn debug_separator_trait_ref(
+        _separator_trait_ref: &chalk_ir::SeparatorTraitRef<Self>,
+        _fmt: &mut fmt::Formatter<'_>,
+    ) -> Option<fmt::Result> {
+        None
+    }
+
     fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> {
         Box::new(ty)
     }
 
-    fn ty_data(ty: &Box<chalk_ir::TyData<Self>>) -> &chalk_ir::TyData<Self> {
+    fn ty_data<'a>(&self, ty: &'a Box<chalk_ir::TyData<Self>>) -> &'a chalk_ir::TyData<Self> {
         ty
     }
 
-    fn intern_lifetime(lifetime: chalk_ir::LifetimeData<Self>) -> chalk_ir::LifetimeData<Self> {
+    fn intern_lifetime(
+        &self,
+        lifetime: chalk_ir::LifetimeData<Self>,
+    ) -> chalk_ir::LifetimeData<Self> {
         lifetime
     }
 
-    fn lifetime_data(lifetime: &chalk_ir::LifetimeData<Self>) -> &chalk_ir::LifetimeData<Self> {
+    fn lifetime_data<'a>(
+        &self,
+        lifetime: &'a chalk_ir::LifetimeData<Self>,
+    ) -> &'a chalk_ir::LifetimeData<Self> {
         lifetime
     }
 
-    fn intern_parameter(parameter: chalk_ir::ParameterData<Self>) -> chalk_ir::ParameterData<Self> {
+    fn intern_parameter(
+        &self,
+        parameter: chalk_ir::ParameterData<Self>,
+    ) -> chalk_ir::ParameterData<Self> {
         parameter
     }
 
-    fn parameter_data(parameter: &chalk_ir::ParameterData<Self>) -> &chalk_ir::ParameterData<Self> {
+    fn parameter_data<'a>(
+        &self,
+        parameter: &'a chalk_ir::ParameterData<Self>,
+    ) -> &'a chalk_ir::ParameterData<Self> {
         parameter
     }
 
-    fn intern_goal(goal: GoalData<Self>) -> Arc<GoalData<Self>> {
+    fn intern_goal(&self, goal: GoalData<Self>) -> Arc<GoalData<Self>> {
         Arc::new(goal)
     }
 
-    fn intern_goals(data: impl IntoIterator<Item = Goal<Self>>) -> Self::InternedGoals {
+    fn intern_goals(&self, data: impl IntoIterator<Item = Goal<Self>>) -> Self::InternedGoals {
         data.into_iter().collect()
     }
 
-    fn goal_data(goal: &Arc<GoalData<Self>>) -> &GoalData<Self> {
+    fn goal_data<'a>(&self, goal: &'a Arc<GoalData<Self>>) -> &'a GoalData<Self> {
         goal
     }
 
-    fn goals_data(goals: &Vec<Goal<Interner>>) -> &[Goal<Interner>] {
+    fn goals_data<'a>(&self, goals: &'a Vec<Goal<Interner>>) -> &'a [Goal<Interner>] {
         goals
     }
 
     fn intern_substitution<E>(
+        &self,
         data: impl IntoIterator<Item = Result<Parameter<Self>, E>>,
     ) -> Result<Vec<Parameter<Self>>, E> {
         data.into_iter().collect()
     }
 
-    fn substitution_data(substitution: &Vec<Parameter<Self>>) -> &[Parameter<Self>] {
+    fn substitution_data<'a>(
+        &self,
+        substitution: &'a Vec<Parameter<Self>>,
+    ) -> &'a [Parameter<Self>] {
         substitution
     }
 }
@@ -145,12 +218,14 @@ fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
             Ty::Apply(apply_ty) => {
                 let name = apply_ty.ctor.to_chalk(db);
                 let substitution = apply_ty.parameters.to_chalk(db);
-                chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
+                chalk_ir::ApplicationTy { name, substitution }.cast(&Interner).intern(&Interner)
             }
             Ty::Projection(proj_ty) => {
                 let associated_ty_id = proj_ty.associated_ty.to_chalk(db);
                 let substitution = proj_ty.parameters.to_chalk(db);
-                chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern(&Interner)
+                chalk_ir::AliasTy { associated_ty_id, substitution }
+                    .cast(&Interner)
+                    .intern(&Interner)
             }
             Ty::Placeholder(id) => {
                 let interned_id = db.intern_type_param_id(id);
@@ -173,14 +248,14 @@ fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
                 chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner)
             }
             Ty::Opaque(_) | Ty::Unknown => {
-                let substitution = chalk_ir::Substitution::empty();
+                let substitution = chalk_ir::Substitution::empty(&Interner);
                 let name = TypeName::Error;
-                chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
+                chalk_ir::ApplicationTy { name, substitution }.cast(&Interner).intern(&Interner)
             }
         }
     }
     fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
-        match chalk.data().clone() {
+        match chalk.data(&Interner).clone() {
             chalk_ir::TyData::Apply(apply_ty) => match apply_ty.name {
                 TypeName::Error => Ty::Unknown,
                 _ => {
@@ -218,13 +293,13 @@ impl ToChalk for Substs {
     type Chalk = chalk_ir::Substitution<Interner>;
 
     fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> {
-        chalk_ir::Substitution::from(self.iter().map(|ty| ty.clone().to_chalk(db)))
+        chalk_ir::Substitution::from(&Interner, self.iter().map(|ty| ty.clone().to_chalk(db)))
     }
 
     fn from_chalk(db: &dyn HirDatabase, parameters: chalk_ir::Substitution<Interner>) -> Substs {
         let tys = parameters
-            .into_iter()
-            .map(|p| match p.ty() {
+            .iter(&Interner)
+            .map(|p| match p.ty(&Interner) {
                 Some(ty) => from_chalk(db, ty.clone()),
                 None => unimplemented!(),
             })
@@ -400,8 +475,8 @@ impl ToChalk for Obligation {
 
     fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal<Interner> {
         match self {
-            Obligation::Trait(tr) => tr.to_chalk(db).cast(),
-            Obligation::Projection(pr) => pr.to_chalk(db).cast(),
+            Obligation::Trait(tr) => tr.to_chalk(db).cast(&Interner),
+            Obligation::Projection(pr) => pr.to_chalk(db).cast(&Interner),
         }
     }
 
@@ -438,8 +513,8 @@ fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Environment<Interner> {
                 continue;
             }
             let program_clause: chalk_ir::ProgramClause<Interner> =
-                pred.clone().to_chalk(db).cast();
-            clauses.push(program_clause.into_from_env_clause());
+                pred.clone().to_chalk(db).cast(&Interner);
+            clauses.push(program_clause.into_from_env_clause(&Interner));
         }
         chalk_ir::Environment::new().add_clauses(clauses)
     }
@@ -578,9 +653,9 @@ fn impls_for_trait(
             .map(|impl_| impl_.to_chalk(self.db))
             .collect();
 
-        let ty: Ty = from_chalk(self.db, parameters[0].assert_ty_ref().clone());
+        let ty: Ty = from_chalk(self.db, parameters[0].assert_ty_ref(&Interner).clone());
         let arg: Option<Ty> =
-            parameters.get(1).map(|p| from_chalk(self.db, p.assert_ty_ref().clone()));
+            parameters.get(1).map(|p| from_chalk(self.db, p.assert_ty_ref(&Interner).clone()));
 
         builtin::get_builtin_impls(self.db, self.krate, &ty, &arg, trait_, |i| {
             result.push(i.to_chalk(self.db))