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 explicitly avoid doing so by
calling fstat(2) on a fd 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 be avoided under certain
circumstances.  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.

Fix #12460

Signed-off-by: NODA, Kai <nodakai@gmail.com>