test: improve cov

This commit is contained in:
BlueGlassBlock 2023-04-27 12:44:38 +08:00
parent 28cc9e3f6c
commit f75ea3d93a
No known key found for this signature in database
GPG Key ID: E69DA4EC7A98B286
3 changed files with 32 additions and 18 deletions

View File

@ -181,7 +181,9 @@ impl<'a> Container<'a> {
attrs.getter = Some(FieldGetter::GetItem(Some(item_name)));
}
FieldGetter::GetItem(None) => bail_spanned!(from_item_all.span() => "Useless `item` - the struct is already annotated with `from_item_all`"),
FieldGetter::GetAttr(_) => bail_spanned!(from_item_all.span() => "The struct is already annotated with `from_item_all`, `attr` is not allowed"),
FieldGetter::GetAttr(_) => bail_spanned!(
from_item_all.span() => "The struct is already annotated with `from_item_all`, `attribute` is not allowed"
),
}
}
}

View File

@ -177,12 +177,18 @@ struct InvalidTransparentWithGetter {
#[derive(FromPyObject)]
#[pyo3(from_item_all)]
struct ItemAllOnTuple(String);
struct FromItemAllOnTuple(String);
#[derive(FromPyObject)]
#[pyo3(from_item_all)]
#[pyo3(transparent)]
struct ItemAllWithTransparent {
struct FromItemAllWithTransparent {
field: String,
}
#[derive(FromPyObject)]
#[pyo3(from_item_all, from_item_all)]
struct MultipleFromItemAll {
field: String,
}
@ -195,15 +201,15 @@ struct UselessItemAttr {
#[derive(FromPyObject)]
#[pyo3(from_item_all)]
struct ItemAllConflictAttr {
#[pyo3(attr)]
struct FromItemAllConflictAttr {
#[pyo3(attribute)]
field: String,
}
#[derive(FromPyObject)]
#[pyo3(from_item_all)]
struct ItemAllConflictAttrWithArgs {
#[pyo3(attr("f"))]
struct FromItemAllConflictAttrWithArgs {
#[pyo3(attribute("f"))]
field: String,
}

View File

@ -200,20 +200,26 @@ error: `transparent` structs may not have a `getter` for the inner field
186 | field: String,
| ^^^^^
error: Useless `item` - the struct is already annotated with `from_item_all`
--> tests/ui/invalid_frompy_derive.rs:190:8
error: `from_item_all` may only be provided once
--> tests/ui/invalid_frompy_derive.rs:190:23
|
190 | #[pyo3(from_item_all)]
190 | #[pyo3(from_item_all, from_item_all)]
| ^^^^^^^^^^^^^
error: Useless `item` - the struct is already annotated with `from_item_all`
--> tests/ui/invalid_frompy_derive.rs:196:8
|
196 | #[pyo3(from_item_all)]
| ^^^^^^^^^^^^^
error: expected one of: `attribute`, `item`, `from_py_with`
--> tests/ui/invalid_frompy_derive.rs:199:12
error: The struct is already annotated with `from_item_all`, `attribute` is not allowed
--> tests/ui/invalid_frompy_derive.rs:203:8
|
199 | #[pyo3(attr)]
| ^^^^
203 | #[pyo3(from_item_all)]
| ^^^^^^^^^^^^^
error: expected one of: `attribute`, `item`, `from_py_with`
--> tests/ui/invalid_frompy_derive.rs:206:12
error: The struct is already annotated with `from_item_all`, `attribute` is not allowed
--> tests/ui/invalid_frompy_derive.rs:210:8
|
206 | #[pyo3(attr("f"))]
| ^^^^
210 | #[pyo3(from_item_all)]
| ^^^^^^^^^^^^^