Skip to content

Commit 5fe262f

Browse files
authored
fix: update Rust and fix clippy lints (#408)
1 parent c3ca334 commit 5fe262f

File tree

15 files changed

+101
-120
lines changed

15 files changed

+101
-120
lines changed

crates/pixi-build-backend/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async fn build<T: ProtocolInstantiator>(factory: T, manifest_path: &Path) -> mie
285285
eprintln!("Successfully build '{}'", package.output_file.display());
286286
eprintln!("Use following globs to revalidate: ");
287287
for glob in package.input_globs {
288-
eprintln!(" - {}", glob);
288+
eprintln!(" - {glob}");
289289
}
290290
}
291291

crates/pixi-build-backend/src/compilers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Display for Language<'_> {
2727
Language::Cxx => write!(f, "cxx"),
2828
Language::Fortran => write!(f, "fortran"),
2929
Language::Rust => write!(f, "rust"),
30-
Language::Other(name) => write!(f, "{}", name),
30+
Language::Other(name) => write!(f, "{name}"),
3131
}
3232
}
3333
}
@@ -116,7 +116,7 @@ pub fn add_compilers_to_requirements(
116116

117117
if !resolved_build_requirements.contains_key(&PackageName::new_unchecked(language_compiler))
118118
{
119-
let template = format!("${{{{ compiler('{}') }}}}", compiler_str);
119+
let template = format!("${{{{ compiler('{compiler_str}') }}}}");
120120
requirements.push(Item::Value(Value::Template(template)));
121121
}
122122
}
@@ -151,7 +151,7 @@ pub fn add_stdlib_to_requirements(
151151
}
152152

153153
// If the stdlib key exists, add it to the requirements
154-
let template = format!("${{{{ stdlib('{}') }}}}", stdlib);
154+
let template = format!("${{{{ stdlib('{stdlib}') }}}}");
155155
requirements.push(Item::Value(Value::Template(template)));
156156
}
157157
}

crates/pixi-build-backend/src/tools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ pub fn output_directory(
384384
[0..placeholder_length - build_dir.join("host_env").as_os_str().len()]
385385
.to_string();
386386

387-
build_dir.join(format!("host_env{}", placeholder))
387+
build_dir.join(format!("host_env{placeholder}"))
388388
};
389389

390390
Directories {

crates/pixi-build-backend/tests/integration/common/model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ pub(crate) fn load_project_model_from_json(filename: &str) -> TestProjectModel {
8888
.join(filename);
8989

9090
let json_content = std::fs::read_to_string(&fixture_path)
91-
.unwrap_or_else(|e| panic!("Failed to read JSON fixture '{}': {}", filename, e));
91+
.unwrap_or_else(|e| panic!("Failed to read JSON fixture '{filename}': {e}"));
9292

9393
serde_json::from_str(&json_content)
94-
.unwrap_or_else(|e| panic!("Failed to parse JSON fixture '{}': {}", filename, e))
94+
.unwrap_or_else(|e| panic!("Failed to parse JSON fixture '{filename}': {e}"))
9595
}
9696

9797
/// Converts a TestProjectModel into a ProjectModelV1

crates/pixi-build-mojo/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ mod tests {
439439
// Check for mojo-compiler package (should be present)
440440
let has_mojo_compiler = build_reqs
441441
.iter()
442-
.any(|item| format!("{:?}", item).contains("mojo-compiler"));
442+
.any(|item| format!("{item:?}").contains("mojo-compiler"));
443443
assert!(has_mojo_compiler, "Should have mojo-compiler package");
444444

445445
// Check for additional compiler templates
@@ -517,7 +517,7 @@ mod tests {
517517
// Check for mojo-compiler package (should be present by default)
518518
let has_mojo_compiler = build_reqs
519519
.iter()
520-
.any(|item| format!("{:?}", item).contains("mojo-compiler"));
520+
.any(|item| format!("{item:?}").contains("mojo-compiler"));
521521
assert!(
522522
has_mojo_compiler,
523523
"Should have mojo-compiler package by default"
@@ -582,7 +582,7 @@ mod tests {
582582
// Check for mojo-compiler package (should NOT be present)
583583
let has_mojo_compiler = build_reqs
584584
.iter()
585-
.any(|item| format!("{:?}", item).contains("mojo-compiler"));
585+
.any(|item| format!("{item:?}").contains("mojo-compiler"));
586586
assert!(
587587
!has_mojo_compiler,
588588
"Should NOT have mojo-compiler package when user opts out"

crates/pixi-build-python/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl GenerateRecipe for PythonGenerator {
105105
// Helper function to get Python requirement spec
106106
let get_python_requirement = || -> miette::Result<recipe::Item<PackageDependency>> {
107107
let python_requirement_str = match pyproject_metadata_provider.requires_python() {
108-
Ok(Some(requires_python)) => format!("python {}", requires_python),
108+
Ok(Some(requires_python)) => format!("python {requires_python}"),
109109
_ => "python".to_string(),
110110
};
111111
python_requirement_str.parse().into_diagnostic()

crates/pixi-build-python/src/metadata.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,7 @@ version = "not.a.valid.version.at.all"
444444
Err(MetadataError::PyProjectToml(_)) => {
445445
// This is expected - invalid version in pyproject.toml
446446
}
447-
other => panic!(
448-
"Expected PyProjectTomlError for invalid version, got: {:?}",
449-
other
450-
),
447+
other => panic!("Expected PyProjectTomlError for invalid version, got: {other:?}"),
451448
}
452449
}
453450

@@ -466,7 +463,7 @@ version = "1.0.0"
466463
assert!(result.is_err());
467464
match result.unwrap_err() {
468465
MetadataError::PyProjectToml(_) => {}
469-
err => panic!("Expected PyProjectToml, got: {:?}", err),
466+
err => panic!("Expected PyProjectToml, got: {err:?}"),
470467
}
471468
}
472469

@@ -626,13 +623,11 @@ requires-python = ">=3.13"
626623

627624
assert!(
628625
has_python_constraint_host,
629-
"Host requirements should include 'python >=3.13', found: {:?}",
630-
host_requirements
626+
"Host requirements should include 'python >=3.13', found: {host_requirements:?}"
631627
);
632628
assert!(
633629
has_python_constraint_run,
634-
"Run requirements should include 'python >=3.13', found: {:?}",
635-
run_requirements
630+
"Run requirements should include 'python >=3.13', found: {run_requirements:?}"
636631
);
637632
}
638633
}

crates/pixi-build-rattler-build/src/protocol.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,8 +1369,7 @@ mod tests {
13691369
for extra_glob in &extra_globs {
13701370
assert!(
13711371
globs.contains(extra_glob),
1372-
"Result should contain extra glob: {}",
1373-
extra_glob
1372+
"Result should contain extra glob: {extra_glob}"
13741373
);
13751374
}
13761375

crates/pixi-build-rust/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ mod tests {
215215
for extra_glob in &config.extra_input_globs {
216216
assert!(
217217
result.contains(extra_glob),
218-
"Result should contain extra glob: {}",
219-
extra_glob
218+
"Result should contain extra glob: {extra_glob}"
220219
);
221220
}
222221

crates/pixi-build-rust/src/metadata.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,7 @@ mod tests {
395395
// This is expected when workspace inheritance fails due to
396396
// missing workspace
397397
}
398-
_ => panic!(
399-
"Expected MissingInheritedValue or CargoTomlError, got: {:?}",
400-
error
401-
),
398+
_ => panic!("Expected MissingInheritedValue or CargoTomlError, got: {error:?}"),
402399
}
403400
}
404401

@@ -417,10 +414,7 @@ mod tests {
417414
// This is expected when workspace inheritance fails due to
418415
// missing workspace
419416
}
420-
_ => panic!(
421-
"Expected MissingInheritedValue or CargoTomlError, got: {:?}",
422-
error
423-
),
417+
_ => panic!("Expected MissingInheritedValue or CargoTomlError, got: {error:?}"),
424418
}
425419
}
426420

@@ -672,8 +666,7 @@ version.workspace = true
672666
assert_eq!(
673667
globs.len(),
674668
1,
675-
"Expected only Cargo.toml glob when workspace is in same file, got: {:?}",
676-
globs
669+
"Expected only Cargo.toml glob when workspace is in same file, got: {globs:?}"
677670
);
678671
}
679672

@@ -723,8 +716,7 @@ description.workspace = true
723716
// is detected
724717
assert!(
725718
globs.len() >= 2,
726-
"Expected at least 2 globs when workspace is in separate file, got: {:?}",
727-
globs
719+
"Expected at least 2 globs when workspace is in separate file, got: {globs:?}"
728720
);
729721

730722
// Check that a workspace-related glob pattern is included
@@ -733,8 +725,7 @@ description.workspace = true
733725
.any(|glob| glob.contains("../Cargo.toml") && glob != "Cargo.toml");
734726
assert!(
735727
has_workspace_glob,
736-
"Expected workspace glob pattern, got: {:?}",
737-
globs
728+
"Expected workspace glob pattern, got: {globs:?}"
738729
);
739730
}
740731

@@ -756,8 +747,7 @@ version = "1.0.0"
756747
assert_eq!(
757748
globs.len(),
758749
1,
759-
"Expected exactly 1 glob when no workspace is present, got: {:?}",
760-
globs
750+
"Expected exactly 1 glob when no workspace is present, got: {globs:?}"
761751
);
762752
assert!(globs.contains("Cargo.toml"));
763753

@@ -767,8 +757,7 @@ version = "1.0.0"
767757
.any(|glob| glob.contains("**/Cargo.toml") && glob != "Cargo.toml");
768758
assert!(
769759
!has_workspace_glob,
770-
"No workspace globs should be present when no workspace inheritance occurs, got: {:?}",
771-
globs
760+
"No workspace globs should be present when no workspace inheritance occurs, got: {globs:?}"
772761
);
773762
}
774763

@@ -804,8 +793,7 @@ description = "Direct package values"
804793
assert_eq!(
805794
globs.len(),
806795
1,
807-
"Expected exactly 1 glob when workspace exists but no inheritance is used, got: {:?}",
808-
globs
796+
"Expected exactly 1 glob when workspace exists but no inheritance is used, got: {globs:?}"
809797
);
810798
assert!(globs.contains("Cargo.toml"));
811799
}
@@ -857,7 +845,7 @@ version = "not.a.valid.version.at.all"
857845
Err(MetadataError::ParseVersionError(_)) => {
858846
// This is the expected error case
859847
}
860-
other => panic!("Unexpected result: {:?}", other),
848+
other => panic!("Unexpected result: {other:?}"),
861849
}
862850
}
863851

@@ -876,7 +864,7 @@ version = "1.0.0"
876864
assert!(result.is_err());
877865
match result.unwrap_err() {
878866
MetadataError::CargoTomlError(_) => {}
879-
err => panic!("Expected CargoTomlError, got: {:?}", err),
867+
err => panic!("Expected CargoTomlError, got: {err:?}"),
880868
}
881869
}
882870
}

0 commit comments

Comments
 (0)