@@ -52,7 +52,7 @@ pub enum CpError {
52
52
IoErr ( #[ from] io:: Error ) ,
53
53
54
54
/// Wrapper for io::Error with path context
55
- #[ error( "Reading from input {1} gave error " ) ]
55
+ #[ error( "{1}: {0} " ) ]
56
56
IoErrContext ( io:: Error , String ) ,
57
57
58
58
/// General copy error
@@ -69,7 +69,7 @@ pub enum CpError {
69
69
WalkDirErr ( #[ from] walkdir:: Error ) ,
70
70
71
71
/// Simple std::path::StripPrefixError wrapper
72
- #[ error( "{0}" ) ]
72
+ #[ error( transparent ) ]
73
73
StripPrefixError ( #[ from] StripPrefixError ) ,
74
74
75
75
/// Result of a skipped file
@@ -1789,19 +1789,19 @@ fn symlink_file(
1789
1789
) -> CopyResult < ( ) > {
1790
1790
#[ cfg( not( windows) ) ]
1791
1791
{
1792
- std:: os:: unix:: fs:: symlink ( source, dest) . map_err ( |_ | CpError :: Error ( format ! (
1792
+ std:: os:: unix:: fs:: symlink ( source, dest) . map_err ( |e | CpError :: IoErrContext ( e , format ! (
1793
1793
"cannot create symlink {} to {}" ,
1794
1794
get_filename( dest) . unwrap_or( "invalid file name" ) . quote( ) ,
1795
1795
get_filename( source) . unwrap_or( "invalid file name" ) . quote( )
1796
1796
) ) ) ?;
1797
1797
}
1798
1798
#[ cfg( windows) ]
1799
1799
{
1800
- std:: os:: windows:: fs:: symlink_file ( source, dest) . context ( format ! (
1800
+ std:: os:: windows:: fs:: symlink_file ( source, dest) . map_err ( |e| CpError :: IoErrContext ( e , format ! (
1801
1801
"cannot create symlink {} to {}" ,
1802
1802
get_filename( dest) . unwrap_or( "invalid file name" ) . quote( ) ,
1803
1803
get_filename( source) . unwrap_or( "invalid file name" ) . quote( )
1804
- ) ) ?;
1804
+ ) ) ) ?;
1805
1805
}
1806
1806
if let Ok ( file_info) = FileInformation :: from_path ( dest, false ) {
1807
1807
symlinked_files. insert ( file_info) ;
@@ -1976,7 +1976,7 @@ fn delete_dest_if_needed_and_allowed(
1976
1976
& FileInformation :: from_path (
1977
1977
source,
1978
1978
options. dereference ( source_in_command_line)
1979
- ) . map_err ( |_ | CpError :: Error ( format ! ( "cannot stat {}" , source. quote( ) ) ) ) ?
1979
+ ) . map_err ( |e | CpError :: IoErrContext ( e , format ! ( "cannot stat {}" , source. quote( ) ) ) ) ?
1980
1980
)
1981
1981
}
1982
1982
}
@@ -2117,7 +2117,7 @@ fn handle_copy_mode(
2117
2117
} else {
2118
2118
fs:: hard_link ( source, dest)
2119
2119
}
2120
- . map_err ( |_ | CpError :: Error ( format ! (
2120
+ . map_err ( |e | CpError :: IoErrContext ( e , format ! (
2121
2121
"cannot create hard link {} to {}" ,
2122
2122
get_filename( dest) . unwrap_or( "invalid file name" ) . quote( ) ,
2123
2123
get_filename( source) . unwrap_or( "invalid file name" ) . quote( )
@@ -2397,7 +2397,7 @@ fn copy_file(
2397
2397
// in the destination tree.
2398
2398
if let Some ( new_source) = copied_files. get (
2399
2399
& FileInformation :: from_path ( source, options. dereference ( source_in_command_line) )
2400
- . map_err ( |_ | CpError :: Error ( format ! ( "cannot stat {}" , source. quote( ) ) ) ) ?,
2400
+ . map_err ( |e | CpError :: IoErrContext ( e , format ! ( "cannot stat {}" , source. quote( ) ) ) ) ?,
2401
2401
) {
2402
2402
fs:: hard_link ( new_source, dest) ?;
2403
2403
0 commit comments