Where this was done already, in `bail!` and `anyhow!`. A newly enforced clippy lint warns about this, making the good point that the debug representation can change in the future. But the display representation it recommends using is less suitable in these places, because it can result in more ambiguous output due to the absence of quoting and escaping. (In some cases, it seems like the display representation could slightly exacerbate CVE-2024-43785 / #1534, but using the debug representation on these two macro calls is peripheral to the cases of greatest concern, and this doesn't really mitigate that.) The clippy lint being suppressed here in two specific places is: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_debug_formatting
Unified · Split
| @@ -114,6 +114,7 @@ pub(crate) mod function { · 113 unmodified lines | ||
| 114 | 114 | }; |
| 115 | 115 | let work_dir = ignore |
| 116 | 116 | .then(|| { |
| 117 | + #[allow(clippy::unnecessary_debug_formatting)] | |
| 117 | 118 | repo.workdir() |
| 118 | 119 | .map(ToOwned::to_owned) |
| 119 | 120 | .ok_or_else(|| anyhow!("repository at {:?} must have a worktree checkout", repo.path())) |
| @@ -51,6 +51,7 @@ pub fn from_list( · 50 unmodified lines | ||
| 51 | 51 | let mut index = gix::index::State::new(object_hash); |
| 52 | 52 | for path in std::io::BufReader::new(std::fs::File::open(entries_file)?).lines() { |
| 53 | 53 | let path: PathBuf = path?.into(); |
| 54 | + #[allow(clippy::unnecessary_debug_formatting)] | |
| 54 | 55 | if !path.is_relative() { |
| 55 | 56 | bail!("Input paths need to be relative, but {path:?} is not.") |
| 56 | 57 | } |