rust-lang/rust — pull request #19303 by nodakai (2014-11-25 14:37:04+00:00)
Title: libsyntax/parse: avoid reading directories as files on *BSD

On *BSD systems, we can `open(2)` a directory and directly `read(2)` from it due to an old tradition. We should avoid doing so by explicitly calling `fstat(2)` to check the type of the opened file.

To do so, it was necessary to elide unnecessary mutability of `&self` in `io::fs::File::stat()`.

Opening a directory as a module file can't always be avoided. Even when there's no "path" attribute trick involved, a *directory* can always be named as `my_module.rs`.

Incidentally, elide unnecessary `Path::clone()` in libsyntax.