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.
Sorry to be somewhat nitpickity, but could you move this to `std::io` instead? We're generally trying to keep the `std::sys` bindings a low-level as possible (no worries about cross-platform errors like this) while pushing the compatibility layer to `std::io` instead.