1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
#![allow(dead_code)] /// Test that a database with a key/value that is not `Send` will, /// indeed, not be `Send`. /// /// ```compile_fail,E0277 /// use std::rc::Rc; /// /// use gluon_salsa as salsa; /// /// #[salsa::query_group(NoSendSyncStorage)] /// trait NoSendSyncDatabase: salsa::Database { /// fn no_send_sync_value(&self, key: bool) -> Rc<bool>; /// fn no_send_sync_key(&self, key: Rc<bool>) -> bool; /// } /// /// fn no_send_sync_value(_db: &impl NoSendSyncDatabase, key: bool) -> Rc<bool> { /// Rc::new(key) /// } /// /// fn no_send_sync_key(_db: &impl NoSendSyncDatabase, key: Rc<bool>) -> bool { /// *key /// } /// /// #[gluon_salsa::database(NoSendSyncStorage)] /// #[derive(Default)] /// struct DatabaseImpl { /// runtime: salsa::Runtime<DatabaseImpl>, /// } /// /// impl salsa::Database for DatabaseImpl { /// fn salsa_runtime(&self) -> &salsa::Runtime<Self> { /// &self.runtime /// } /// /// fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> { /// &mut self.runtime /// } /// } /// /// fn is_send<T: Send>(_: T) { } /// /// fn assert_send() { /// is_send(DatabaseImpl::default()); /// } /// ``` fn test_key_not_send_db_not_send() {} /// Test that a database with a key/value that is not `Sync` will not /// be `Send`. /// /// ```compile_fail,E0277 /// use std::rc::Rc; /// use std::cell::Cell; /// /// use gluon_salsa as salsa; /// /// #[salsa::query_group(NoSendSyncStorage)] /// trait NoSendSyncDatabase: salsa::Database { /// fn no_send_sync_value(&self, key: bool) -> Cell<bool>; /// fn no_send_sync_key(&self, key: Cell<bool>) -> bool; /// } /// /// fn no_send_sync_value(_db: &impl NoSendSyncDatabase, key: bool) -> Cell<bool> { /// Cell::new(key) /// } /// /// fn no_send_sync_key(_db: &impl NoSendSyncDatabase, key: Cell<bool>) -> bool { /// *key /// } /// /// #[gluon_salsa::database(NoSendSyncStorage)] /// #[derive(Default)] /// struct DatabaseImpl { /// runtime: salsa::Runtime<DatabaseImpl>, /// } /// /// impl salsa::Database for DatabaseImpl { /// fn salsa_runtime(&self) -> &salsa::Runtime<Self> { /// &self.runtime /// } /// /// fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> { /// &mut self.runtime /// } /// } /// /// fn is_send<T: Send>(_: T) { } /// /// fn assert_send() { /// is_send(DatabaseImpl::default()); /// } /// ``` fn test_key_not_sync_db_not_send() {}