Enforce public visibility of all fields of structs deriving Outgoing
This commit is contained in:
parent
8049631827
commit
b3196d7f64
@ -12,10 +12,10 @@ ruma_api! {
|
||||
|
||||
request: {
|
||||
#[ruma_api(header = LOCATION)]
|
||||
location: Option<String>,
|
||||
pub location: Option<String>,
|
||||
}
|
||||
response: {
|
||||
#[ruma_api(header = LOCATION)]
|
||||
stuff: Option<String>,
|
||||
pub stuff: Option<String>,
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, ruma_common::Outgoing, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
some: &'t str,
|
||||
t: &'t [u8],
|
||||
pub some: &'t str,
|
||||
pub t: &'t [u8],
|
||||
}
|
||||
|
||||
mod empty_response {
|
||||
|
@ -106,6 +106,9 @@ pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||
DataKind::Struct(mut fields, struct_kind) => {
|
||||
let mut found_lifetime = false;
|
||||
for field in &mut fields {
|
||||
if !matches!(field.vis, syn::Visibility::Public(_)) {
|
||||
return Err(syn::Error::new_spanned(field, "All fields must be marked `pub`"));
|
||||
}
|
||||
if strip_lifetimes(&mut field.ty) {
|
||||
found_lifetime = true;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ pub struct IncomingThing<T> {
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
some: &'t str,
|
||||
t: &'t [u8],
|
||||
pub some: &'t str,
|
||||
pub t: &'t [u8],
|
||||
}
|
||||
|
||||
#[derive(Outgoing)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user