Skip to content

Commit a4197c0

Browse files
committed
address some lint warnings
1 parent 6dbc2bd commit a4197c0

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.trim_text(true);
@@ -1089,14 +1089,11 @@ pub fn parse_profile(
10891089
for e in events {
10901090
match e {
10911091
Ok(Event::Start(bytes)) => {
1092-
let id = match identify_element(bytes.name().into_inner()) {
1093-
None => {
1094-
panic!(
1095-
"unexpected element {:?}",
1096-
String::from_utf8_lossy(bytes.name().into_inner())
1097-
);
1098-
}
1099-
Some(kind) => kind,
1092+
let Some(id) = identify_element(bytes.name().into_inner()) else {
1093+
panic!(
1094+
"unexpected element {:?}",
1095+
String::from_utf8_lossy(bytes.name().into_inner())
1096+
);
11001097
};
11011098

11021099
assert!(
@@ -1110,20 +1107,20 @@ pub fn parse_profile(
11101107
is_in_extension = true;
11111108
}
11121109
MavXmlElement::Message => {
1113-
message = Default::default();
1110+
message = MavMessage::default();
11141111
}
11151112
MavXmlElement::Field => {
1116-
field = Default::default();
1113+
field = MavField::default();
11171114
field.is_extension = is_in_extension;
11181115
}
11191116
MavXmlElement::Enum => {
1120-
mavenum = Default::default();
1117+
mavenum = MavEnum::default();
11211118
}
11221119
MavXmlElement::Entry => {
1123-
entry = Default::default();
1120+
entry = MavEnumEntry::default();
11241121
}
11251122
MavXmlElement::Include => {
1126-
include = Default::default();
1123+
include = PathBuf::default();
11271124
}
11281125
MavXmlElement::Param => {
11291126
paramid = None;
@@ -1238,7 +1235,7 @@ pub fn parse_profile(
12381235
if entry.params.is_none() {
12391236
entry.params = Some(vec![]);
12401237
}
1241-
if let b"index" = attr.key.into_inner() {
1238+
if attr.key.into_inner() == b"index" {
12421239
let s = std::str::from_utf8(&attr.value).unwrap();
12431240
paramid = Some(s.parse::<usize>().unwrap());
12441241
}
@@ -1252,7 +1249,7 @@ pub fn parse_profile(
12521249
is_in_extension = true;
12531250
}
12541251
b"entry" => {
1255-
entry = Default::default();
1252+
entry = MavEnumEntry::default();
12561253
for attr in bytes.attributes() {
12571254
let attr = attr.unwrap();
12581255
match attr.key.into_inner() {
@@ -1312,7 +1309,7 @@ pub fn parse_profile(
13121309
eprintln!("TODO: deprecated {s:?}");
13131310
}
13141311
data => {
1315-
panic!("unexpected text data {:?} reading {:?}", data, s);
1312+
panic!("unexpected text data {data:?} reading {s:?}");
13161313
}
13171314
}
13181315
}
@@ -1490,7 +1487,7 @@ impl MavXmlFilter {
14901487
}
14911488
!self.extension_filter.is_in
14921489
}
1493-
Err(error) => panic!("Failed to filter XML: {}", error),
1490+
Err(error) => panic!("Failed to filter XML: {error}"),
14941491
}
14951492
}
14961493
}

0 commit comments

Comments
 (0)