Non-panicking Display for Path
This commit is contained in:
parent
d6d9e76240
commit
5230e8fbe6
@ -341,10 +341,10 @@ fn format(
|
|||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
eprintln!("Error: file `{}` does not exist", file.to_str().unwrap());
|
eprintln!("Error: file `{}` does not exist", file.display());
|
||||||
session.add_operational_error();
|
session.add_operational_error();
|
||||||
} else if file.is_dir() {
|
} else if file.is_dir() {
|
||||||
eprintln!("Error: `{}` is a directory", file.to_str().unwrap());
|
eprintln!("Error: `{}` is a directory", file.display());
|
||||||
session.add_operational_error();
|
session.add_operational_error();
|
||||||
} else {
|
} else {
|
||||||
// Check the file directory if the config-path could not be read or not provided
|
// Check the file directory if the config-path could not be read or not provided
|
||||||
|
@ -38,7 +38,7 @@ impl From<rustc_span::FileName> for FileName {
|
|||||||
impl fmt::Display for FileName {
|
impl fmt::Display for FileName {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
FileName::Real(p) => write!(f, "{}", p.to_str().unwrap()),
|
FileName::Real(p) => write!(f, "{}", p.display()),
|
||||||
FileName::Stdin => write!(f, "<stdin>"),
|
FileName::Stdin => write!(f, "<stdin>"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,10 +105,9 @@ fn is_file_skip(path: &Path) -> bool {
|
|||||||
fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
|
fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
|
||||||
let mut files = vec![];
|
let mut files = vec![];
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
for entry in fs::read_dir(path).expect(&format!(
|
for entry in
|
||||||
"couldn't read directory {}",
|
fs::read_dir(path).expect(&format!("couldn't read directory {}", path.display()))
|
||||||
path.to_str().unwrap()
|
{
|
||||||
)) {
|
|
||||||
let entry = entry.expect("couldn't get `DirEntry`");
|
let entry = entry.expect("couldn't get `DirEntry`");
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.is_dir() && recursive {
|
if path.is_dir() && recursive {
|
||||||
@ -122,10 +121,7 @@ fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn verify_config_used(path: &Path, config_name: &str) {
|
fn verify_config_used(path: &Path, config_name: &str) {
|
||||||
for entry in fs::read_dir(path).expect(&format!(
|
for entry in fs::read_dir(path).expect(&format!("couldn't read {} directory", path.display())) {
|
||||||
"couldn't read {} directory",
|
|
||||||
path.to_str().unwrap()
|
|
||||||
)) {
|
|
||||||
let entry = entry.expect("couldn't get directory entry");
|
let entry = entry.expect("couldn't get directory entry");
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.extension().map_or(false, |f| f == "rs") {
|
if path.extension().map_or(false, |f| f == "rs") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user