Skip to content

Commit ab94f0f

Browse files
committed
address some lint warnings
1 parent 2edce73 commit ab94f0f

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

mavlink-bindgen/src/parser.rs

+17-20
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl MavEnum {
365365

366366
#[cfg(feature = "emit-description")]
367367
let description = if let Some(description) = self.description.as_ref() {
368-
let desc = format!("{description}");
368+
let desc = description.to_string();
369369
quote!(#[doc = #desc])
370370
} else {
371371
quote!()
@@ -1001,7 +1001,7 @@ pub enum MavXmlElement {
10011001
Extensions,
10021002
}
10031003

1004-
fn identify_element(s: &[u8]) -> Option<MavXmlElement> {
1004+
const fn identify_element(s: &[u8]) -> Option<MavXmlElement> {
10051005
use self::MavXmlElement::*;
10061006
match s {
10071007
b"version" => Some(Version),
@@ -1066,7 +1066,7 @@ pub fn parse_profile(
10661066
let mut events: Vec<Result<Event, quick_xml::Error>> = Vec::new();
10671067
let file = File::open(&in_path).map_err(|e| BindGenError::CouldNotReadDefinitionFile {
10681068
source: e,
1069-
path: in_path.to_path_buf(),
1069+
path: in_path.clone(),
10701070
})?;
10711071
let mut reader = Reader::from_reader(BufReader::new(file));
10721072
reader.config_mut().trim_text(true);
@@ -1088,14 +1088,11 @@ pub fn parse_profile(
10881088
for e in events {
10891089
match e {
10901090
Ok(Event::Start(bytes)) => {
1091-
let id = match identify_element(bytes.name().into_inner()) {
1092-
None => {
1093-
panic!(
1094-
"unexpected element {:?}",
1095-
String::from_utf8_lossy(bytes.name().into_inner())
1096-
);
1097-
}
1098-
Some(kind) => kind,
1091+
let Some(id) = identify_element(bytes.name().into_inner()) else {
1092+
panic!(
1093+
"unexpected element {:?}",
1094+
String::from_utf8_lossy(bytes.name().into_inner())
1095+
);
10991096
};
11001097

11011098
assert!(
@@ -1109,20 +1106,20 @@ pub fn parse_profile(
11091106
is_in_extension = true;
11101107
}
11111108
MavXmlElement::Message => {
1112-
message = Default::default();
1109+
message = MavMessage::default();
11131110
}
11141111
MavXmlElement::Field => {
1115-
field = Default::default();
1112+
field = MavField::default();
11161113
field.is_extension = is_in_extension;
11171114
}
11181115
MavXmlElement::Enum => {
1119-
mavenum = Default::default();
1116+
mavenum = MavEnum::default();
11201117
}
11211118
MavXmlElement::Entry => {
1122-
entry = Default::default();
1119+
entry = MavEnumEntry::default();
11231120
}
11241121
MavXmlElement::Include => {
1125-
include = Default::default();
1122+
include = PathBuf::default();
11261123
}
11271124
MavXmlElement::Param => {
11281125
paramid = None;
@@ -1237,7 +1234,7 @@ pub fn parse_profile(
12371234
if entry.params.is_none() {
12381235
entry.params = Some(vec![]);
12391236
}
1240-
if let b"index" = attr.key.into_inner() {
1237+
if attr.key.into_inner() == b"index" {
12411238
let s = std::str::from_utf8(&attr.value).unwrap();
12421239
paramid = Some(s.parse::<usize>().unwrap());
12431240
}
@@ -1251,7 +1248,7 @@ pub fn parse_profile(
12511248
is_in_extension = true;
12521249
}
12531250
b"entry" => {
1254-
entry = Default::default();
1251+
entry = MavEnumEntry::default();
12551252
for attr in bytes.attributes() {
12561253
let attr = attr.unwrap();
12571254
match attr.key.into_inner() {
@@ -1311,7 +1308,7 @@ pub fn parse_profile(
13111308
eprintln!("TODO: deprecated {s:?}");
13121309
}
13131310
data => {
1314-
panic!("unexpected text data {:?} reading {:?}", data, s);
1311+
panic!("unexpected text data {data:?} reading {s:?}");
13151312
}
13161313
}
13171314
}
@@ -1489,7 +1486,7 @@ impl MavXmlFilter {
14891486
}
14901487
!self.extension_filter.is_in
14911488
}
1492-
Err(error) => panic!("Failed to filter XML: {}", error),
1489+
Err(error) => panic!("Failed to filter XML: {error}"),
14931490
}
14941491
}
14951492
}

0 commit comments

Comments
 (0)