Skip to content

Commit bf20a0c

Browse files
authored
Merge pull request #277 from Tim-Zhang/use-rust-1.81.0
Use rust 1.81.0 to develop
2 parents 35a7a85 + 3d3604b commit bf20a0c

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

compiler/src/codegen.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'a> MethodGen<'a> {
148148
&format!("struct {}Method {{", self.struct_name()),
149149
"}",
150150
|w| {
151-
w.write_line(&format!(
151+
w.write_line(format!(
152152
"service: Arc<dyn {} + Send + Sync>,",
153153
self.service_name
154154
));
@@ -167,7 +167,7 @@ impl<'a> MethodGen<'a> {
167167
|w| {
168168
w.block("fn handler(&self, ctx: ::ttrpc::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<()> {", "}",
169169
|w| {
170-
w.write_line(&format!("::ttrpc::request_handler!(self, ctx, req, {}, {}, {});",
170+
w.write_line(format!("::ttrpc::request_handler!(self, ctx, req, {}, {}, {});",
171171
proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()),
172172
self.root_scope.find_message(self.proto.get_input_type()).rust_name(),
173173
self.name()));
@@ -184,7 +184,7 @@ impl<'a> MethodGen<'a> {
184184
|w| {
185185
w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<::ttrpc::Response> {", "}",
186186
|w| {
187-
w.write_line(&format!("::ttrpc::async_request_handler!(self, ctx, req, {}, {}, {});",
187+
w.write_line(format!("::ttrpc::async_request_handler!(self, ctx, req, {}, {}, {});",
188188
proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()),
189189
self.root_scope.find_message(self.proto.get_input_type()).rust_name(),
190190
self.name()));
@@ -197,7 +197,7 @@ impl<'a> MethodGen<'a> {
197197
|w| {
198198
w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result<Option<::ttrpc::Response>> {", "}",
199199
|w| {
200-
w.write_line(&format!("::ttrpc::async_client_streamimg_handler!(self, ctx, inner, {});",
200+
w.write_line(format!("::ttrpc::async_client_streamimg_handler!(self, ctx, inner, {});",
201201
self.name()));
202202
});
203203
});
@@ -208,7 +208,7 @@ impl<'a> MethodGen<'a> {
208208
|w| {
209209
w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, mut inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result<Option<::ttrpc::Response>> {", "}",
210210
|w| {
211-
w.write_line(&format!("::ttrpc::async_server_streamimg_handler!(self, ctx, inner, {}, {}, {});",
211+
w.write_line(format!("::ttrpc::async_server_streamimg_handler!(self, ctx, inner, {}, {}, {});",
212212
proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()),
213213
self.root_scope.find_message(self.proto.get_input_type()).rust_name(),
214214
self.name()));
@@ -221,7 +221,7 @@ impl<'a> MethodGen<'a> {
221221
|w| {
222222
w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result<Option<::ttrpc::Response>> {", "}",
223223
|w| {
224-
w.write_line(&format!("::ttrpc::async_duplex_streamimg_handler!(self, ctx, inner, {});",
224+
w.write_line(format!("::ttrpc::async_duplex_streamimg_handler!(self, ctx, inner, {});",
225225
self.name()));
226226
});
227227
});
@@ -277,8 +277,8 @@ impl<'a> MethodGen<'a> {
277277
let method_name = self.name();
278278
if let MethodType::Unary = self.method_type().0 {
279279
w.pub_fn(&self.unary(&method_name), |w| {
280-
w.write_line(&format!("let mut cres = {}::new();", self.output()));
281-
w.write_line(&format!(
280+
w.write_line(format!("let mut cres = {}::new();", self.output()));
281+
w.write_line(format!(
282282
"::ttrpc::client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);",
283283
self.package_name,
284284
self.service_name,
@@ -295,8 +295,8 @@ impl<'a> MethodGen<'a> {
295295
// Unary RPC
296296
MethodType::Unary => {
297297
pub_async_fn(w, &self.unary(&method_name), |w| {
298-
w.write_line(&format!("let mut cres = {}::new();", self.output()));
299-
w.write_line(&format!(
298+
w.write_line(format!("let mut cres = {}::new();", self.output()));
299+
w.write_line(format!(
300300
"::ttrpc::async_client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);",
301301
self.package_name,
302302
self.service_name,
@@ -307,7 +307,7 @@ impl<'a> MethodGen<'a> {
307307
// Client Streaming RPC
308308
MethodType::ClientStreaming => {
309309
pub_async_fn(w, &self.client_streaming(&method_name), |w| {
310-
w.write_line(&format!(
310+
w.write_line(format!(
311311
"::ttrpc::async_client_stream_send!(self, ctx, \"{}.{}\", \"{}\");",
312312
self.package_name,
313313
self.service_name,
@@ -318,7 +318,7 @@ impl<'a> MethodGen<'a> {
318318
// Server Streaming RPC
319319
MethodType::ServerStreaming => {
320320
pub_async_fn(w, &self.server_streaming(&method_name), |w| {
321-
w.write_line(&format!(
321+
w.write_line(format!(
322322
"::ttrpc::async_client_stream_receive!(self, ctx, req, \"{}.{}\", \"{}\");",
323323
self.package_name,
324324
self.service_name,
@@ -329,7 +329,7 @@ impl<'a> MethodGen<'a> {
329329
// Bidirectional streaming RPC
330330
MethodType::Duplex => {
331331
pub_async_fn(w, &self.duplex_streaming(&method_name), |w| {
332-
w.write_line(&format!(
332+
w.write_line(format!(
333333
"::ttrpc::async_client_stream!(self, ctx, \"{}.{}\", \"{}\");",
334334
self.package_name,
335335
self.service_name,
@@ -496,13 +496,13 @@ impl<'a> ServiceGen<'a> {
496496

497497
fn write_sync_client(&self, w: &mut CodeWriter) {
498498
w.write_line("#[derive(Clone)]");
499-
w.pub_struct(&self.client_name(), |w| {
499+
w.pub_struct(self.client_name(), |w| {
500500
w.field_decl("client", "::ttrpc::Client");
501501
});
502502

503503
w.write_line("");
504504

505-
w.impl_self_block(&self.client_name(), |w| {
505+
w.impl_self_block(self.client_name(), |w| {
506506
w.pub_fn("new(client: ::ttrpc::Client) -> Self", |w| {
507507
w.expr_block(&self.client_name(), |w| {
508508
w.write_line("client,");
@@ -518,13 +518,13 @@ impl<'a> ServiceGen<'a> {
518518

519519
fn write_async_client(&self, w: &mut CodeWriter) {
520520
w.write_line("#[derive(Clone)]");
521-
w.pub_struct(&self.client_name(), |w| {
521+
w.pub_struct(self.client_name(), |w| {
522522
w.field_decl("client", "::ttrpc::r#async::Client");
523523
});
524524

525525
w.write_line("");
526526

527-
w.impl_self_block(&self.client_name(), |w| {
527+
w.impl_self_block(self.client_name(), |w| {
528528
w.pub_fn("new(client: ::ttrpc::r#async::Client) -> Self", |w| {
529529
w.expr_block(&self.client_name(), |w| {
530530
w.write_line("client,");

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel="1.77.0"
2+
channel="1.81.0"
33
profile="default"
44
components=["rustfmt", "clippy"]

ttrpc-codegen/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a> Run<'a> {
233233
protobuf_path: &str,
234234
result: &mut HashMap<String, FileDescriptorPair>,
235235
) {
236-
if result.get(protobuf_path).is_some() {
236+
if result.contains_key(protobuf_path) {
237237
return;
238238
}
239239

@@ -257,7 +257,7 @@ impl<'a> Run<'a> {
257257
}
258258

259259
fn add_file(&mut self, protobuf_path: &str, fs_path: &Path) -> io::Result<()> {
260-
if self.parsed_files.get(protobuf_path).is_some() {
260+
if self.parsed_files.contains_key(protobuf_path) {
261261
return Ok(());
262262
}
263263

ttrpc-codegen/src/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ trait ToChar {
106106

107107
impl ToI32 for u64 {
108108
fn to_i32(&self) -> ParserResult<i32> {
109-
if *self <= i32::max_value() as u64 {
109+
if *self <= i32::MAX as u64 {
110110
Ok(*self as i32)
111111
} else {
112112
Err(ParserError::IntegerOverflow)
@@ -116,7 +116,7 @@ impl ToI32 for u64 {
116116

117117
impl ToI32 for i64 {
118118
fn to_i32(&self) -> ParserResult<i32> {
119-
if *self <= i32::max_value() as i64 && *self >= i32::min_value() as i64 {
119+
if *self <= i32::MAX as i64 && *self >= i32::MIN as i64 {
120120
Ok(*self as i32)
121121
} else {
122122
Err(ParserError::IntegerOverflow)
@@ -126,7 +126,7 @@ impl ToI32 for i64 {
126126

127127
impl ToI64 for u64 {
128128
fn to_i64(&self) -> Result<i64, ParserError> {
129-
if *self <= i64::max_value() as u64 {
129+
if *self <= i64::MAX as u64 {
130130
Ok(*self as i64)
131131
} else {
132132
Err(ParserError::IntegerOverflow)
@@ -1378,7 +1378,7 @@ impl<'a> Parser<'a> {
13781378
let from = self.next_field_number()?;
13791379
let to = if self.next_ident_if_eq("to")? {
13801380
if self.next_ident_if_eq("max")? {
1381-
i32::max_value()
1381+
i32::MAX
13821382
} else {
13831383
self.next_field_number()?
13841384
}

0 commit comments

Comments
 (0)