From b832a97a51f510c77f8187c00be3b3544e195e2b Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 14:43:41 +0200 Subject: [PATCH 1/7] Update chalk to 0.22.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26a9e64b85af4..84f2c82357b2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1df0dbb57d74b4acd20f20fa66ab2acd09776b79eaeb9d8f947b2f3e01c40bf" +checksum = "f26289db4cf059de9e0ab868ab9fc0dbc64455c3b09279c62c73ea0b3948b53f" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7c65a13f32f02aba8f1d9a37f206af615f77ac564624b81a4c593c6c1735b9" +checksum = "45ea68bc2cdd40ea6b48e39580adebfe833dc72a9593426fa73589326a2e1d75" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44361a25dbdb1dc428f56ad7a3c21ba9ca12f3225c26a47919ff6fcb10a583d4" +checksum = "e155e98d67dbf34f0eaa7b5ef34b629c1d61e949196b3d2bd046e4daed7b506e" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a886da37a0dc457057d86f78f026f7a09c6d8088aa13f4f4127fdb8dc80119a3" +checksum = "08cce24bb0f20800287136fec62669bbef50409712162ee51fd1db40926d10f1" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index a5a860a38b3e8..d3aa9742a594f 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.21.0" +chalk-ir = "0.22.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 3571ff17f31be..399555ddf156c 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.21.0" -chalk-solve = "0.21.0" -chalk-engine = "0.21.0" +chalk-ir = "0.22.0" +chalk-solve = "0.22.0" +chalk-engine = "0.22.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From 52eeff6fbea7a3252ae292c8c4e23b4c7816e719 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 15:21:46 +0200 Subject: [PATCH 2/7] Update chalk to 0.23.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84f2c82357b2a..a6a2dac02b3e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26289db4cf059de9e0ab868ab9fc0dbc64455c3b09279c62c73ea0b3948b53f" +checksum = "c3cb438e961fd7f1183dc5e0bdcfd09253bf9b90592cf665d1ce6787d8a4908f" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ea68bc2cdd40ea6b48e39580adebfe833dc72a9593426fa73589326a2e1d75" +checksum = "fd715f39817e75c0f1616e1079880f2a90949af1c607033f922927780017a490" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e155e98d67dbf34f0eaa7b5ef34b629c1d61e949196b3d2bd046e4daed7b506e" +checksum = "bb332abfcb015b148c6fbab39b1d13282745b0f7f312019dd8e138f5f3f0855d" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08cce24bb0f20800287136fec62669bbef50409712162ee51fd1db40926d10f1" +checksum = "802de4eff72e5a5d2828e6c07224c74d66949dc6308aff025d0ae2871a11b4eb" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index d3aa9742a594f..eb495206bbf18 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.22.0" +chalk-ir = "0.23.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 399555ddf156c..1089e87e0b204 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.22.0" -chalk-solve = "0.22.0" -chalk-engine = "0.22.0" +chalk-ir = "0.23.0" +chalk-solve = "0.23.0" +chalk-engine = "0.23.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From cb660c6ab5c6c2c3ab7c4bd10535e68a49b940a0 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 16:02:31 +0200 Subject: [PATCH 3/7] Update chalk to 0.24.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6a2dac02b3e2..26c1d26a703d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cb438e961fd7f1183dc5e0bdcfd09253bf9b90592cf665d1ce6787d8a4908f" +checksum = "37f72751ba791492671e4cbc382c9cc0a1051e264e5c4f1cb5bba0ed58f8e65e" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd715f39817e75c0f1616e1079880f2a90949af1c607033f922927780017a490" +checksum = "196432c82e77fea69c9ef96070d66f76e91fb067caf7cf21c12878ea334358c7" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb332abfcb015b148c6fbab39b1d13282745b0f7f312019dd8e138f5f3f0855d" +checksum = "45e1d0a1980c632ba01074c44e4299257bb0227d19ac03f7f903127da788ea13" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "802de4eff72e5a5d2828e6c07224c74d66949dc6308aff025d0ae2871a11b4eb" +checksum = "f892ee7c59419a18554fdc006e2fb4237a0af85a6ae59dcc22e0408c3538a093" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index eb495206bbf18..6491d47a911a4 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.23.0" +chalk-ir = "0.24.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 1089e87e0b204..f170b38a7ecd2 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.23.0" -chalk-solve = "0.23.0" -chalk-engine = "0.23.0" +chalk-ir = "0.24.0" +chalk-solve = "0.24.0" +chalk-engine = "0.24.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From ed784023e50d47bb8b447ed3a01c254e43c39bb0 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 16:09:39 +0200 Subject: [PATCH 4/7] Update chalk to 0.25.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26c1d26a703d4..f3ed03ae67887 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37f72751ba791492671e4cbc382c9cc0a1051e264e5c4f1cb5bba0ed58f8e65e" +checksum = "624e14d3f029186e6ffd97081ffa082f98ddd5df20655b6f0e8efb83dd8ac8b4" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196432c82e77fea69c9ef96070d66f76e91fb067caf7cf21c12878ea334358c7" +checksum = "fd172df00ff1de4789ed8971e1623afb10551041a9385d3b4e22fe6b1e8a0d1d" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e1d0a1980c632ba01074c44e4299257bb0227d19ac03f7f903127da788ea13" +checksum = "118c68eccdda5604af50bbef84c94550f3854f76989cb03c36ffd36cc2ffe958" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f892ee7c59419a18554fdc006e2fb4237a0af85a6ae59dcc22e0408c3538a093" +checksum = "45b235a1f568b28707f117b2d30eabbee9cbcfccaa0d6e9697300400c8ca0996" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 6491d47a911a4..3633166df7b3d 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.24.0" +chalk-ir = "0.25.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index f170b38a7ecd2..4377871602fd4 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.24.0" -chalk-solve = "0.24.0" -chalk-engine = "0.24.0" +chalk-ir = "0.25.0" +chalk-solve = "0.25.0" +chalk-engine = "0.25.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From 61b2a6f5e5ca52328b32cc919d1f2880489a2577 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 16:49:02 +0200 Subject: [PATCH 5/7] Update chalk to 0.26.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- compiler/rustc_traits/src/chalk/db.rs | 14 ++++++++------ compiler/rustc_traits/src/chalk/lowering.rs | 15 +++++++++------ 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3ed03ae67887..fc20d70038ade 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624e14d3f029186e6ffd97081ffa082f98ddd5df20655b6f0e8efb83dd8ac8b4" +checksum = "72aade21de1aa12a31fc287ec9891915965b6d7caac1c5de5ea095b6b9bc4cc4" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd172df00ff1de4789ed8971e1623afb10551041a9385d3b4e22fe6b1e8a0d1d" +checksum = "fcffc1240cc5f9c5d1d8028d35a293e193a647a71244d51d3d5b4295cbea0593" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "118c68eccdda5604af50bbef84c94550f3854f76989cb03c36ffd36cc2ffe958" +checksum = "6b856e69b664ca362a30c21f477fe10f59f74458978bc9bfd667820549bc7758" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45b235a1f568b28707f117b2d30eabbee9cbcfccaa0d6e9697300400c8ca0996" +checksum = "abae2ca9cca3b0a2f33fe946a688881a8b17b8edc088fe3820cb770275e965ed" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 3633166df7b3d..026f810fd793a 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.25.0" +chalk-ir = "0.26.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 4377871602fd4..cd718def79bfb 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.25.0" -chalk-solve = "0.25.0" -chalk-engine = "0.25.0" +chalk-ir = "0.26.0" +chalk-solve = "0.26.0" +chalk-engine = "0.26.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 2fad54013ad5b..5804296540a7f 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -11,7 +11,6 @@ use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef}; use rustc_middle::ty::{self, AssocItemContainer, AssocKind, TyCtxt, TypeFoldable}; use rustc_hir::def_id::DefId; -use rustc_hir::Unsafety; use rustc_span::symbol::sym; @@ -19,6 +18,7 @@ use std::fmt; use std::sync::Arc; use crate::chalk::lowering::{self, LowerInto}; +use rustc_hir::Unsafety; pub struct RustIrDatabase<'tcx> { pub(crate) interner: RustInterner<'tcx>, @@ -247,12 +247,14 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t }; Arc::new(chalk_solve::rust_ir::FnDefDatum { id: fn_def_id, - abi: sig.abi(), - safety: match sig.unsafety() { - Unsafety::Normal => chalk_ir::Safety::Safe, - Unsafety::Unsafe => chalk_ir::Safety::Unsafe, + sig: chalk_ir::FnSig { + abi: sig.abi(), + safety: match sig.unsafety() { + Unsafety::Normal => chalk_ir::Safety::Safe, + Unsafety::Unsafe => chalk_ir::Safety::Unsafe, + }, + variadic: sig.c_variadic(), }, - variadic: sig.c_variadic(), binders: chalk_ir::Binders::new(binders, bound), }) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 650404e8ca6dd..3a84efb880b4c 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -340,18 +340,20 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { collect_bound_vars(interner, interner.tcx, &sig.inputs_and_output()); TyData::Function(chalk_ir::FnPointer { num_binders: binders.len(interner), + sig: chalk_ir::FnSig { + abi: sig.abi(), + safety: match sig.unsafety() { + rustc_hir::Unsafety::Normal => chalk_ir::Safety::Safe, + rustc_hir::Unsafety::Unsafe => chalk_ir::Safety::Unsafe, + }, + variadic: sig.c_variadic(), + }, substitution: chalk_ir::Substitution::from_iter( interner, inputs_and_outputs.iter().map(|ty| { chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner) }), ), - abi: sig.abi(), - safety: match sig.unsafety() { - rustc_hir::Unsafety::Normal => chalk_ir::Safety::Safe, - rustc_hir::Unsafety::Unsafe => chalk_ir::Safety::Unsafe, - }, - variadic: sig.c_variadic(), }) .intern(interner) } @@ -480,6 +482,7 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { substs: application_ty.substitution.lower_into(interner), item_def_id: assoc_ty.0, }), + chalk_ir::TypeName::Foreign(def_id) => ty::Foreign(def_id.0), chalk_ir::TypeName::Error => unimplemented!(), }, TyData::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder { From 5f67571e34882ae796d513fcc0f3acb16f44146e Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 16:59:21 +0200 Subject: [PATCH 6/7] Update chalk to 0.27.0 --- Cargo.lock | 16 ++++++++-------- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +++--- compiler/rustc_traits/src/chalk/db.rs | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc20d70038ade..a9ab90f40093e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72aade21de1aa12a31fc287ec9891915965b6d7caac1c5de5ea095b6b9bc4cc4" +checksum = "d5444ff2a211fe2a863e44d16a368c3d8a314d489de21b8eeb6879f14dd5d4a8" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcffc1240cc5f9c5d1d8028d35a293e193a647a71244d51d3d5b4295cbea0593" +checksum = "5b8ba5b42db32c9c92deec8baf6821628b1234eaa296c48dff39cecbce3c0271" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b856e69b664ca362a30c21f477fe10f59f74458978bc9bfd667820549bc7758" +checksum = "e39c3db1dd4abfaa7658faaa62e5fe998a982a592b710bd971fad5b6adfcfdef" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abae2ca9cca3b0a2f33fe946a688881a8b17b8edc088fe3820cb770275e965ed" +checksum = "a673abe3077adc25f8ee0894198aed494a5bb0ce50ee993900d0ee1a44e1948a" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 026f810fd793a..b4e1a380ce56d 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.26.0" +chalk-ir = "0.27.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index cd718def79bfb..b9223e4fcef0a 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.26.0" -chalk-solve = "0.26.0" -chalk-engine = "0.26.0" +chalk-ir = "0.27.0" +chalk-solve = "0.27.0" +chalk-engine = "0.27.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 5804296540a7f..30c33f1e1a631 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -427,6 +427,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t FnMut => self.interner.tcx.lang_items().fn_mut_trait(), FnOnce => self.interner.tcx.lang_items().fn_once_trait(), Unsize => self.interner.tcx.lang_items().unsize_trait(), + Unpin => self.interner.tcx.lang_items().unpin_trait(), }; def_id.map(chalk_ir::TraitId) } From 51c781f6138ec541c9e3dff30e8d049027075e79 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Thu, 24 Sep 2020 17:37:55 +0200 Subject: [PATCH 7/7] Upgrade chalk to 0.28.0 --- Cargo.lock | 16 ++-- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_traits/Cargo.toml | 6 +- compiler/rustc_traits/src/chalk/db.rs | 99 +++++++++++++++------ compiler/rustc_traits/src/chalk/lowering.rs | 27 +++--- 5 files changed, 103 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9ab90f40093e..daaa4ae44bac6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5444ff2a211fe2a863e44d16a368c3d8a314d489de21b8eeb6879f14dd5d4a8" +checksum = "8c85b013e2dc1b46ac4a279f54e62e55556a8c4d859f7b7c4e340a9b1d013640" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8ba5b42db32c9c92deec8baf6821628b1234eaa296c48dff39cecbce3c0271" +checksum = "2a499f81860f6eadfe0c76c5bb606cd2df701939d5a596ed3724c7db04aec14b" dependencies = [ "chalk-derive", "chalk-ir", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e39c3db1dd4abfaa7658faaa62e5fe998a982a592b710bd971fad5b6adfcfdef" +checksum = "2135d844688dc920e3ece3012c5d3d4f06e26986fe38bc041bc98f0e7a9f4e2b" dependencies = [ "chalk-derive", "lazy_static", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a673abe3077adc25f8ee0894198aed494a5bb0ce50ee993900d0ee1a44e1948a" +checksum = "bc69e4e94ffd4b39f1a865824b431bb82a7b4c8f14a0ba3d461cd86e56a590ac" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index b4e1a380ce56d..5136e2743cdb1 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.27.0" +chalk-ir = "0.28.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index b9223e4fcef0a..369d003eb22f7 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.27.0" -chalk-solve = "0.27.0" -chalk-engine = "0.27.0" +chalk-ir = "0.28.0" +chalk-solve = "0.28.0" +chalk-engine = "0.28.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 30c33f1e1a631..828ee6dea6256 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -18,7 +18,7 @@ use std::fmt; use std::sync::Arc; use crate::chalk::lowering::{self, LowerInto}; -use rustc_hir::Unsafety; +use rustc_ast::ast; pub struct RustIrDatabase<'tcx> { pub(crate) interner: RustInterner<'tcx>, @@ -247,14 +247,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t }; Arc::new(chalk_solve::rust_ir::FnDefDatum { id: fn_def_id, - sig: chalk_ir::FnSig { - abi: sig.abi(), - safety: match sig.unsafety() { - Unsafety::Normal => chalk_ir::Safety::Safe, - Unsafety::Unsafe => chalk_ir::Safety::Unsafe, - }, - variadic: sig.c_variadic(), - }, + sig: sig.lower_into(&self.interner), binders: chalk_ir::Binders::new(binders, bound), }) } @@ -329,21 +322,75 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t fn impl_provided_for( &self, auto_trait_id: chalk_ir::TraitId>, - adt_id: chalk_ir::AdtId>, + app_ty: &chalk_ir::ApplicationTy>, ) -> bool { + use chalk_ir::Scalar::*; + use chalk_ir::TypeName::*; + let trait_def_id = auto_trait_id.0; - let adt_def = adt_id.0; let all_impls = self.interner.tcx.all_impls(trait_def_id); for impl_def_id in all_impls { let trait_ref = self.interner.tcx.impl_trait_ref(impl_def_id).unwrap(); let self_ty = trait_ref.self_ty(); - match *self_ty.kind() { - ty::Adt(impl_adt_def, _) => { - if impl_adt_def == adt_def { - return true; + let provides = match (self_ty.kind(), app_ty.name) { + (&ty::Adt(impl_adt_def, ..), Adt(id)) => impl_adt_def.did == id.0.did, + (_, AssociatedType(_ty_id)) => { + // FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774 + false + } + (ty::Bool, Scalar(Bool)) => true, + (ty::Char, Scalar(Char)) => true, + (ty::Int(ty1), Scalar(Int(ty2))) => match (ty1, ty2) { + (ast::IntTy::Isize, chalk_ir::IntTy::Isize) + | (ast::IntTy::I8, chalk_ir::IntTy::I8) + | (ast::IntTy::I16, chalk_ir::IntTy::I16) + | (ast::IntTy::I32, chalk_ir::IntTy::I32) + | (ast::IntTy::I64, chalk_ir::IntTy::I64) + | (ast::IntTy::I128, chalk_ir::IntTy::I128) => true, + _ => false, + }, + (ty::Uint(ty1), Scalar(Uint(ty2))) => match (ty1, ty2) { + (ast::UintTy::Usize, chalk_ir::UintTy::Usize) + | (ast::UintTy::U8, chalk_ir::UintTy::U8) + | (ast::UintTy::U16, chalk_ir::UintTy::U16) + | (ast::UintTy::U32, chalk_ir::UintTy::U32) + | (ast::UintTy::U64, chalk_ir::UintTy::U64) + | (ast::UintTy::U128, chalk_ir::UintTy::U128) => true, + _ => false, + }, + (ty::Float(ty1), Scalar(Float(ty2))) => match (ty1, ty2) { + (ast::FloatTy::F32, chalk_ir::FloatTy::F32) + | (ast::FloatTy::F64, chalk_ir::FloatTy::F64) => true, + _ => false, + }, + (&ty::Tuple(..), Tuple(..)) => true, + (&ty::Array(..), Array) => true, + (&ty::Slice(..), Slice) => true, + (&ty::RawPtr(type_and_mut), Raw(mutability)) => { + match (type_and_mut.mutbl, mutability) { + (ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true, + (ast::Mutability::Mut, chalk_ir::Mutability::Not) => false, + (ast::Mutability::Not, chalk_ir::Mutability::Mut) => false, + (ast::Mutability::Not, chalk_ir::Mutability::Not) => true, } } - _ => {} + (&ty::Ref(.., mutability1), Ref(mutability2)) => match (mutability1, mutability2) { + (ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true, + (ast::Mutability::Mut, chalk_ir::Mutability::Not) => false, + (ast::Mutability::Not, chalk_ir::Mutability::Mut) => false, + (ast::Mutability::Not, chalk_ir::Mutability::Not) => true, + }, + (&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id)) => def_id == opaque_ty_id.0, + (&ty::FnDef(def_id, ..), FnDef(fn_def_id)) => def_id == fn_def_id.0, + (&ty::Str, Str) => true, + (&ty::Never, Never) => true, + (&ty::Closure(def_id, ..), Closure(closure_id)) => def_id == closure_id.0, + (&ty::Foreign(def_id), Foreign(foreign_def_id)) => def_id == foreign_def_id.0, + (&ty::Error(..), Error) => false, + _ => false, + }; + if provides { + return true; } } false @@ -418,16 +465,18 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t well_known_trait: chalk_solve::rust_ir::WellKnownTrait, ) -> Option>> { use chalk_solve::rust_ir::WellKnownTrait::*; + let lang_items = self.interner.tcx.lang_items(); let def_id = match well_known_trait { - Sized => self.interner.tcx.lang_items().sized_trait(), - Copy => self.interner.tcx.lang_items().copy_trait(), - Clone => self.interner.tcx.lang_items().clone_trait(), - Drop => self.interner.tcx.lang_items().drop_trait(), - Fn => self.interner.tcx.lang_items().fn_trait(), - FnMut => self.interner.tcx.lang_items().fn_mut_trait(), - FnOnce => self.interner.tcx.lang_items().fn_once_trait(), - Unsize => self.interner.tcx.lang_items().unsize_trait(), - Unpin => self.interner.tcx.lang_items().unpin_trait(), + Sized => lang_items.sized_trait(), + Copy => lang_items.copy_trait(), + Clone => lang_items.clone_trait(), + Drop => lang_items.drop_trait(), + Fn => lang_items.fn_trait(), + FnMut => lang_items.fn_mut_trait(), + FnOnce => lang_items.fn_once_trait(), + Unsize => lang_items.unsize_trait(), + Unpin => lang_items.unpin_trait(), + CoerceUnsized => lang_items.coerce_unsized_trait(), }; def_id.map(chalk_ir::TraitId) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 3a84efb880b4c..1e1841a57f818 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -39,6 +39,8 @@ use rustc_middle::ty::{ }; use rustc_span::def_id::DefId; +use chalk_ir::{FnSig, ForeignDefId}; +use rustc_hir::Unsafety; use std::collections::btree_map::{BTreeMap, Entry}; /// Essentially an `Into` with a `&RustInterner` parameter @@ -269,8 +271,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { ast::FloatTy::F64 => float(chalk_ir::FloatTy::F64), }, Adt(def, substs) => apply(struct_ty(def.did), substs.lower_into(interner)), - // FIXME(chalk): lower Foreign - Foreign(def_id) => apply(chalk_ir::TypeName::FnDef(chalk_ir::FnDefId(def_id)), empty()), + Foreign(def_id) => apply(chalk_ir::TypeName::Foreign(ForeignDefId(def_id)), empty()), Str => apply(chalk_ir::TypeName::Str, empty()), Array(ty, len) => { let value = match len.val { @@ -340,14 +341,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { collect_bound_vars(interner, interner.tcx, &sig.inputs_and_output()); TyData::Function(chalk_ir::FnPointer { num_binders: binders.len(interner), - sig: chalk_ir::FnSig { - abi: sig.abi(), - safety: match sig.unsafety() { - rustc_hir::Unsafety::Normal => chalk_ir::Safety::Safe, - rustc_hir::Unsafety::Unsafe => chalk_ir::Safety::Unsafe, - }, - variadic: sig.c_variadic(), - }, + sig: sig.lower_into(interner), substitution: chalk_ir::Substitution::from_iter( interner, inputs_and_outputs.iter().map(|ty| { @@ -721,6 +715,19 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders LowerInto<'tcx, chalk_ir::FnSig>> for ty::Binder> { + fn lower_into(self, _interner: &RustInterner<'_>) -> FnSig> { + chalk_ir::FnSig { + abi: self.abi(), + safety: match self.unsafety() { + Unsafety::Normal => chalk_ir::Safety::Safe, + Unsafety::Unsafe => chalk_ir::Safety::Unsafe, + }, + variadic: self.c_variadic(), + } + } +} + /// To collect bound vars, we have to do two passes. In the first pass, we /// collect all `BoundRegion`s and `ty::Bound`s. In the second pass, we then /// replace `BrNamed` into `BrAnon`. The two separate passes are important,