From cc5885552edc6fb8d59007dadb7b7d1d8dd8b173 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 22 Mar 2022 23:39:11 -0700 Subject: [PATCH 1/2] upgrade chalk --- 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 48518008b7d45..80f0a0b8b5ba3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -515,9 +515,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chalk-derive" -version = "0.76.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c24b8052ea1e3adbb6f9ab7ba5fcc18b9d12591c042de4c833f709ce81e0e0" +checksum = "d0001adf0cf12361e08b65e1898ea138f8f77d8f5177cbf29b6b3b3532252bd6" dependencies = [ "proc-macro2", "quote", @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.76.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eca186b6ea9af798312f4b568fd094c82e7946ac08be5dc5fea22decc6d2ed8" +checksum = "c44ee96f2d67cb5193d1503f185db1abad9933a1c6e6b4169c176f90baecd393" dependencies = [ "chalk-derive", "chalk-ir", @@ -540,9 +540,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.76.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cad5c3f1edd4b4a2c9bda24ae558ceb4f88336f88f944c2e35d0bfeb13c818" +checksum = "92d8a95548f23618fda86426e4304e563ec2bb7ba0216139f0748d63c107b5f1" dependencies = [ "bitflags", "chalk-derive", @@ -551,9 +551,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.76.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94533188d3452bc72cbd5618d166f45fc7646b674ad3fe9667d557bc25236dee" +checksum = "f37f492dacfafe2e21319b80827da2779932909bb392f0cc86b2bd5c07c1b4e1" dependencies = [ "chalk-derive", "chalk-ir", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index b1334410237e7..9cfc5f5b444df 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -29,7 +29,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.76.0" +chalk-ir = "0.80.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } rustc_session = { path = "../rustc_session" } rustc_type_ir = { path = "../rustc_type_ir" } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 25f228c789031..67f878df31cb5 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.76.0" -chalk-engine = "0.76.0" -chalk-solve = "0.76.0" +chalk-ir = "0.80.0" +chalk-engine = "0.80.0" +chalk-solve = "0.80.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } From 376d100e7473d094acb202dab08022be8cf65a83 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 23 Mar 2022 21:52:17 -0700 Subject: [PATCH 2/2] make rustc work again --- compiler/rustc_traits/src/chalk/db.rs | 47 +++++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 9b85242e90a71..6424b90747876 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -100,6 +100,8 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t &self, trait_id: chalk_ir::TraitId>, ) -> Arc>> { + use chalk_solve::rust_ir::WellKnownTrait::*; + let def_id = trait_id.0; let trait_def = self.interner.tcx.trait_def(def_id); @@ -119,25 +121,27 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let lang_items = self.interner.tcx.lang_items(); let well_known = if lang_items.sized_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Sized) + Some(Sized) } else if lang_items.copy_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Copy) + Some(Copy) } else if lang_items.clone_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Clone) + Some(Clone) } else if lang_items.drop_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Drop) + Some(Drop) } else if lang_items.fn_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Fn) + Some(Fn) } else if lang_items.fn_once_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::FnOnce) + Some(FnOnce) } else if lang_items.fn_mut_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::FnMut) + Some(FnMut) } else if lang_items.unsize_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Unsize) + Some(Unsize) } else if lang_items.unpin_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::Unpin) + Some(Unpin) } else if lang_items.coerce_unsized_trait() == Some(def_id) { - Some(chalk_solve::rust_ir::WellKnownTrait::CoerceUnsized) + Some(CoerceUnsized) + } else if lang_items.dispatch_from_dyn_trait() == Some(def_id) { + Some(DispatchFromDyn) } else { None }; @@ -232,6 +236,28 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t }) } + fn adt_size_align( + &self, + adt_id: chalk_ir::AdtId>, + ) -> Arc { + let tcx = self.interner.tcx; + let did = adt_id.0.did(); + + // Grab the ADT and the param we might need to calculate its layout + let param_env = tcx.param_env(did); + let adt_ty = tcx.type_of(did); + + // The ADT is a 1-zst if it's a ZST and its alignment is 1. + // Mark the ADT as _not_ a 1-zst if there was a layout error. + let one_zst = if let Ok(layout) = tcx.layout_of(param_env.and(adt_ty)) { + layout.is_zst() && layout.align.abi.bytes() == 1 + } else { + false + }; + + Arc::new(chalk_solve::rust_ir::AdtSizeAlign::from_one_zst(one_zst)) + } + fn fn_def_datum( &self, fn_def_id: chalk_ir::FnDefId>, @@ -540,6 +566,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t Unpin => lang_items.unpin_trait(), CoerceUnsized => lang_items.coerce_unsized_trait(), DiscriminantKind => lang_items.discriminant_kind_trait(), + DispatchFromDyn => lang_items.dispatch_from_dyn_trait(), }; def_id.map(chalk_ir::TraitId) }