Fix several clippy warnings
This commit is contained in:
parent
17584344c2
commit
bd998ab880
21
r2r/build.rs
21
r2r/build.rs
|
|
@ -102,7 +102,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let msgs_file = bindgen_dir.join(MSGS_FILENAME);
|
let msgs_file = bindgen_dir.join(MSGS_FILENAME);
|
||||||
write_to_file(&msgs_file, &pretty_tokenstream(modules)).unwrap();
|
write_to_file(&msgs_file, pretty_tokenstream(modules)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mod_files: Vec<_> = msgs
|
let mod_files: Vec<_> = msgs
|
||||||
|
|
@ -113,7 +113,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
.map(|(prefix, msgs)| {
|
.map(|(prefix, msgs)| {
|
||||||
let prefix_content = match *prefix {
|
let prefix_content = match *prefix {
|
||||||
"msg" => {
|
"msg" => {
|
||||||
let msg_snipplets = msgs.into_iter().map(|msg| {
|
let msg_snipplets = msgs.iter().map(|msg| {
|
||||||
println!("cargo:rustc-cfg=r2r__{}__{}__{}", module, prefix, msg);
|
println!("cargo:rustc-cfg=r2r__{}__{}__{}", module, prefix, msg);
|
||||||
r2r_msg_gen::generate_rust_msg(module, prefix, msg)
|
r2r_msg_gen::generate_rust_msg(module, prefix, msg)
|
||||||
});
|
});
|
||||||
|
|
@ -124,7 +124,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"srv" => {
|
"srv" => {
|
||||||
let msg_snipplets = msgs.into_iter().map(|msg| {
|
let msg_snipplets = msgs.iter().map(|msg| {
|
||||||
let service_snipplet =
|
let service_snipplet =
|
||||||
r2r_msg_gen::generate_rust_service(module, prefix, msg);
|
r2r_msg_gen::generate_rust_service(module, prefix, msg);
|
||||||
let msg_snipplets = ["Request", "Response"].iter().map(|s| {
|
let msg_snipplets = ["Request", "Response"].iter().map(|s| {
|
||||||
|
|
@ -152,7 +152,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"action" => {
|
"action" => {
|
||||||
let msg_snipplets = msgs.into_iter().map(|msg| {
|
let msg_snipplets = msgs.iter().map(|msg| {
|
||||||
let action_snipplet =
|
let action_snipplet =
|
||||||
r2r_msg_gen::generate_rust_action(module, prefix, msg);
|
r2r_msg_gen::generate_rust_action(module, prefix, msg);
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
let mod_content = quote! { #(#snipplets)* };
|
let mod_content = quote! { #(#snipplets)* };
|
||||||
let file_name = format!("{}.rs", module);
|
let file_name = format!("{}.rs", module);
|
||||||
let mod_file = bindgen_dir.join(&file_name);
|
let mod_file = bindgen_dir.join(&file_name);
|
||||||
write_to_file(&mod_file, &pretty_tokenstream(mod_content)).unwrap();
|
write_to_file(&mod_file, pretty_tokenstream(mod_content)).unwrap();
|
||||||
|
|
||||||
file_name
|
file_name
|
||||||
})
|
})
|
||||||
|
|
@ -251,19 +251,19 @@ fn generate_bindings(bindgen_dir: &Path) {
|
||||||
{
|
{
|
||||||
let untyped_helper = r2r_msg_gen::generate_untyped_helper(&msg_list);
|
let untyped_helper = r2r_msg_gen::generate_untyped_helper(&msg_list);
|
||||||
let untyped_file = bindgen_dir.join(UNTYPED_FILENAME);
|
let untyped_file = bindgen_dir.join(UNTYPED_FILENAME);
|
||||||
write_to_file(&untyped_file, &pretty_tokenstream(untyped_helper)).unwrap();
|
write_to_file(&untyped_file, pretty_tokenstream(untyped_helper)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let untyped_service_helper = r2r_msg_gen::generate_untyped_service_helper(&msg_list);
|
let untyped_service_helper = r2r_msg_gen::generate_untyped_service_helper(&msg_list);
|
||||||
let untyped_service_file = bindgen_dir.join(UNTYPED_SERVICE_FILENAME);
|
let untyped_service_file = bindgen_dir.join(UNTYPED_SERVICE_FILENAME);
|
||||||
write_to_file(&untyped_service_file, &pretty_tokenstream(untyped_service_helper)).unwrap();
|
write_to_file(&untyped_service_file, pretty_tokenstream(untyped_service_helper)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let untyped_action_helper = r2r_msg_gen::generate_untyped_action_helper(&msg_list);
|
let untyped_action_helper = r2r_msg_gen::generate_untyped_action_helper(&msg_list);
|
||||||
let untyped_action_file = bindgen_dir.join(UNTYPED_ACTION_FILENAME);
|
let untyped_action_file = bindgen_dir.join(UNTYPED_ACTION_FILENAME);
|
||||||
write_to_file(&untyped_action_file, &pretty_tokenstream(untyped_action_helper)).unwrap();
|
write_to_file(&untyped_action_file, pretty_tokenstream(untyped_action_helper)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save file list
|
// Save file list
|
||||||
|
|
@ -292,16 +292,17 @@ fn copy_files(src_dir: &Path, tgt_dir: &Path) {
|
||||||
.for_each(|file_name| {
|
.for_each(|file_name| {
|
||||||
let src_file = src_dir.join(file_name);
|
let src_file = src_dir.join(file_name);
|
||||||
let tgt_file = tgt_dir.join(file_name);
|
let tgt_file = tgt_dir.join(file_name);
|
||||||
fs::copy(&src_file, &tgt_file).unwrap();
|
fs::copy(src_file, tgt_file).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
fs::copy(&src_list_file, &tgt_list_file).unwrap();
|
fs::copy(&src_list_file, tgt_list_file).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "doc-only"))]
|
#[cfg(not(feature = "doc-only"))]
|
||||||
fn touch(path: &Path) {
|
fn touch(path: &Path) {
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
||||||
|
|
|
||||||
|
|
@ -555,7 +555,7 @@ where
|
||||||
// todo: add logic that replies to the requests
|
// todo: add logic that replies to the requests
|
||||||
self.result_requests
|
self.result_requests
|
||||||
.entry(uuid)
|
.entry(uuid)
|
||||||
.or_insert_with(Vec::new)
|
.or_default()
|
||||||
.push(request_id);
|
.push(request_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ pub trait WrappedTypesupport:
|
||||||
|
|
||||||
self.copy_to_native(unsafe { msg.as_mut().expect("not null") });
|
self.copy_to_native(unsafe { msg.as_mut().expect("not null") });
|
||||||
|
|
||||||
let msg_buf: &mut rcl_serialized_message_t = &mut *msg_buf
|
let msg_buf: &mut rcl_serialized_message_t = &mut msg_buf
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_err(|err| Error::from_rcl_error(*err))?
|
.map_err(|err| Error::from_rcl_error(*err))?
|
||||||
.borrow_mut();
|
.borrow_mut();
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ impl Node {
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
let params = self.params.clone();
|
let params = self.params.clone();
|
||||||
let params_struct_clone = params_struct.as_ref().map(|p| p.clone());
|
let params_struct_clone = params_struct.clone();
|
||||||
let set_params_future = set_params_request_stream.for_each(
|
let set_params_future = set_params_request_stream.for_each(
|
||||||
move |req: ServiceRequest<rcl_interfaces::srv::SetParameters::Service>| {
|
move |req: ServiceRequest<rcl_interfaces::srv::SetParameters::Service>| {
|
||||||
let mut result = rcl_interfaces::srv::SetParameters::Response::default();
|
let mut result = rcl_interfaces::srv::SetParameters::Response::default();
|
||||||
|
|
@ -339,7 +339,7 @@ impl Node {
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
let params = self.params.clone();
|
let params = self.params.clone();
|
||||||
let params_struct_clone = params_struct.as_ref().map(|p| p.clone());
|
let params_struct_clone = params_struct.clone();
|
||||||
let get_params_future = get_params_request_stream.for_each(
|
let get_params_future = get_params_request_stream.for_each(
|
||||||
move |req: ServiceRequest<rcl_interfaces::srv::GetParameters::Service>| {
|
move |req: ServiceRequest<rcl_interfaces::srv::GetParameters::Service>| {
|
||||||
let params = params.lock().unwrap();
|
let params = params.lock().unwrap();
|
||||||
|
|
@ -350,7 +350,7 @@ impl Node {
|
||||||
.map(|n| {
|
.map(|n| {
|
||||||
// First try to get the parameter from the param structure
|
// First try to get the parameter from the param structure
|
||||||
if let Some(ps) = ¶ms_struct_clone {
|
if let Some(ps) = ¶ms_struct_clone {
|
||||||
if let Ok(value) = ps.lock().unwrap().get_parameter(&n) {
|
if let Ok(value) = ps.lock().unwrap().get_parameter(n) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -481,14 +481,14 @@ impl Node {
|
||||||
return (depth == ListParameters::Request::DEPTH_RECURSIVE as u64)
|
return (depth == ListParameters::Request::DEPTH_RECURSIVE as u64)
|
||||||
|| substr.matches(separator).count() < depth as usize;
|
|| substr.matches(separator).count() < depth as usize;
|
||||||
}
|
}
|
||||||
return false;
|
false
|
||||||
});
|
});
|
||||||
get_all || prefix_matches
|
get_all || prefix_matches
|
||||||
}) {
|
}) {
|
||||||
result.names.push(name.clone());
|
result.names.push(name.clone());
|
||||||
if let Some(last_separator) = name.rfind(separator) {
|
if let Some(last_separator) = name.rfind(separator) {
|
||||||
let prefix = &name[0..last_separator];
|
let prefix = &name[0..last_separator];
|
||||||
if result.prefixes.iter().find(|&p| p == prefix) == None {
|
if result.prefixes.iter().all(|p| p != prefix) {
|
||||||
result.prefixes.push(prefix.to_string());
|
result.prefixes.push(prefix.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ fn generate_bindings(out_file: &Path) {
|
||||||
fn touch(path: &Path) {
|
fn touch(path: &Path) {
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ fn generate_includes(bindgen_dir: &Path, msg_list: &[RosMsg]) {
|
||||||
} = msg;
|
} = msg;
|
||||||
|
|
||||||
// filename is certainly CamelCase -> snake_case. convert
|
// filename is certainly CamelCase -> snake_case. convert
|
||||||
let include_filename = camel_to_snake(&name);
|
let include_filename = camel_to_snake(name);
|
||||||
|
|
||||||
[
|
[
|
||||||
format!("#include <{module}/{prefix}/{include_filename}.h>"),
|
format!("#include <{module}/{prefix}/{include_filename}.h>"),
|
||||||
|
|
@ -131,7 +131,7 @@ fn generate_includes(bindgen_dir: &Path, msg_list: &[RosMsg]) {
|
||||||
include_lines.par_sort();
|
include_lines.par_sort();
|
||||||
|
|
||||||
// Write the file content
|
// Write the file content
|
||||||
let mut writer = BufWriter::new(File::create(&msg_includes_file).unwrap());
|
let mut writer = BufWriter::new(File::create(msg_includes_file).unwrap());
|
||||||
for line in include_lines {
|
for line in include_lines {
|
||||||
writeln!(writer, "{line}").unwrap();
|
writeln!(writer, "{line}").unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +163,6 @@ fn generate_introspecion_map(bindgen_dir: &Path, msg_list: &[RosMsg]) {
|
||||||
);
|
);
|
||||||
(key, ident)
|
(key, ident)
|
||||||
})
|
})
|
||||||
.map(|(key, ident)| (key, ident))
|
|
||||||
.collect(),
|
.collect(),
|
||||||
"action" => {
|
"action" => {
|
||||||
let iter1 = ACTION_SUFFICES.iter().map(|s| {
|
let iter1 = ACTION_SUFFICES.iter().map(|s| {
|
||||||
|
|
@ -551,6 +550,7 @@ fn run_dynlink(msg_list: &[RosMsg]) {
|
||||||
fn touch(path: &Path) {
|
fn touch(path: &Path) {
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ fn gen_bindings(out_file: &Path) {
|
||||||
fn touch(path: &Path) {
|
fn touch(path: &Path) {
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
.unwrap_or_else(|_| panic!("Unable to create file '{}'", path.display()));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue