Skip to content

Commit ed1088e

Browse files
committed
Use track_caller more for better error spans in clippy_dev
1 parent 46ff0a8 commit ed1088e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

clippy_dev/src/utils.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ pub struct FileUpdater {
338338
dst_buf: String,
339339
}
340340
impl FileUpdater {
341+
#[track_caller]
341342
fn update_file_checked_inner(
342343
&mut self,
343344
tool: &str,
@@ -361,6 +362,7 @@ impl FileUpdater {
361362
}
362363
}
363364

365+
#[track_caller]
364366
fn update_file_inner(&mut self, path: &Path, update: &mut dyn FnMut(&Path, &str, &mut String) -> UpdateStatus) {
365367
let mut file = File::open(path, OpenOptions::new().read(true).write(true));
366368
file.read_to_cleared_string(&mut self.src_buf);
@@ -370,6 +372,7 @@ impl FileUpdater {
370372
}
371373
}
372374

375+
#[track_caller]
373376
pub fn update_file_checked(
374377
&mut self,
375378
tool: &str,
@@ -380,6 +383,7 @@ impl FileUpdater {
380383
self.update_file_checked_inner(tool, mode, path.as_ref(), update);
381384
}
382385

386+
#[track_caller]
383387
pub fn update_file(
384388
&mut self,
385389
path: impl AsRef<Path>,
@@ -598,6 +602,7 @@ impl<'txt> RustSearcher<'txt> {
598602
}
599603
}
600604

605+
#[track_caller]
601606
#[expect(clippy::must_use_candidate)]
602607
pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
603608
match OpenOptions::new().create_new(true).write(true).open(new_name) {
@@ -620,6 +625,7 @@ pub fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
620625
}
621626
}
622627

628+
#[track_caller]
623629
#[expect(clippy::must_use_candidate)]
624630
pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
625631
match fs::create_dir(new_name) {
@@ -646,10 +652,12 @@ pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
646652
}
647653
}
648654

655+
#[track_caller]
649656
pub fn write_file(path: &Path, contents: &str) {
650657
expect_action(fs::write(path, contents), ErrAction::Write, path);
651658
}
652659

660+
#[track_caller]
653661
pub fn run_exit_on_err(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) {
654662
match expect_action(cmd.status(), ErrAction::Run, path.as_ref()).code() {
655663
Some(0) => {},
@@ -661,6 +669,7 @@ pub fn run_exit_on_err(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) {
661669
}
662670
}
663671

672+
#[track_caller]
664673
#[must_use]
665674
pub fn run_with_output(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) -> Vec<u8> {
666675
fn f(path: &Path, cmd: &mut Command) -> Vec<u8> {
@@ -746,6 +755,7 @@ pub fn split_args_for_threads(
746755
}
747756
}
748757

758+
#[track_caller]
749759
#[expect(clippy::must_use_candidate)]
750760
pub fn delete_file_if_exists(path: &Path) -> bool {
751761
match fs::remove_file(path) {
@@ -755,6 +765,7 @@ pub fn delete_file_if_exists(path: &Path) -> bool {
755765
}
756766
}
757767

768+
#[track_caller]
758769
pub fn delete_dir_if_exists(path: &Path) {
759770
match fs::remove_dir_all(path) {
760771
Ok(()) => {},

0 commit comments

Comments
 (0)