Description
I am trying to run architecture tests using cargo_pup_lint_config library and cargo test . No matter what I am presented with the error:
error: no bin target named `cargo-pup` in default-run packages
thread '<thread_name>' (37792) panicked at C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\cargo_pup_lint_config-0.1.7\src\lint_builder_ext.rs:136:13:
cargo pup checks failed!
Preconditions
- Folder
cargo_pup_lint_config-0.1.7 is removed from C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f so it rebuilds before running test
Steps to reproduce issue
cargo new project
cargo add cargo_pup_lint_config --dev
ui.rs
use std::fs;
pub fn ui_stuff() {
let file_path = "config.toml";
let _ = fs::read_to_string(file_path).map_err(|e| format!("Failed to read config file: {}", e));
}
main.rs
mod ui;
fn main() {
ui::ui_stuff();
}
architecture_tests.rs
use cargo_pup_lint_config::{LintBuilder, LintBuilderExt, ModuleLintExt, Severity};
#[test]
fn ui_does_not_depend_on_fs() {
let mut builder = LintBuilder::new();
builder
.module_lint()
.lint_named("ui_does_not_depend_on_fs")
.matching(|m| m.module(".*ui.*"))
.with_severity(Severity::Error)
.restrict_imports(
None,
Some(vec![".*fs.*".to_string()])
)
.build();
builder
.assert_lints(None)
.expect("UI modules should not depend on filesystem modules");
}
cargo test
Expected behavior
error: Use of module 'std::fs' is denied
--> src\ui.rs:1:1
|
1 | use std::fs;
| ^^^^^^^^^^^^
|
= help: Remove this import
= note: Applied by cargo-pup rule 'ui_does_not_depend_on_fs'.
= note: `#[deny(module_restrict_imports)]` on by default
Actual behavior
error: no bin target named `cargo-pup` in default-run packages
thread '<thread_name>' (37792) panicked at C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\cargo_pup_lint_config-0.1.7\src\lint_builder_ext.rs:136:13:
cargo pup checks failed!
Environment
rustc 1.94.1 (e408947bf 2026-03-25)
binary: rustc
commit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1
commit-date: 2026-03-25
host: x86_64-pc-windows-msvc
release: 1.94.1
LLVM version: 21.1.8
cargo_pup_lint_config = "0.1.7"
Proposed fix
I used AI to diagnose and find the error. It proposed this to fix the error and it works.
lint_builder_ext.rs - https://github.com/DataDog/cargo-pup/blob/main/cargo_pup_lint_config/src/lint_builder_ext.rs
// ...
// Line 225
// Before
Ok(current_dir)
// After
anyhow::bail!("Failed to find cargo-pup workspace root");
// ...
Description
I am trying to run architecture tests using
cargo_pup_lint_configlibrary andcargo test. No matter what I am presented with the error:Preconditions
cargo_pup_lint_config-0.1.7is removed fromC:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557fso it rebuilds before running testSteps to reproduce issue
cargo new projectcargo add cargo_pup_lint_config --devui.rsmain.rsarchitecture_tests.rscargo testExpected behavior
Actual behavior
Environment
rustc -Vvcargo_pup_lint_config = "0.1.7"Proposed fix
I used AI to diagnose and find the error. It proposed this to fix the error and it works.
lint_builder_ext.rs- https://github.com/DataDog/cargo-pup/blob/main/cargo_pup_lint_config/src/lint_builder_ext.rs