Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 43 files
+1 −1 .github/workflows/main.yml
+3 −2 Cargo.lock
+1 −0 crates/cargo-util-terminal/Cargo.toml
+15 −0 crates/cargo-util-terminal/src/shell.rs
+2 −0 crates/cargo-util/src/paths.rs
+0 −53 doc/book/src/reference/lints.md
+1 −0 etc/_cargo
+1 −1 src/compiler/compilation.rs
+3 −3 src/compiler/fingerprint/rustdoc.rs
+8 −2 src/compiler/mod.rs
+1 −1 src/compiler/timings/mod.rs
+0 −361 src/diagnostics/rules/implicit_minimum_version_req.rs
+0 −10 src/diagnostics/rules/mod.rs
+10 −4 src/diagnostics/rules/unused_dependencies.rs
+2 −3 src/ops/cargo_doc.rs
+42 −7 src/ops/cargo_report/timings.rs
+72 −0 src/resolver/errors.rs
+33 −9 src/sources/git/utils.rs
+22 −14 src/sources/path.rs
+2 −2 src/sources/registry/download.rs
+13 −17 src/sources/registry/git_remote.rs
+2 −2 src/sources/registry/index/cache.rs
+4 −4 src/sources/registry/index/mod.rs
+5 −5 src/sources/registry/mod.rs
+24 −3 src/util/errors.rs
+2 −2 src/util/network/retry.rs
+8 −16 src/util/progress.rs
+16 −1 src/workspace/features.rs
+16 −0 src/workspace/parser/mod.rs
+107 −0 tests/testsuite/build.rs
+2 −20 tests/testsuite/cargo_add/invalid_path/stderr.term.svg
+77 −0 tests/testsuite/cargo_report_timings/mod.rs
+31 −31 tests/testsuite/doc.rs
+265 −4 tests/testsuite/git.rs
+1 −4 tests/testsuite/install.rs
+0 −1,187 tests/testsuite/lints/implicit_minimum_version_req.rs
+8 −10 tests/testsuite/lints/mod.rs
+9 −9 tests/testsuite/lints/unknown_lints.rs
+67 −7 tests/testsuite/lints_table.rs
+141 −41 tests/testsuite/path.rs
+4 −2 tests/testsuite/profile_trim_paths.rs
+81 −0 tests/testsuite/timings.rs
+3 −13 tests/testsuite/workspaces.rs
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc};
// Path-related helpers.
pub use crate::path_helpers::{
build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
has_suffix, not_contains, path, recursive_find_files, shallow_find_directories,
shallow_find_files, source_root,
};
// Convenience helpers for running binaries and other commands.
pub use crate::run::{cmd, run, run_fail, run_with_args};
Expand Down
24 changes: 24 additions & 0 deletions src/tools/run-make-support/src/path_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
matching_files
}

/// Browse the directory `path` recursively and return all files which respect the parameters
/// outlined by `closure`.
#[track_caller]
pub fn recursive_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
path: P,
filter: F,
) -> Vec<PathBuf> {
let mut matching_files = Vec::new();
let mut stack = vec![path.as_ref().to_path_buf()];
while let Some(dir) = stack.pop() {
for entry in rfs::read_dir(dir) {
let entry = entry.expect("failed to read directory entry.");
let path = entry.path();

if path.is_dir() {
stack.push(path);
} else if path.is_file() && filter(&path) {
matching_files.push(path);
}
}
}
matching_files
}

/// Browse the directory `path` non-recursively and return all directories which respect the
/// parameters outlined by `closure`.
#[track_caller]
Expand Down
24 changes: 10 additions & 14 deletions tests/run-make-cargo/compiler-builtins/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::collections::HashSet;
use run_make_support::object::read::Object;
use run_make_support::object::read::archive::ArchiveFile;
use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget};
use run_make_support::rfs::{read, read_dir};
use run_make_support::{cargo, object, path, target};
use run_make_support::rfs::read;
use run_make_support::{cargo, object, path, recursive_find_files, target};

fn main() {
let target_dir = path("target");
Expand All @@ -44,18 +44,14 @@ fn main() {
.env("LIB", std::env::var("LIB").unwrap_or_default())
.run();

let rlibs_path = target_dir.join(target()).join("debug").join("deps");
let compiler_builtins_rlib = read_dir(rlibs_path)
.find_map(|e| {
let path = e.unwrap().path();
let file_name = path.file_name().unwrap().to_str().unwrap();
if file_name.starts_with("libcompiler_builtins") && file_name.ends_with(".rlib") {
Some(path)
} else {
None
}
})
.unwrap();
// The rlib file is emitted as an intermediate build artifacts.
// Do not hardcode the path.
let mut rlibs = recursive_find_files(&target_dir.join(target()).join("debug"), |path| {
let file_name = path.file_name().unwrap().to_str().unwrap();
file_name.starts_with("libcompiler_builtins") && file_name.ends_with(".rlib")
});
assert_eq!(rlibs.len(), 1, "expected exactly one compiler_builtins rlib: {rlibs:?}");

@weihanglo weihanglo Jul 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length assertion should guard us well to only get the one and only artifact.

View changes since the review

let compiler_builtins_rlib = rlibs.pop().unwrap();

// rlib files are archives, where the archive members each a CGU, and we also have one called
// lib.rmeta which is the encoded metadata. Each of the CGUs is an object file.
Expand Down
22 changes: 9 additions & 13 deletions tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#![deny(warnings)]

use run_make_support::{cargo, llvm_filecheck, path, rfs, target};
use run_make_support::{cargo, llvm_filecheck, path, recursive_find_files, target};

fn main() {
let target_dir = path("target");
Expand All @@ -29,18 +29,14 @@ fn main() {
.env("LIB", std::env::var("LIB").unwrap_or_default())
.run();

let out_dir = target_dir.join(target()).join("release").join("deps");
let ir_file = rfs::read_dir(out_dir)
.find_map(|e| {
let path = e.unwrap().path();
let file_name = path.file_name().unwrap().to_str().unwrap();
if file_name.starts_with("panic_scenarios") && file_name.ends_with(".ll") {
Some(path)
} else {
None
}
})
.unwrap();
// The .ll file is emitted as an intermediate build artifacts.
// Do not hardcode the path.
let mut ir_files = recursive_find_files(&target_dir.join(target()).join("release"), |path| {
let file_name = path.file_name().unwrap().to_str().unwrap();
file_name.starts_with("panic_scenarios") && file_name.ends_with(".ll")
});
assert_eq!(ir_files.len(), 1, "expected exactly one .ll file: {ir_files:?}");
let ir_file = ir_files.pop().unwrap();

llvm_filecheck().patterns("lib.rs").input_file(ir_file).run();
}
Loading