Skip to content

Commit e01c2aa

Browse files
committed
fix(rust-core): 修复 Rust 1.100 clippy 新增的 lint,让 Rust Core CI 通过
1 parent f0b5074 commit e01c2aa

7 files changed

Lines changed: 23 additions & 19 deletions

File tree

‎rust/crates/build/src/options.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) fn resolve(
3636
model_values: Option<&BTreeMap<String, Vec<String>>>,
3737
) -> ResolvedOptions {
3838
let mut resolved = ResolvedOptions::default();
39-
for (id, _) in stored.iter() {
39+
for id in stored.keys() {
4040
if build_system.option(id).is_none() {
4141
resolved.dropped.push(id.clone());
4242
}

‎rust/crates/core/src/tests/build_systems.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ fn gradle_canonical_outputs_are_read_from_the_output_file() {
871871
"format": "litheBuildModel",
872872
"version": 0,
873873
"projects": [
874-
{ "path": format!("{root}"), "name": "shop", "properties": { "taskPrefix": ":" } },
874+
{ "path": root.to_string(), "name": "shop", "properties": { "taskPrefix": ":" } },
875875
{ "path": "app", "name": "app", "properties": { "taskPrefix": ":app:" } }
876876
],
877877
"tasks": [

‎rust/crates/git/src/configuration.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn entries(bytes: &[u8]) -> Result<Vec<Entry>, CoreError> {
126126
));
127127
}
128128
let mut result: Vec<Entry> = Vec::new();
129-
for part in parts.chunks_exact(3) {
129+
for part in parts.as_chunks::<3>().0 {
130130
let (key, value) = part[2].split_once('\n').unwrap_or((part[2], "true"));
131131
let key = key.to_string();
132132
if !readable(&key) {

‎rust/crates/git/src/diff_blocks.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ pub(super) fn worktree_attributes_safe(root: &str, paths: &[String]) -> Result<b
676676
}
677677
let fields = output.stdout.split('\0').collect::<Vec<_>>();
678678
let mut reported = 0;
679-
for record in fields.chunks_exact(3) {
679+
for record in fields.as_chunks::<3>().0 {
680680
if record[1] == "filter" || record[1] == "working-tree-encoding" {
681681
reported += 1;
682682
if record[2] != "unspecified" && record[2] != "unset" {

‎rust/crates/lsp-client/src/client/capabilities.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub(crate) fn semantic_token_result(
389389
}
390390
let mut tokens = Vec::with_capacity(data.len() / 5);
391391
let (mut line, mut column) = (0_u64, 0_u64);
392-
for chunk in data.chunks_exact(5) {
392+
for chunk in data.as_chunks::<5>().0 {
393393
let numbers: Vec<u64> = chunk.iter().map(Value::as_u64).collect::<Option<_>>()?;
394394
if numbers.iter().any(|value| *value > u32::MAX as u64) {
395395
return None;

‎rust/crates/project-generators/src/archive.rs‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,22 @@ fn is_plain_relative(path: &Path, platform: Platform) -> bool {
228228
})
229229
}
230230

231+
/// A directory that is neither a symbolic link nor, on Windows, another
232+
/// reparse point such as a junction.
231233
fn real_directory(metadata: &fs::Metadata) -> bool {
232-
if !metadata.is_dir() || metadata.file_type().is_symlink() {
233-
return false;
234-
}
235-
#[cfg(windows)]
236-
{
237-
use std::os::windows::fs::MetadataExt;
238-
if metadata.file_attributes() & 0x400 != 0 {
239-
return false;
240-
}
241-
}
242-
true
234+
metadata.is_dir() && !metadata.file_type().is_symlink() && !reparse_point(metadata)
235+
}
236+
237+
#[cfg(windows)]
238+
fn reparse_point(metadata: &fs::Metadata) -> bool {
239+
use std::os::windows::fs::MetadataExt;
240+
// FILE_ATTRIBUTE_REPARSE_POINT
241+
metadata.file_attributes() & 0x400 != 0
242+
}
243+
244+
#[cfg(not(windows))]
245+
fn reparse_point(_metadata: &fs::Metadata) -> bool {
246+
false
243247
}
244248

245249
/// Unix stores any name the earlier checks let through. Windows needs valid

‎rust/crates/toolchain/src/paths.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub fn normalize(path: &str, platform: &str, case_sensitive: bool) -> Option<Str
2323
&& bytes[2] == b'/'
2424
{
2525
(text[..3].to_owned(), &text[3..])
26-
} else if let Some(unc) = text.strip_prefix("//") {
26+
} else {
27+
// Anything else must be a UNC path: `//server/share/...`.
28+
let unc = text.strip_prefix("//")?;
2729
let mut components = unc.splitn(3, '/');
2830
let server = components.next()?;
2931
let share = components.next()?;
@@ -40,8 +42,6 @@ pub fn normalize(path: &str, platform: &str, case_sensitive: bool) -> Option<Str
4042
format!("//{server}/{share}/"),
4143
components.next().unwrap_or(""),
4244
)
43-
} else {
44-
return None;
4545
}
4646
} else {
4747
("/".to_owned(), text.strip_prefix('/')?)

0 commit comments

Comments
 (0)