diff --git a/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.rs b/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.rs new file mode 100644 index 00000000..d8e9bbba --- /dev/null +++ b/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.rs @@ -0,0 +1,31 @@ +#[salsa::jar(db = Db)] +pub struct Jar(a::MyInput); + +mod a { + use crate::Jar; + + #[salsa::input(jar = Jar)] + pub struct MyInput { + field: u32, + } +} + +pub trait Db: salsa::DbWithJar {} + +#[salsa::db(Jar)] +#[derive(Default)] +struct Database { + storage: salsa::Storage, +} + +impl salsa::Database for Database {} + +impl Db for Database {} + +fn main() { + let mut db = Database::default(); + let input = a::MyInput::new(&mut db, 22); + + input.field(&db); + input.set_field(&mut db).to(23); +} diff --git a/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.stderr b/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.stderr new file mode 100644 index 00000000..8d547292 --- /dev/null +++ b/salsa-2022-tests/tests/compile-fail/get-set-on-private-field.stderr @@ -0,0 +1,17 @@ +error[E0624]: associated function `field` is private + --> tests/compile-fail/get-set-on-private-field.rs:29:11 + | +7 | #[salsa::input(jar = Jar)] + | -------------------------- private associated function defined here +... +29 | input.field(&db); + | ^^^^^ private associated function + +error[E0624]: associated function `set_field` is private + --> tests/compile-fail/get-set-on-private-field.rs:30:11 + | +7 | #[salsa::input(jar = Jar)] + | -------------------------- private associated function defined here +... +30 | input.set_field(&mut db).to(23); + | ^^^^^^^^^ private associated function