convert DatabaseSlot to unsafe trait

The unsafe impl now asserts that the `DatabaseSlot` implementor type
is indeed `Send+Sync` if `DB::DatabaseData` is `Send+Sync`. Since our
query keys/values are a part of database-data, this means that `Slot`
must be `Send+Sync` if the key/value are `Send+Sync`. We test this
with a function that will cause compliation to fail if we accidentally
introduce an `Rc<T>` etc.
This commit is contained in:
Niko Matsakis 2019-06-20 20:46:51 -07:00
parent 579e093213
commit e7d704dd8b
8 changed files with 250 additions and 9 deletions

View file

@ -367,7 +367,9 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
#[derive(Default, Debug)]
#trait_vis struct #qt;
impl<#db> salsa::Query<#db> for #qt
// Unsafe proof obligation: that our key/value are a part
// of the `GroupData`.
unsafe impl<#db> salsa::Query<#db> for #qt
where
DB: #trait_name + #requires,
DB: salsa::plumbing::HasQueryGroup<#group_struct>,