about summary refs log tree commit diff
path: root/library/std/src/sys_common/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys_common/fs.rs')
-rw-r--r--library/std/src/sys_common/fs.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/library/std/src/sys_common/fs.rs b/library/std/src/sys_common/fs.rs
index 92d0cc60850..30908824dd6 100644
--- a/library/std/src/sys_common/fs.rs
+++ b/library/std/src/sys_common/fs.rs
@@ -4,15 +4,17 @@ use crate::fs;
 use crate::io::{self, Error, ErrorKind};
 use crate::path::Path;
 
+pub(crate) const NOT_FILE_ERROR: Error = Error::new_const(
+    ErrorKind::InvalidInput,
+    &"the source path is neither a regular file nor a symlink to a regular file",
+);
+
 pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
     let mut reader = fs::File::open(from)?;
     let metadata = reader.metadata()?;
 
     if !metadata.is_file() {
-        return Err(Error::new_const(
-            ErrorKind::InvalidInput,
-            &"the source path is not an existing regular file",
-        ));
+        return Err(NOT_FILE_ERROR);
     }
 
     let mut writer = fs::File::create(to)?;