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

Fix enum entry value generation when no implicit value is set #247

Merged
merged 1 commit into from
Aug 4, 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
4 changes: 2 additions & 2 deletions mavlink-bindgen/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
}

fn emit_defs(&self) -> Vec<TokenStream> {
let mut cnt = 0isize;
let mut cnt = 0u32;
self.entries
.iter()
.map(|enum_entry| {
Expand All @@ -330,7 +330,7 @@
value = quote!(#cnt);
} else {
let tmp_value = enum_entry.value.unwrap();
cnt = cnt.max(tmp_value as isize);
cnt = cnt.max(tmp_value as u32);

Check warning on line 333 in mavlink-bindgen/src/parser.rs

View workflow job for this annotation

GitHub Actions / linting

casting to the same type is unnecessary (`u32` -> `u32`)

warning: casting to the same type is unnecessary (`u32` -> `u32`) --> mavlink-bindgen/src/parser.rs:333:35 | 333 | cnt = cnt.max(tmp_value as u32); | ^^^^^^^^^^^^^^^^ help: try: `tmp_value` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
let tmp = TokenStream::from_str(&tmp_value.to_string()).unwrap();
value = quote!(#tmp);
};
Expand Down
Loading