Fix panic when canonicalizing a nonexistent path

This commit is contained in:
Eli Youngs 2022-02-08 20:19:13 -08:00
parent 47b12b31a6
commit 6e0fedc277

View file

@ -299,9 +299,8 @@ pub fn canonicalize<P: AsRef<Path>>(
let original = if original.is_absolute() {
original.to_path_buf()
} else {
dunce::canonicalize(env::current_dir().unwrap())
.unwrap()
.join(original)
let current_dir = env::current_dir()?;
dunce::canonicalize(current_dir)?.join(original)
};
let mut result = PathBuf::new();