Skip to content

Commit 079d2a9

Browse files
authored
*: Update rust toolchain to nightly-2025-04-03 (#18416)
ref #17465 Following #17605, another attempt to update rust toolchain Changes: - Language - After rust-lang/rust#134258, we can't manually impl both `ToString` and `fmt::Display`, so this PR add a new trait `ToStringValue` to work around types type produces different result between ToString and Display. - Clippy - `Option::map_or(false, ...)` --> `Option::is_some_and(...)` - `Option::map_or(true, ...)` --> `Option::is_none_or(...)` - `(a + b - 1 )/ b` --> `a.div_ceil(b)` - `io::Error::new(ErrorKind::Other, ...)` --> ` io::Error::other(...)` - `Slice::group_by` --> `Slice::chunk_by` - `Result::map_err(|e| {...; e})` --> `Result::inspect_err(|e| { ... })` - `Map::get(&key).is_{some, none}()` --> `Map::contains_key()` - Formatter - The import order now follows ascii order, e.g. before is "use crate::{a, b, c, A, B, C}", after is "use crate::{A, B, C, a, b, c}". Most changes are due to this. - List in rust doc should be properly aligned. - cargo-deny - `vulnerability`, `notice` and `unsound` can't be config in version 2, and `unmaintained` can't be allowed anymore(but support setting `workspace` to allow indirected pkgs). So replacing some unmaintained packages with suggested alternatives. (See: #18416) Signed-off-by: glorv <[email protected]>
1 parent d241ebe commit 079d2a9

File tree

874 files changed

+3803
-4023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

874 files changed

+3803
-4023
lines changed

Cargo.lock

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

cmd/tikv-ctl/src/cmd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
use std::{borrow::ToOwned, str, string::ToString, sync::LazyLock, u64};
3+
use std::{borrow::ToOwned, str, string::ToString, sync::LazyLock};
44

5-
use clap::{crate_authors, AppSettings};
6-
use engine_traits::{SstCompressionType, CF_DEFAULT};
5+
use clap::{AppSettings, crate_authors};
6+
use engine_traits::{CF_DEFAULT, SstCompressionType};
77
use raft_engine::ReadableSize;
88
use structopt::StructOpt;
99

cmd/tikv-ctl/src/executor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ use api_version::{ApiV1, KvFormat};
99
use encryption_export::data_key_manager_from_config;
1010
use engine_rocks::util::{db_exist, new_engine_opt};
1111
use engine_traits::{
12-
Engines, Error as EngineError, RaftEngine, TabletRegistry, ALL_CFS, CF_DEFAULT, CF_LOCK,
13-
CF_WRITE, DATA_CFS,
12+
ALL_CFS, CF_DEFAULT, CF_LOCK, CF_WRITE, DATA_CFS, Engines, Error as EngineError, RaftEngine,
13+
TabletRegistry,
1414
};
1515
use file_system::read_dir;
1616
use futures::{
17+
StreamExt, TryStreamExt,
1718
executor::block_on,
1819
future,
1920
stream::{self, BoxStream},
20-
StreamExt, TryStreamExt,
2121
};
2222
use grpcio::{ChannelBuilder, Environment};
2323
use kvproto::{
@@ -31,23 +31,23 @@ use pd_client::{Config as PdConfig, PdClient, RpcClient};
3131
use protobuf::Message;
3232
use raft::eraftpb::{ConfChange, ConfChangeV2, Entry, EntryType};
3333
use raft_log_engine::RaftLogEngine;
34-
use raftstore::store::{util::build_key_range, INIT_EPOCH_CONF_VER};
34+
use raftstore::store::{INIT_EPOCH_CONF_VER, util::build_key_range};
3535
use security::SecurityManager;
3636
use serde_json::json;
3737
use server::fatal;
3838
use slog_global::crit;
3939
use tikv::{
4040
config::{ConfigController, TikvConfig},
4141
server::{
42+
KvEngineFactoryBuilder,
4243
debug::{BottommostLevelCompaction, Debugger, DebuggerImpl, RegionInfo},
4344
debug2::DebuggerImplV2,
44-
KvEngineFactoryBuilder,
4545
},
4646
storage::{
47+
Engine,
4748
config::EngineType,
4849
kv::MockEngine,
4950
lock_manager::{LockManager, MockLockManager},
50-
Engine,
5151
},
5252
};
5353
use tikv_util::escape;
@@ -223,7 +223,7 @@ pub trait DebugExecutor {
223223
let r = self.get_region_info(region_id);
224224
if skip_tombstone {
225225
let region_state = r.region_local_state.as_ref();
226-
if region_state.map_or(false, |s| s.get_state() == PeerState::Tombstone) {
226+
if region_state.is_some_and(|s| s.get_state() == PeerState::Tombstone) {
227227
continue;
228228
}
229229
}
@@ -386,21 +386,21 @@ pub trait DebugExecutor {
386386
println!("key: {}", escape(&key));
387387
if cfs.contains(&CF_LOCK) && mvcc.has_lock() {
388388
let lock_info = mvcc.get_lock();
389-
if start_ts.map_or(true, |ts| lock_info.get_start_ts() == ts) {
389+
if start_ts.is_none_or(|ts| lock_info.get_start_ts() == ts) {
390390
println!("\tlock cf value: {:?}", lock_info);
391391
}
392392
}
393393
if cfs.contains(&CF_DEFAULT) {
394394
for value_info in mvcc.get_values() {
395-
if commit_ts.map_or(true, |ts| value_info.get_start_ts() == ts) {
395+
if commit_ts.is_none_or(|ts| value_info.get_start_ts() == ts) {
396396
println!("\tdefault cf value: {:?}", value_info);
397397
}
398398
}
399399
}
400400
if cfs.contains(&CF_WRITE) {
401401
for write_info in mvcc.get_writes() {
402-
if start_ts.map_or(true, |ts| write_info.get_start_ts() == ts)
403-
&& commit_ts.map_or(true, |ts| write_info.get_commit_ts() == ts)
402+
if start_ts.is_none_or(|ts| write_info.get_start_ts() == ts)
403+
&& commit_ts.is_none_or(|ts| write_info.get_commit_ts() == ts)
404404
{
405405
println!("\t write cf value: {:?}", write_info);
406406
}

cmd/tikv-ctl/src/fork_readonly_tikv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
};
99

1010
use encryption_export::data_key_manager_from_config;
11-
use raft_engine::{env::DefaultFileSystem, Engine as RaftEngine};
11+
use raft_engine::{Engine as RaftEngine, env::DefaultFileSystem};
1212
use regex::Regex;
1313
use tikv::config::TikvConfig;
1414

cmd/tikv-ctl/src/main.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
#![feature(lazy_cell)]
43
#![feature(let_chains)]
54

65
#[macro_use]
@@ -16,19 +15,19 @@ use std::{
1615
sync::{Arc, Mutex, RwLock},
1716
thread,
1817
time::Duration,
19-
u64,
2018
};
2119

2220
use collections::HashMap;
2321
use compact_log_backup::{
22+
TraceResultExt,
2423
exec_hooks::{self as compact_log_hooks, skip_small_compaction::SkipSmallCompaction},
25-
execute as compact_log, TraceResultExt,
24+
execute as compact_log,
2625
};
2726
use crypto::fips;
2827
use encryption_export::{
29-
create_backend, data_key_manager_from_config, DataKeyManager, DecrypterReader, Iv,
28+
DataKeyManager, DecrypterReader, Iv, create_backend, data_key_manager_from_config,
3029
};
31-
use engine_rocks::{get_env, util::new_engine_opt, RocksEngine};
30+
use engine_rocks::{RocksEngine, get_env, util::new_engine_opt};
3231
use engine_traits::Peekable;
3332
use file_system::calc_crc32;
3433
use futures::{executor::block_on, future::try_join_all};
@@ -49,16 +48,16 @@ use raft_log_engine::ManagedFileSystem;
4948
use raftstore::store::util::build_key_range;
5049
use regex::Regex;
5150
use security::{SecurityConfig, SecurityManager};
52-
use structopt::{clap::ErrorKind, StructOpt};
51+
use structopt::{StructOpt, clap::ErrorKind};
5352
use tempfile::TempDir;
5453
use tikv::{
5554
config::TikvConfig,
56-
server::{debug::BottommostLevelCompaction, KvEngineFactoryBuilder},
55+
server::{KvEngineFactoryBuilder, debug::BottommostLevelCompaction},
5756
storage::config::EngineType,
5857
};
5958
use tikv_util::{
6059
escape,
61-
logger::{get_log_level, Level},
60+
logger::{Level, get_log_level},
6261
run_and_wait_child_process,
6362
sys::thread::StdThreadBuildWrapper,
6463
unescape, warn,
@@ -1292,6 +1291,9 @@ fn print_bad_ssts(data_dir: &str, manifest: Option<&str>, pd_client: RpcClient,
12921291
stderr_buf.read_to_end(&mut buffer).unwrap();
12931292
let corruptions = unsafe { String::from_utf8_unchecked(buffer) };
12941293

1294+
let r = Regex::new(r"/\w*\.sst").unwrap();
1295+
let column_r = Regex::new(r"--------------- (.*) --------------\n(.*)").unwrap();
1296+
let sst_stat_r = Regex::new(r".*\n\d+:\d+\[\d+ .. \d+\]\['(\w*)' seq:\d+, type:\d+ .. '(\w*)' seq:\d+, type:\d+\] at level \d+").unwrap();
12951297
for line in corruptions.lines() {
12961298
println!("--------------------------------------------------------");
12971299
// The corruption format may like this:
@@ -1300,7 +1302,6 @@ fn print_bad_ssts(data_dir: &str, manifest: Option<&str>, pd_client: RpcClient,
13001302
// ```
13011303
println!("corruption info:\n{}", line);
13021304

1303-
let r = Regex::new(r"/\w*\.sst").unwrap();
13041305
let sst_file_number = match r.captures(line) {
13051306
None => {
13061307
println!("skip bad line format");
@@ -1361,15 +1362,13 @@ fn print_bad_ssts(data_dir: &str, manifest: Option<&str>, pd_client: RpcClient,
13611362
// --------------- Column family "write" (ID 2) --------------
13621363
// 63:132906243[3555338 .. 3555338]['7A311B40EFCC2CB4C5911ECF3937D728DED26AE53FA5E61BE04F23F2BE54EACC73' seq:3555338, type:1 .. '7A313030302E25CD5F57252E' seq:3555338, type:1] at level 0
13631364
// ```
1364-
let column_r = Regex::new(r"--------------- (.*) --------------\n(.*)").unwrap();
13651365
if let Some(m) = column_r.captures(&output) {
13661366
println!(
13671367
"{} for {}",
13681368
m.get(2).unwrap().as_str(),
13691369
m.get(1).unwrap().as_str()
13701370
);
1371-
let r = Regex::new(r".*\n\d+:\d+\[\d+ .. \d+\]\['(\w*)' seq:\d+, type:\d+ .. '(\w*)' seq:\d+, type:\d+\] at level \d+").unwrap();
1372-
let matches = match r.captures(&output) {
1371+
let matches = match sst_stat_r.captures(&output) {
13731372
None => {
13741373
println!("sst start key format is not correct: {}", output);
13751374
continue;

cmd/tikv-ctl/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
use std::{borrow::ToOwned, error::Error, str, str::FromStr, u64};
3+
use std::{borrow::ToOwned, error::Error, str, str::FromStr};
44

55
use kvproto::kvrpcpb::KeyRange;
66
use server::setup::initial_logger;

cmd/tikv-server/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
use std::{path::Path, process};
66

7-
use clap::{crate_authors, App, Arg};
7+
use clap::{App, Arg, crate_authors};
88
use crypto::fips;
99
use serde_json::{Map, Value};
1010
use server::setup::{ensure_no_unrecognized_config, validate_and_persist_config};
1111
use tikv::{
12-
config::{to_flatten_config_info, TikvConfig},
12+
config::{TikvConfig, to_flatten_config_info},
1313
storage::config::EngineType,
1414
};
1515

components/api_version/src/api_v1ttl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use engine_traits::Result;
44
use tikv_util::{
55
box_err,
66
codec::{
7-
number::{self, NumberEncoder},
87
Error,
8+
number::{self, NumberEncoder},
99
},
1010
};
1111

components/api_version/src/api_v2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
use codec::byte::MemComparableByteCodec;
44
use engine_traits::Result;
55
use tikv_util::codec::{
6-
bytes,
6+
Error, bytes,
77
number::{self, NumberEncoder},
8-
Error,
98
};
109
use txn_types::{Key, TimeStamp};
1110

components/api_version/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<T: AsRef<[u8]>> RawValue<T> {
259259
#[inline]
260260
pub fn is_ttl_expired(&self, current_ts: u64) -> bool {
261261
self.expire_ts
262-
.map_or(false, |expire_ts| expire_ts <= current_ts)
262+
.is_some_and(|expire_ts| expire_ts <= current_ts)
263263
}
264264
}
265265

0 commit comments

Comments
 (0)