Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new clippy lints #139

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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))

Check warning on line 265 in prost-reflect/src/dynamic/mod.rs

View check run for this annotation

Codecov / codecov/patch

prost-reflect/src/dynamic/mod.rs#L265

Added line #L265 was not covered by tests
}

/// 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 @@
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
Loading