build: bump rust edition to 2024 (#6920)

* bump edition

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* format

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* gen keyword

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* lifetime and env var

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* one more gen fix

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* lifetime of temporaries in tail expressions

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* format again

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* clippy nested if

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* clippy let and return

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2025-09-07 19:37:18 -07:00
committed by GitHub
parent 658d07bfc8
commit c9377e7c5a
1014 changed files with 6268 additions and 5540 deletions

View File

@@ -28,7 +28,7 @@ use std::time::Duration;
use async_trait::async_trait;
use client::error::ServerSnafu;
use client::{
Client, Database as DB, Error as ClientError, DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME,
Client, DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, Database as DB, Error as ClientError,
};
use common_error::ext::ErrorExt;
use common_query::{Output, OutputData};
@@ -45,8 +45,8 @@ use tokio_postgres::{Client as PgClient, SimpleQueryMessage as PgRow};
use crate::protocol_interceptor::{MYSQL, PROTOCOL_KEY};
use crate::server_mode::ServerMode;
use crate::util::{get_workspace_root, maybe_pull_binary, PROGRAM};
use crate::{util, ServerAddr};
use crate::util::{PROGRAM, get_workspace_root, maybe_pull_binary};
use crate::{ServerAddr, util};
// standalone mode
const SERVER_MODE_STANDALONE_IDX: usize = 0;
@@ -102,7 +102,9 @@ impl EnvController for Env {
panic!("Parallel test mode is not supported when server address is already set.");
}
std::env::set_var("SQLNESS_HOME", self.sqlness_home.display().to_string());
unsafe {
std::env::set_var("SQLNESS_HOME", self.sqlness_home.display().to_string());
}
match mode {
"standalone" => self.start_standalone(id).await,
"distributed" => self.start_distributed(id).await,
@@ -177,13 +179,17 @@ impl Env {
// start a distributed GreptimeDB
let meta_server_mode = ServerMode::random_metasrv();
let metasrv_port = match &meta_server_mode {
ServerMode::Metasrv { rpc_server_addr, .. } => rpc_server_addr
ServerMode::Metasrv {
rpc_server_addr, ..
} => rpc_server_addr
.split(':')
.nth(1)
.unwrap()
.parse::<u16>()
.unwrap(),
_ => panic!("metasrv mode not set, maybe running in remote mode which doesn't support restart?"),
_ => panic!(
"metasrv mode not set, maybe running in remote mode which doesn't support restart?"
),
};
db_ctx.set_server_mode(meta_server_mode.clone(), SERVER_MODE_METASRV_IDX);
let meta_server = self.start_server(meta_server_mode, &db_ctx, id, true).await;
@@ -612,7 +618,7 @@ impl GreptimeDB {
match row {
Ok(r) => rows.push(r),
Err(e) => {
return Box::new(format!("Failed to parse query result, err: {:?}", e))
return Box::new(format!("Failed to parse query result, err: {:?}", e));
}
}
}

View File

@@ -137,10 +137,10 @@ async fn main() {
Arc::new(protocol_interceptor::ProtocolInterceptorFactory),
);
if let Some(d) = &args.case_dir {
if !d.is_dir() {
panic!("{} is not a directory", d.display());
}
if let Some(d) = &args.case_dir
&& !d.is_dir()
{
panic!("{} is not a directory", d.display());
}
if args.jobs == 0 {
args.jobs = num_cpus::get() / 2;
@@ -156,7 +156,9 @@ async fn main() {
|| args.test_filter != ".*"
{
args.jobs = 1;
println!("Normalizing parallelism to 1 due to server addresses, etcd/pg/mysql setup, or test filter usage");
println!(
"Normalizing parallelism to 1 due to server addresses, etcd/pg/mysql setup, or test filter usage"
);
}
let config = ConfigBuilder::default()

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use sqlness::interceptor::{Interceptor, InterceptorFactory, InterceptorRef};
use sqlness::SqlnessError;
use sqlness::interceptor::{Interceptor, InterceptorFactory, InterceptorRef};
pub const PROTOCOL_KEY: &str = "protocol";
pub const POSTGRES: &str = "postgres";

View File

@@ -20,7 +20,7 @@ use serde::Serialize;
use tinytemplate::TinyTemplate;
use crate::env::{Env, GreptimeDBContext};
use crate::{util, ServerAddr};
use crate::{ServerAddr, util};
const DEFAULT_LOG_LEVEL: &str = "--log-level=debug,hyper=warn,tower=warn,datafusion=warn,reqwest=warn,sqlparser=warn,h2=info,opendal=info";

View File

@@ -182,10 +182,14 @@ pub async fn pull_binary(version: &str) {
/// Pull the binary if it does not exist and `pull_version_on_need` is true.
pub async fn maybe_pull_binary(version: &str, pull_version_on_need: bool) {
let exist = Path::new(version).join(PROGRAM).is_file();
match (exist, pull_version_on_need){
match (exist, pull_version_on_need) {
(true, _) => println!("Binary {version} exists"),
(false, false) => panic!("Binary {version} does not exist, please run with --pull-version-on-need or manually download it"),
(false, true) => { pull_binary(version).await; },
(false, false) => panic!(
"Binary {version} does not exist, please run with --pull-version-on-need or manually download it"
),
(false, true) => {
pull_binary(version).await;
}
}
}