mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-10-23 04:46:35 +00:00
wip privacy on interned
This commit is contained in:
parent
fe90e68c8f
commit
73a6aed554
4 changed files with 26 additions and 1 deletions
|
@ -23,6 +23,9 @@ macro_rules! setup_interned_struct {
|
|||
// Field names
|
||||
field_ids: [$($field_id:ident),*],
|
||||
|
||||
// Visibilities for field accessor methods
|
||||
field_vis: [$($field_vis:vis f),*],
|
||||
|
||||
// Names for field setter methods (typically `set_foo`)
|
||||
field_getter_ids: [$($field_getter_id:ident),*],
|
||||
|
||||
|
@ -134,7 +137,7 @@ macro_rules! setup_interned_struct {
|
|||
}
|
||||
|
||||
$(
|
||||
pub fn $field_getter_id<$Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty)
|
||||
$field_vis fn $field_getter_id<$Db>(self, db: &'db $Db) -> $zalsa::maybe_cloned_ty!($field_option, 'db, $field_ty)
|
||||
where
|
||||
// FIXME(rust-lang/rust#65991): The `db` argument *should* have the type `dyn Database`
|
||||
$Db: ?Sized + $zalsa::Database,
|
||||
|
|
|
@ -84,6 +84,7 @@ impl Macro {
|
|||
let field_ids = salsa_struct.field_ids();
|
||||
let field_indices = salsa_struct.field_indices();
|
||||
let num_fields = salsa_struct.num_fields();
|
||||
let field_vis = salsa_struct.field_vis();
|
||||
let field_getter_ids = salsa_struct.field_getter_ids();
|
||||
let field_options = salsa_struct.field_options();
|
||||
let field_tys = salsa_struct.field_tys();
|
||||
|
@ -106,6 +107,7 @@ impl Macro {
|
|||
new_fn: #new_fn,
|
||||
field_options: [#(#field_options),*],
|
||||
field_ids: [#(#field_ids),*],
|
||||
field_vis: [#(#field_vis f),*],
|
||||
field_getter_ids: [#(#field_getter_ids),*],
|
||||
field_tys: [#(#field_tys),*],
|
||||
field_indices: [#(#field_indices),*],
|
||||
|
|
12
tests/compile-fail/get-on-private-interned-field.rs
Normal file
12
tests/compile-fail/get-on-private-interned-field.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
mod a {
|
||||
#[salsa::interned]
|
||||
pub struct MyInterned<'db> {
|
||||
field: u32,
|
||||
}
|
||||
}
|
||||
|
||||
fn test<'db>(db: &'db dyn salsa::Database, interned: a::MyInterned<'db>) {
|
||||
interned.field(db);
|
||||
}
|
||||
|
||||
fn main() {}
|
8
tests/compile-fail/get-on-private-interned-field.stderr
Normal file
8
tests/compile-fail/get-on-private-interned-field.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error[E0624]: method `field` is private
|
||||
--> tests/compile-fail/get-on-private-interned-field.rs:9:14
|
||||
|
|
||||
2 | #[salsa::interned]
|
||||
| ------------------ private method defined here
|
||||
...
|
||||
9 | interned.field(db);
|
||||
| ^^^^^ private method
|
Loading…
Reference in a new issue