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.

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".

Fix #12460

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