api: Use VersionHistory::new from ruma_api!

… and remove a now-redundant check from the macro code.
This commit is contained in:
Jonas Platte 2022-10-27 18:38:44 +02:00 committed by Jonas Platte
parent e783d77db7
commit ec67fcbd6f
3 changed files with 10 additions and 20 deletions

View File

@ -16,8 +16,8 @@ ruma_api! {
rate_limited: false,
authentication: None,
added: 1.0,
deprecated: 1.1,
removed: 1.2,
deprecated: 1.2,
removed: 1.3,
}
request: {
@ -71,6 +71,6 @@ fn main() {
);
assert_eq!(METADATA.history.added_version(), Some(MatrixVersion::V1_0));
assert_eq!(METADATA.history.deprecated, Some(MatrixVersion::V1_1));
assert_eq!(METADATA.history.removed, Some(MatrixVersion::V1_2));
assert_eq!(METADATA.history.deprecated, Some(MatrixVersion::V1_2));
assert_eq!(METADATA.history.removed, Some(MatrixVersion::V1_3));
}

View File

@ -109,16 +109,6 @@ impl Api {
})?;
let path_args = path.args();
for extra_path in path_iter {
let extra_path_args = extra_path.args();
if extra_path_args != path_args {
return Err(syn::Error::new(
Span::call_site(),
"paths have different path parameters",
));
}
}
if let Some(req) = &self.request {
let path_field_names: Vec<_> = req
.fields

View File

@ -369,12 +369,12 @@ impl ToTokens for History {
let removed = util::map_option_literal(&removed);
tokens.extend(quote! {
::ruma_common::api::VersionHistory {
unstable_paths: &[ #(#unstable),* ],
stable_paths: &[ #(#versioned),* ],
deprecated: #deprecated,
removed: #removed,
}
::ruma_common::api::VersionHistory::new(
&[ #(#unstable),* ],
&[ #(#versioned),* ],
#deprecated,
#removed,
)
});
}
}