From 45f6197533a4a7e79abe716930f640da47e4ab4d Mon Sep 17 00:00:00 2001 From: Vincent Lafeychine <vincent.lafeychine@proton.me> Date: Sun, 26 May 2024 18:32:25 +0200 Subject: [PATCH] clippy: Fix let_unit_value --- rr_frontend/.cargo/config.toml | 8 +++----- .../translation/src/spec_parsers/const_attr_parser.rs | 3 +-- .../translation/src/spec_parsers/crate_attr_parser.rs | 11 +++++------ rr_frontend/translation/src/spec_parsers/mod.rs | 10 ++-------- .../src/spec_parsers/module_attr_parser.rs | 7 +++---- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml index 8ad5757f..21e7dbb6 100644 --- a/rr_frontend/.cargo/config.toml +++ b/rr_frontend/.cargo/config.toml @@ -101,9 +101,7 @@ rustflags = [ "-Aclippy::min_ident_chars", "-Aclippy::missing_inline_in_public_items", "-Aclippy::missing_trait_methods", - "-Aclippy::pub_with_shorthand", # ("pub_without_shortand" is allowed) "-Aclippy::question_mark_used", - "-Aclippy::semicolon_outside_block", # ("semicolon_outside_block" is allowed) "-Aclippy::shadow_reuse", "-Aclippy::shadow_same", "-Aclippy::shadow_unrelated", @@ -123,10 +121,10 @@ rustflags = [ # `clippy::restriction` is enabled globally, but used carefully. "-Aclippy::blanket_clippy_restriction_lints", - "-Aclippy::mod_module_files", # see: self_named_module_files - # These lints could be false positives, and should be caught by other lints. - "-Aclippy::let_unit_value", + "-Aclippy::mod_module_files", # see: self_named_module_files + "-Aclippy::pub_with_shorthand", # see: pub_without_shortand + "-Aclippy::semicolon_outside_block", # see: semicolon_inline_block ] [unstable.gitoxide] diff --git a/rr_frontend/translation/src/spec_parsers/const_attr_parser.rs b/rr_frontend/translation/src/spec_parsers/const_attr_parser.rs index e164bfcd..048e0839 100644 --- a/rr_frontend/translation/src/spec_parsers/const_attr_parser.rs +++ b/rr_frontend/translation/src/spec_parsers/const_attr_parser.rs @@ -41,7 +41,6 @@ impl ConstAttrParser for VerboseConstAttrParser { _did: LocalDefId, attrs: &'a [&'a AttrItem], ) -> Result<ConstAttrs, String> { - let meta = (); let mut name: Option<String> = None; for &it in attrs { @@ -56,7 +55,7 @@ impl ConstAttrParser for VerboseConstAttrParser { match seg.ident.name.as_str() { "name" => { - let parsed_name: parse::LitStr = buffer.parse(&meta).map_err(str_err)?; + let parsed_name: parse::LitStr = buffer.parse(&()).map_err(str_err)?; if name.is_some() { return Err(format!("name attribute has already been specified")); } diff --git a/rr_frontend/translation/src/spec_parsers/crate_attr_parser.rs b/rr_frontend/translation/src/spec_parsers/crate_attr_parser.rs index fcea172a..d49b15bd 100644 --- a/rr_frontend/translation/src/spec_parsers/crate_attr_parser.rs +++ b/rr_frontend/translation/src/spec_parsers/crate_attr_parser.rs @@ -37,7 +37,6 @@ impl VerboseCrateAttrParser { impl CrateAttrParser for VerboseCrateAttrParser { fn parse_crate_attrs<'a>(&'a mut self, attrs: &'a [&'a AttrItem]) -> Result<CrateAttrs, String> { - let meta = (); let mut exports: Vec<coq::Export> = Vec::new(); let mut includes: Vec<String> = Vec::new(); let mut prefix: Option<String> = None; @@ -55,29 +54,29 @@ impl CrateAttrParser for VerboseCrateAttrParser { let buffer = parse::Buffer::new(&it.args.inner_tokens()); match seg.ident.name.as_str() { "import" => { - let path: parse_utils::CoqModule = buffer.parse(&meta).map_err(str_err)?; + let path: parse_utils::CoqModule = buffer.parse(&()).map_err(str_err)?; exports.push(coq::Export::new(path.into())); }, "include" => { - let name: parse::LitStr = buffer.parse(&meta).map_err(str_err)?; + let name: parse::LitStr = buffer.parse(&()).map_err(str_err)?; includes.push(name.value()); }, "coq_prefix" => { - let path: parse::LitStr = buffer.parse(&meta).map_err(str_err)?; + let path: parse::LitStr = buffer.parse(&()).map_err(str_err)?; if prefix.is_some() { return Err(format!("multiple rr::coq_prefix attributes have been provided")); } prefix = Some(path.value().clone()); }, "package" => { - let path: parse::LitStr = buffer.parse(&meta).map_err(str_err)?; + let path: parse::LitStr = buffer.parse(&()).map_err(str_err)?; if package.is_some() { return Err(format!("multiple rr::package attributes have been provided")); } package = Some(path.value().clone()); }, "context" => { - let param: parse_utils::RRGlobalCoqContextItem = buffer.parse(&meta).map_err(str_err)?; + let param: parse_utils::RRGlobalCoqContextItem = buffer.parse(&()).map_err(str_err)?; context_params.push(coq::Param::new( coq::Name::Unnamed, coq::Type::Literal(param.item), diff --git a/rr_frontend/translation/src/spec_parsers/mod.rs b/rr_frontend/translation/src/spec_parsers/mod.rs index 2a768e73..e908dfbd 100644 --- a/rr_frontend/translation/src/spec_parsers/mod.rs +++ b/rr_frontend/translation/src/spec_parsers/mod.rs @@ -25,9 +25,6 @@ impl<F> parse::Parse<F> for RustPath { } pub fn get_export_as_attr(attrs: &[&AttrItem]) -> Result<Vec<String>, String> { - let meta: () = (); - let meta = &meta; - for &it in attrs { let path_segs = &it.path.segments; @@ -35,7 +32,7 @@ pub fn get_export_as_attr(attrs: &[&AttrItem]) -> Result<Vec<String>, String> { let buffer = parse::Buffer::new(&it.args.inner_tokens()); if seg.ident.name.as_str() == "export_as" { - let path = RustPath::parse(&buffer, meta).map_err(parse_utils::str_err)?; + let path = RustPath::parse(&buffer, &()).map_err(parse_utils::str_err)?; return Ok(path.path); } } @@ -74,9 +71,6 @@ where /// Extract a shim annotation from a list of annotations of a function or method. pub fn get_shim_attrs(attrs: &[&AttrItem]) -> Result<ShimAnnot, String> { - let meta: () = (); - let meta = &meta; - for &it in attrs { let path_segs = &it.path.segments; @@ -84,7 +78,7 @@ pub fn get_shim_attrs(attrs: &[&AttrItem]) -> Result<ShimAnnot, String> { let buffer = parse::Buffer::new(&it.args.inner_tokens()); if seg.ident.name.as_str() == "shim" { - let annot = ShimAnnot::parse(&buffer, meta).map_err(parse_utils::str_err)?; + let annot = ShimAnnot::parse(&buffer, &()).map_err(parse_utils::str_err)?; return Ok(annot); } } diff --git a/rr_frontend/translation/src/spec_parsers/module_attr_parser.rs b/rr_frontend/translation/src/spec_parsers/module_attr_parser.rs index a1bdaddc..366ea5a8 100644 --- a/rr_frontend/translation/src/spec_parsers/module_attr_parser.rs +++ b/rr_frontend/translation/src/spec_parsers/module_attr_parser.rs @@ -44,7 +44,6 @@ impl ModuleAttrParser for VerboseModuleAttrParser { _did: LocalDefId, attrs: &'a [&'a AttrItem], ) -> Result<ModuleAttrs, String> { - let meta = (); let mut exports: Vec<coq::Export> = Vec::new(); let mut includes: Vec<String> = Vec::new(); let mut context_params = Vec::new(); @@ -60,15 +59,15 @@ impl ModuleAttrParser for VerboseModuleAttrParser { let buffer = parse::Buffer::new(&it.args.inner_tokens()); match seg.ident.name.as_str() { "import" => { - let path: parse_utils::CoqModule = buffer.parse(&meta).map_err(str_err)?; + let path: parse_utils::CoqModule = buffer.parse(&()).map_err(str_err)?; exports.push(coq::Export::new(path.into())); }, "include" => { - let name: parse::LitStr = buffer.parse(&meta).map_err(str_err)?; + let name: parse::LitStr = buffer.parse(&()).map_err(str_err)?; includes.push(name.value()); }, "context" => { - let param: parse_utils::RRGlobalCoqContextItem = buffer.parse(&meta).map_err(str_err)?; + let param: parse_utils::RRGlobalCoqContextItem = buffer.parse(&()).map_err(str_err)?; context_params.push(coq::Param::new( coq::Name::Unnamed, coq::Type::Literal(param.item), -- GitLab