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: {
|
request: {
|
||||||
#[ruma_api(header = LOCATION)]
|
#[ruma_api(header = LOCATION)]
|
||||||
location: Option<String>,
|
pub location: Option<String>,
|
||||||
}
|
}
|
||||||
response: {
|
response: {
|
||||||
#[ruma_api(header = LOCATION)]
|
#[ruma_api(header = LOCATION)]
|
||||||
stuff: Option<String>,
|
pub stuff: Option<String>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[derive(Copy, Clone, Debug, ruma_common::Outgoing, serde::Serialize)]
|
#[derive(Copy, Clone, Debug, ruma_common::Outgoing, serde::Serialize)]
|
||||||
pub struct OtherThing<'t> {
|
pub struct OtherThing<'t> {
|
||||||
some: &'t str,
|
pub some: &'t str,
|
||||||
t: &'t [u8],
|
pub t: &'t [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
mod empty_response {
|
mod empty_response {
|
||||||
|
@ -106,6 +106,9 @@ pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result<TokenStream> {
|
|||||||
DataKind::Struct(mut fields, struct_kind) => {
|
DataKind::Struct(mut fields, struct_kind) => {
|
||||||
let mut found_lifetime = false;
|
let mut found_lifetime = false;
|
||||||
for field in &mut fields {
|
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) {
|
if strip_lifetimes(&mut field.ty) {
|
||||||
found_lifetime = true;
|
found_lifetime = true;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ pub struct IncomingThing<T> {
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)]
|
#[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)]
|
||||||
pub struct OtherThing<'t> {
|
pub struct OtherThing<'t> {
|
||||||
some: &'t str,
|
pub some: &'t str,
|
||||||
t: &'t [u8],
|
pub t: &'t [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Outgoing)]
|
#[derive(Outgoing)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user