Skip to content

Commit ee891c7

Browse files
committed
chore: cargo clippy
1 parent f07b0a9 commit ee891c7

File tree

19 files changed

+319
-319
lines changed

19 files changed

+319
-319
lines changed

Cargo.lock

Lines changed: 152 additions & 263 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pilota-build/src/codegen/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,7 @@ where
442442

443443
let methods = methods
444444
.iter()
445-
.map(|m| {
446-
let method = self.backend.codegen_service_method(def_id, m);
447-
format!("{method}")
448-
})
445+
.map(|m| self.backend.codegen_service_method(def_id, m))
449446
.join("\n");
450447

451448
let deprecated_attr = if self.is_deprecated(def_id) {

pilota-build/src/codegen/pb/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,15 @@ impl CodegenBackend for ProtobufBackend {
546546

547547
if self.cx.config.with_descriptor {
548548
let file_id = self.cx.node(def_id).unwrap().file_id;
549-
match &self.cx.file_paths().get(&file_id) {
550-
Some(_) => {
551-
let filename = self.file_name(file_id).unwrap().replace(".", "_");
552-
let filename_lower = filename.to_lowercase();
549+
if self.cx.file_paths().get(&file_id).is_some() {
550+
let filename = self.file_name(file_id).unwrap().replace(".", "_");
551+
let filename_lower = filename.to_lowercase();
553552

554-
let file = &self.cx.files().get(&file_id).unwrap().package;
555-
let path = self.cx.item_path(def_id);
556-
let super_mods = "super::".repeat(path.len() - file.len() - 1);
553+
let file = &self.cx.files().get(&file_id).unwrap().package;
554+
let path = self.cx.item_path(def_id);
555+
let super_mods = "super::".repeat(path.len() - file.len() - 1);
557556

558-
stream.push_str(&format!(
557+
stream.push_str(&format!(
559558
r#"
560559
impl {name} {{
561560
fn get_descriptor_proto() -> Option<&'static ::pilota::pb::descriptor::DescriptorProto> {{
@@ -565,8 +564,6 @@ impl CodegenBackend for ProtobufBackend {
565564
}}
566565
"#
567566
));
568-
}
569-
_ => {}
570567
}
571568
}
572569

pilota-build/src/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ops::DerefMut, ptr::NonNull, sync::Arc};
1+
use std::{ptr::NonNull, sync::Arc};
22

33
use ahash::AHashMap;
44
use itertools::Itertools;

pilota-build/test_data/custom_options.rs

Lines changed: 116 additions & 4 deletions
Large diffs are not rendered by default.

pilota-build/test_data/protobuf_with_descriptor/message.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub mod message {
4848

4949
impl ::pilota::pb::Message for Person {
5050
#[inline]
51-
fn encoded_len(&self) -> usize {
52-
0 + ::pilota::pb::encoding::faststr::encoded_len(1, &self.name)
53-
+ ::pilota::pb::encoding::int32::encoded_len(2, &self.age)
51+
fn encoded_len(&self, ctx: &mut ::pilota::pb::EncodeLengthContext) -> usize {
52+
0 + ::pilota::pb::encoding::faststr::encoded_len(ctx, 1, &self.name)
53+
+ ::pilota::pb::encoding::int32::encoded_len(ctx, 2, &self.age)
5454
}
5555

5656
#[allow(unused_variables)]
@@ -66,6 +66,7 @@ pub mod message {
6666
wire_type: ::pilota::pb::encoding::WireType,
6767
buf: &mut ::pilota::Bytes,
6868
ctx: &mut ::pilota::pb::encoding::DecodeContext,
69+
is_root: bool,
6970
) -> ::core::result::Result<(), ::pilota::pb::DecodeError> {
7071
const STRUCT_NAME: &'static str = stringify!(Person);
7172

@@ -116,9 +117,9 @@ pub mod message {
116117

117118
impl ::pilota::pb::Message for Company {
118119
#[inline]
119-
fn encoded_len(&self) -> usize {
120-
0 + ::pilota::pb::encoding::faststr::encoded_len(1, &self.name)
121-
+ ::pilota::pb::encoding::message::encoded_len_repeated(2, &self.employees)
120+
fn encoded_len(&self, ctx: &mut ::pilota::pb::EncodeLengthContext) -> usize {
121+
0 + ::pilota::pb::encoding::faststr::encoded_len(ctx, 1, &self.name)
122+
+ ::pilota::pb::encoding::message::encoded_len_repeated(ctx, 2, &self.employees)
122123
}
123124

124125
#[allow(unused_variables)]
@@ -136,6 +137,7 @@ pub mod message {
136137
wire_type: ::pilota::pb::encoding::WireType,
137138
buf: &mut ::pilota::Bytes,
138139
ctx: &mut ::pilota::pb::encoding::DecodeContext,
140+
is_root: bool,
139141
) -> ::core::result::Result<(), ::pilota::pb::DecodeError> {
140142
const STRUCT_NAME: &'static str = stringify!(Company);
141143

@@ -182,7 +184,7 @@ pub mod message {
182184

183185
impl ::pilota::pb::Message for Self_ {
184186
#[inline]
185-
fn encoded_len(&self) -> usize {
187+
fn encoded_len(&self, ctx: &mut ::pilota::pb::EncodeLengthContext) -> usize {
186188
0
187189
}
188190

@@ -196,6 +198,7 @@ pub mod message {
196198
wire_type: ::pilota::pb::encoding::WireType,
197199
buf: &mut ::pilota::Bytes,
198200
ctx: &mut ::pilota::pb::encoding::DecodeContext,
201+
is_root: bool,
199202
) -> ::core::result::Result<(), ::pilota::pb::DecodeError> {
200203
match tag {
201204
_ => ::pilota::pb::encoding::skip_field(wire_type, tag, buf, ctx),

pilota-build/test_data/protobuf_with_descriptor/oneof.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ pub mod oneof {
4747

4848
impl ::pilota::pb::Message for UserContact {
4949
#[inline]
50-
fn encoded_len(&self) -> usize {
51-
0 + ::pilota::pb::encoding::faststr::encoded_len(1, &self.name)
52-
+ self.contact.as_ref().map_or(0, |msg| msg.encoded_len())
50+
fn encoded_len(&self, ctx: &mut ::pilota::pb::EncodeLengthContext) -> usize {
51+
0 + ::pilota::pb::encoding::faststr::encoded_len(ctx, 1, &self.name)
52+
+ self.contact.as_ref().map_or(0, |msg| msg.encoded_len(ctx))
5353
}
5454

5555
#[allow(unused_variables)]
@@ -67,6 +67,7 @@ pub mod oneof {
6767
wire_type: ::pilota::pb::encoding::WireType,
6868
buf: &mut ::pilota::Bytes,
6969
ctx: &mut ::pilota::pb::encoding::DecodeContext,
70+
is_root: bool,
7071
) -> ::core::result::Result<(), ::pilota::pb::DecodeError> {
7172
const STRUCT_NAME: &'static str = stringify!(UserContact);
7273

@@ -139,13 +140,13 @@ pub mod oneof {
139140
}
140141

141142
#[inline]
142-
pub fn encoded_len(&self) -> usize {
143+
pub fn encoded_len(&self, ctx: &mut ::pilota::pb::EncodeLengthContext) -> usize {
143144
match self {
144145
Contact::Email(value) => {
145-
::pilota::pb::encoding::faststr::encoded_len(2, &*value)
146+
::pilota::pb::encoding::faststr::encoded_len(ctx, 2, &*value)
146147
}
147148
Contact::Phone(value) => {
148-
::pilota::pb::encoding::faststr::encoded_len(3, &*value)
149+
::pilota::pb::encoding::faststr::encoded_len(ctx, 3, &*value)
149150
}
150151
}
151152
}

pilota-thrift-parser/src/parser/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Constant {
7676
r#type,
7777
value,
7878
annotations: annotations.unwrap_or_default(),
79-
trailing_comments: FastStr::from(trailing_comments.unwrap_or_default()),
79+
trailing_comments: trailing_comments.unwrap_or_default(),
8080
}
8181
},
8282
)

pilota-thrift-parser/src/parser/enum_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl EnumValue {
3232
name: Ident(name.into()),
3333
value,
3434
annotations: annotations.unwrap_or_default(),
35-
trailing_comments: FastStr::from(trailing_comments.unwrap_or_default()),
35+
trailing_comments: trailing_comments.unwrap_or_default(),
3636
},
3737
)
3838
}
@@ -61,7 +61,7 @@ impl Enum {
6161
name: Ident(name.into()),
6262
values,
6363
annotations: annotations.unwrap_or_default(),
64-
trailing_comments: FastStr::from(trailing_comments.unwrap_or_default()),
64+
trailing_comments: trailing_comments.unwrap_or_default(),
6565
},
6666
)
6767
}

pilota-thrift-parser/src/parser/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Field {
4949
name: Ident(name.into()),
5050
default: value,
5151
annotations: annotations.unwrap_or_default(),
52-
trailing_comments: FastStr::from(trailing_comments.unwrap_or_default()),
52+
trailing_comments: trailing_comments.unwrap_or_default(),
5353
},
5454
)
5555
}

0 commit comments

Comments
 (0)