Skip to content

Commit fc33ba5

Browse files
authored
Rollup merge of rust-lang#93897 - schopin-pro:linkchecker-symlink, r=Mark-Simulacrum
linkchecker: fix panic on directory symlinks In Debian and Ubuntu, there are some patches that change the rustc/fonts directory to a symlink to the system fonts. This triggers a latent bug in linkchecker, as the DirEntry filetype isn't a dir but later on the file itself, when opened, is one, triggering an unreachable!() clause. This patch fixes the situation by using std::fs::metadata, which goes through symlinks. I'd have added a test case but `tidy` doesn't seem to like symlinks, and moreover I'm not sure how Git deals with symlinks on Windows. Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
2 parents 71d42a5 + 3a1ffea commit fc33ba5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/tools/linkchecker/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ impl Checker {
182182
fn walk(&mut self, dir: &Path, report: &mut Report) {
183183
for entry in t!(dir.read_dir()).map(|e| t!(e)) {
184184
let path = entry.path();
185-
let kind = t!(entry.file_type());
186-
if kind.is_dir() {
185+
// Goes through symlinks
186+
let metadata = t!(fs::metadata(&path));
187+
if metadata.is_dir() {
187188
self.walk(&path, report);
188189
} else {
189190
self.check(&path, report);

0 commit comments

Comments
 (0)