Ban pyo3(get, set) on tuple struct field
This commit is contained in:
parent
773a371ba5
commit
2cec240b0e
|
@ -506,7 +506,7 @@ fn impl_descriptors(
|
|||
.flat_map(|(field, fns)| {
|
||||
fns.iter()
|
||||
.map(|desc| {
|
||||
let name = field.ident.as_ref().unwrap().unraw();
|
||||
if let Some(name) = field.ident.as_ref().map(|ident| ident.unraw()) {
|
||||
let doc = utils::get_doc(&field.attrs, None, true)
|
||||
.unwrap_or_else(|_| syn::LitStr::new(&name.to_string(), name.span()));
|
||||
let property_type = PropertyType::Descriptor(&field);
|
||||
|
@ -519,6 +519,9 @@ fn impl_descriptors(
|
|||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
bail_spanned!(field.span() => "get/set are not supported on tuple struct field");
|
||||
}
|
||||
})
|
||||
.collect::<Vec<syn::Result<TokenStream>>>()
|
||||
})
|
||||
|
|
|
@ -24,4 +24,7 @@ impl ClassWithSetter {
|
|||
fn setter_with_too_many_args(&mut self, py: Python, foo: u32, bar: u32) {}
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
struct TupleGetterSetter(#[pyo3(get, set)] i32);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -15,3 +15,9 @@ error: setter function can have at most two arguments ([pyo3::Python,] and value
|
|||
|
|
||||
24 | fn setter_with_too_many_args(&mut self, py: Python, foo: u32, bar: u32) {}
|
||||
| ^^^
|
||||
|
||||
error: get/set are not supported on tuple struct field
|
||||
--> $DIR/invalid_property_args.rs:28:44
|
||||
|
|
||||
28 | struct TupleGetterSetter(#[pyo3(get, set)] i32);
|
||||
| ^^^
|
||||
|
|
Loading…
Reference in New Issue