Fix usage of rustc --ls on invalid files

Closes #11259