Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check deserialized query id matches expected id #783

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub struct SemverQuery {
impl SemverQuery {
pub fn all_queries() -> BTreeMap<String, SemverQuery> {
let mut queries = BTreeMap::default();
for query_text in get_query_text_contents() {
for (id, query_text) in get_queries() {
let query: SemverQuery = ron::from_str(query_text).unwrap_or_else(|e| {
panic!(
"\
Expand All @@ -108,6 +108,7 @@ Failed to parse a query: {e}
```"
);
});
assert_eq!(id, query.id, "Query id must match file name");
let id_conflict = queries.insert(query.id.clone(), query);
assert!(id_conflict.is_none(), "{id_conflict:?}");
}
Expand Down Expand Up @@ -462,10 +463,13 @@ macro_rules! add_lints {
)*
}

fn get_query_text_contents() -> Vec<&'static str> {
fn get_queries() -> Vec<(&'static str, &'static str)> {
vec![
$(
include_str!(concat!("lints/", stringify!($name), ".ron")),
(
stringify!($name),
include_str!(concat!("lints/", stringify!($name), ".ron")),
),
)*
]
}
Expand All @@ -475,6 +479,8 @@ macro_rules! add_lints {
}
}

// The following add_lints! invocation is programmatically edited by scripts/make_new_lint.sh
// If you must manually edit it, be sure to read the "Requirements" comments in that script first
add_lints!(
auto_trait_impl_removed,
constructible_struct_adds_field,
Expand Down
Loading