From 43fa5e83cbed6a6b1681f119f8685498d4b4f081 Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Thu, 26 Dec 2024 15:47:00 +0800 Subject: [PATCH] Update rustc version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit because this error "package `home v0.5.11` cannot be built \ because it requires rustc 1.81 or newer,\ while the currently active rustc version is 1.77.0" Signed-off-by: 胡丁洋10346053 --- compiler/src/codegen.rs | 34 +++++++++++++++++----------------- rust-toolchain.toml | 2 +- ttrpc-codegen/src/lib.rs | 2 +- ttrpc-codegen/src/parser.rs | 8 ++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/compiler/src/codegen.rs b/compiler/src/codegen.rs index 39746af7..238d814e 100644 --- a/compiler/src/codegen.rs +++ b/compiler/src/codegen.rs @@ -148,7 +148,7 @@ impl<'a> MethodGen<'a> { &format!("struct {}Method {{", self.struct_name()), "}", |w| { - w.write_line(&format!( + w.write_line(format!( "service: Arc,", self.service_name )); @@ -167,7 +167,7 @@ impl<'a> MethodGen<'a> { |w| { w.block("fn handler(&self, ctx: ::ttrpc::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<()> {", "}", |w| { - w.write_line(&format!("::ttrpc::request_handler!(self, ctx, req, {}, {}, {});", + w.write_line(format!("::ttrpc::request_handler!(self, ctx, req, {}, {}, {});", proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()), self.root_scope.find_message(self.proto.get_input_type()).rust_name(), self.name())); @@ -184,7 +184,7 @@ impl<'a> MethodGen<'a> { |w| { w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<::ttrpc::Response> {", "}", |w| { - w.write_line(&format!("::ttrpc::async_request_handler!(self, ctx, req, {}, {}, {});", + w.write_line(format!("::ttrpc::async_request_handler!(self, ctx, req, {}, {}, {});", proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()), self.root_scope.find_message(self.proto.get_input_type()).rust_name(), self.name())); @@ -197,7 +197,7 @@ impl<'a> MethodGen<'a> { |w| { w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result> {", "}", |w| { - w.write_line(&format!("::ttrpc::async_client_streamimg_handler!(self, ctx, inner, {});", + w.write_line(format!("::ttrpc::async_client_streamimg_handler!(self, ctx, inner, {});", self.name())); }); }); @@ -208,7 +208,7 @@ impl<'a> MethodGen<'a> { |w| { w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, mut inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result> {", "}", |w| { - w.write_line(&format!("::ttrpc::async_server_streamimg_handler!(self, ctx, inner, {}, {}, {});", + w.write_line(format!("::ttrpc::async_server_streamimg_handler!(self, ctx, inner, {}, {}, {});", proto_path_to_rust_mod(self.root_scope.find_message(self.proto.get_input_type()).get_scope().get_file_descriptor().get_name()), self.root_scope.find_message(self.proto.get_input_type()).rust_name(), self.name())); @@ -221,7 +221,7 @@ impl<'a> MethodGen<'a> { |w| { w.block("async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, inner: ::ttrpc::r#async::StreamInner) -> ::ttrpc::Result> {", "}", |w| { - w.write_line(&format!("::ttrpc::async_duplex_streamimg_handler!(self, ctx, inner, {});", + w.write_line(format!("::ttrpc::async_duplex_streamimg_handler!(self, ctx, inner, {});", self.name())); }); }); @@ -277,8 +277,8 @@ impl<'a> MethodGen<'a> { let method_name = self.name(); if let MethodType::Unary = self.method_type().0 { w.pub_fn(&self.unary(&method_name), |w| { - w.write_line(&format!("let mut cres = {}::new();", self.output())); - w.write_line(&format!( + w.write_line(format!("let mut cres = {}::new();", self.output())); + w.write_line(format!( "::ttrpc::client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);", self.package_name, self.service_name, @@ -295,8 +295,8 @@ impl<'a> MethodGen<'a> { // Unary RPC MethodType::Unary => { pub_async_fn(w, &self.unary(&method_name), |w| { - w.write_line(&format!("let mut cres = {}::new();", self.output())); - w.write_line(&format!( + w.write_line(format!("let mut cres = {}::new();", self.output())); + w.write_line(format!( "::ttrpc::async_client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);", self.package_name, self.service_name, @@ -307,7 +307,7 @@ impl<'a> MethodGen<'a> { // Client Streaming RPC MethodType::ClientStreaming => { pub_async_fn(w, &self.client_streaming(&method_name), |w| { - w.write_line(&format!( + w.write_line(format!( "::ttrpc::async_client_stream_send!(self, ctx, \"{}.{}\", \"{}\");", self.package_name, self.service_name, @@ -318,7 +318,7 @@ impl<'a> MethodGen<'a> { // Server Streaming RPC MethodType::ServerStreaming => { pub_async_fn(w, &self.server_streaming(&method_name), |w| { - w.write_line(&format!( + w.write_line(format!( "::ttrpc::async_client_stream_receive!(self, ctx, req, \"{}.{}\", \"{}\");", self.package_name, self.service_name, @@ -329,7 +329,7 @@ impl<'a> MethodGen<'a> { // Bidirectional streaming RPC MethodType::Duplex => { pub_async_fn(w, &self.duplex_streaming(&method_name), |w| { - w.write_line(&format!( + w.write_line(format!( "::ttrpc::async_client_stream!(self, ctx, \"{}.{}\", \"{}\");", self.package_name, self.service_name, @@ -496,13 +496,13 @@ impl<'a> ServiceGen<'a> { fn write_sync_client(&self, w: &mut CodeWriter) { w.write_line("#[derive(Clone)]"); - w.pub_struct(&self.client_name(), |w| { + w.pub_struct(self.client_name(), |w| { w.field_decl("client", "::ttrpc::Client"); }); w.write_line(""); - w.impl_self_block(&self.client_name(), |w| { + w.impl_self_block(self.client_name(), |w| { w.pub_fn("new(client: ::ttrpc::Client) -> Self", |w| { w.expr_block(&self.client_name(), |w| { w.write_line("client,"); @@ -518,13 +518,13 @@ impl<'a> ServiceGen<'a> { fn write_async_client(&self, w: &mut CodeWriter) { w.write_line("#[derive(Clone)]"); - w.pub_struct(&self.client_name(), |w| { + w.pub_struct(self.client_name(), |w| { w.field_decl("client", "::ttrpc::r#async::Client"); }); w.write_line(""); - w.impl_self_block(&self.client_name(), |w| { + w.impl_self_block(self.client_name(), |w| { w.pub_fn("new(client: ::ttrpc::r#async::Client) -> Self", |w| { w.expr_block(&self.client_name(), |w| { w.write_line("client,"); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c058c59e..7e550c68 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel="1.77.0" +channel="1.81.0" profile="default" components=["rustfmt", "clippy"] diff --git a/ttrpc-codegen/src/lib.rs b/ttrpc-codegen/src/lib.rs index e9c7445e..b307a914 100644 --- a/ttrpc-codegen/src/lib.rs +++ b/ttrpc-codegen/src/lib.rs @@ -257,7 +257,7 @@ impl<'a> Run<'a> { } fn add_file(&mut self, protobuf_path: &str, fs_path: &Path) -> io::Result<()> { - if self.parsed_files.get(protobuf_path).is_some() { + if self.parsed_files.contains_key(protobuf_path){ return Ok(()); } diff --git a/ttrpc-codegen/src/parser.rs b/ttrpc-codegen/src/parser.rs index 16fba7a1..ba7fb386 100644 --- a/ttrpc-codegen/src/parser.rs +++ b/ttrpc-codegen/src/parser.rs @@ -106,7 +106,7 @@ trait ToChar { impl ToI32 for u64 { fn to_i32(&self) -> ParserResult { - if *self <= i32::max_value() as u64 { + if *self <= i32::MAX as u64 { Ok(*self as i32) } else { Err(ParserError::IntegerOverflow) @@ -116,7 +116,7 @@ impl ToI32 for u64 { impl ToI32 for i64 { fn to_i32(&self) -> ParserResult { - if *self <= i32::max_value() as i64 && *self >= i32::min_value() as i64 { + if *self <= i32::MAX as i64 && *self >= i32::MIN as i64 { Ok(*self as i32) } else { Err(ParserError::IntegerOverflow) @@ -126,7 +126,7 @@ impl ToI32 for i64 { impl ToI64 for u64 { fn to_i64(&self) -> Result { - if *self <= i64::max_value() as u64 { + if *self <= i64::MAX as u64 { Ok(*self as i64) } else { Err(ParserError::IntegerOverflow) @@ -1378,7 +1378,7 @@ impl<'a> Parser<'a> { let from = self.next_field_number()?; let to = if self.next_ident_if_eq("to")? { if self.next_ident_if_eq("max")? { - i32::max_value() + i32::MAX } else { self.next_field_number()? }