Skip to content

Commit

Permalink
Fix new clippy lints (#139)
Browse files Browse the repository at this point in the history
* Fix new clippy lints

* fmt
  • Loading branch information
andrewhickman authored Jan 13, 2025
1 parent 5d2cccf commit 5a199d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion prost-reflect/src/descriptor/build/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Visitor for NameVisitor<'_> {
});
}

let allow_alias = enum_.options.as_ref().map_or(false, |o| {
let allow_alias = enum_.options.as_ref().is_some_and(|o| {
o.value.allow_alias()
|| o.value.uninterpreted_option.iter().any(|u| {
u.name.len() == 1
Expand Down
11 changes: 4 additions & 7 deletions prost-reflect/src/descriptor/build/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Visitor for ResolveVisitor<'_> {
let json_name: Box<str> = self.resolve_field_json_name(field, file, path).into();

let is_packed = cardinality == Cardinality::Repeated
&& kind.map_or(false, |k| k.is_packable())
&& kind.is_some_and(|k| k.is_packable())
&& (field
.options
.as_ref()
Expand All @@ -128,7 +128,7 @@ impl Visitor for ResolveVisitor<'_> {
let supports_presence = field.proto3_optional()
|| field.oneof_index.is_some()
|| (cardinality != Cardinality::Repeated
&& (kind.map_or(false, |k| k.is_message()) || syntax == Syntax::Proto2));
&& (kind.is_some_and(|k| k.is_message()) || syntax == Syntax::Proto2));

let default = kind.and_then(|kind| {
self.parse_field_default_value(kind, field.default_value.as_deref(), file, path)
Expand Down Expand Up @@ -390,7 +390,7 @@ impl Visitor for ResolveVisitor<'_> {
self.resolve_field_json_name(extension, file, path);

let is_packed = cardinality == Cardinality::Repeated
&& kind.map_or(false, |k| k.is_packable())
&& kind.is_some_and(|k| k.is_packable())
&& (extension
.options
.as_ref()
Expand Down Expand Up @@ -631,10 +631,7 @@ impl ResolveVisitor<'_> {
file: FileIndex,
path: &[i32],
) -> Option<Value> {
let default_value = match default_value {
Some(value) => value,
None => return None,
};
let default_value = default_value?;

match kind {
KindIndex::Double
Expand Down
4 changes: 2 additions & 2 deletions prost-reflect/src/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl DynamicMessage {
pub fn has_field_by_number(&self, number: u32) -> bool {
self.desc
.get_field(number)
.map_or(false, |field_desc| self.has_field(&field_desc))
.is_some_and(|field_desc| self.has_field(&field_desc))
}

/// Gets the value of the field with the given number, or the default value if it is unset.
Expand Down Expand Up @@ -346,7 +346,7 @@ impl DynamicMessage {
pub fn has_field_by_name(&self, name: &str) -> bool {
self.desc
.get_field_by_name(name)
.map_or(false, |field_desc| self.has_field(&field_desc))
.is_some_and(|field_desc| self.has_field(&field_desc))
}

/// Gets the value of the field with the given name, or the default value if it is unset.
Expand Down
6 changes: 4 additions & 2 deletions prost-reflect/src/reflect/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4567,7 +4567,9 @@ impl_reflect_message! {
fn compare_parsed_and_coded_default_descriptors() {
use prost::Message;

let desc = crate::descriptor::types::FileDescriptorSet::decode(expected_well_known_types().as_slice()).unwrap();
let desc =
crate::descriptor::types::FileDescriptorSet::decode(expected_well_known_types().as_slice())
.unwrap();
let built_in_desc = make_descriptor();

if desc != built_in_desc {
Expand Down Expand Up @@ -4599,7 +4601,7 @@ fn compare_parsed_and_coded_default_descriptors() {

#[cfg(test)]
fn expected_well_known_types() -> Vec<u8> {
use protox::{Compiler, file::GoogleFileResolver};
use protox::{file::GoogleFileResolver, Compiler};

// protox can output a FileDescriptorSet directly, but by going through bytes, this should still work
// when upgrading to a newer prost-types version.
Expand Down

0 comments on commit 5a199d5

Please sign in to comment.