Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
47 changes: 37 additions & 10 deletions compiler/rustc_traits/src/chalk/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
&self,
trait_id: chalk_ir::TraitId<RustInterner<'tcx>>,
) -> Arc<chalk_solve::rust_ir::TraitDatum<RustInterner<'tcx>>> {
use chalk_solve::rust_ir::WellKnownTrait::*;

let def_id = trait_id.0;
let trait_def = self.interner.tcx.trait_def(def_id);

Expand All @@ -119,25 +121,27 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> 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
};
Expand Down Expand Up @@ -232,6 +236,28 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
})
}

fn adt_size_align(
&self,
adt_id: chalk_ir::AdtId<RustInterner<'tcx>>,
) -> Arc<chalk_solve::rust_ir::AdtSizeAlign> {
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<RustInterner<'tcx>>,
Expand Down Expand Up @@ -540,6 +566,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> 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)
}
Expand Down