@@ -61,7 +61,6 @@ impl<'d> Debug for TempFile<'d> {
61
61
62
62
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
63
63
fn new_tempfile_linux ( d : & Dir , anonymous : bool ) -> io:: Result < Option < File > > {
64
- use cap_std:: io_lifetimes:: OwnedFd ;
65
64
use rustix:: fs:: { Mode , OFlags } ;
66
65
// openat's API uses WRONLY. There may be use cases for reading too, so let's
67
66
// support it.
@@ -74,15 +73,13 @@ fn new_tempfile_linux(d: &Dir, anonymous: bool) -> io::Result<Option<File>> {
74
73
let mode = Mode :: from_raw_mode ( 0o666 ) ;
75
74
// Happy path - Linux with O_TMPFILE
76
75
match rustix:: fs:: openat ( d, "." , oflags, mode) {
77
- Ok ( r) => return Ok ( Some ( File :: from ( OwnedFd :: from ( r ) ) ) ) ,
76
+ Ok ( r) => Ok ( Some ( File :: from ( r ) ) ) ,
78
77
// See <https://github.com/Stebalien/tempfile/blob/1a40687e06eb656044e3d2dffa1379f04b3ef3fd/src/file/imp/unix.rs#L81>
79
78
// TODO: With newer Rust versions, this could be simplied to only write `Err` once.
80
79
Err ( rustix:: io:: Errno :: OPNOTSUPP )
81
80
| Err ( rustix:: io:: Errno :: ISDIR )
82
81
| Err ( rustix:: io:: Errno :: NOENT ) => Ok ( None ) ,
83
- Err ( e) => {
84
- return Err ( e. into ( ) ) ;
85
- }
82
+ Err ( e) => Err ( e. into ( ) ) ,
86
83
}
87
84
}
88
85
@@ -92,10 +89,10 @@ fn generate_name_in(subdir: &Dir, f: &File) -> io::Result<String> {
92
89
use rustix:: fd:: AsFd ;
93
90
use rustix:: fs:: AtFlags ;
94
91
let procself_fd = rustix:: io:: proc_self_fd ( ) ?;
95
- let fdnum = rustix:: path:: DecInt :: from_fd ( & f. as_fd ( ) ) ;
92
+ let fdnum = rustix:: path:: DecInt :: from_fd ( f. as_fd ( ) ) ;
96
93
let fdnum = fdnum. as_c_str ( ) ;
97
94
super :: retry_with_name_ignoring ( io:: ErrorKind :: AlreadyExists , |name| {
98
- rustix:: fs:: linkat ( & procself_fd, fdnum, subdir, name, AtFlags :: SYMLINK_FOLLOW )
95
+ rustix:: fs:: linkat ( procself_fd, fdnum, subdir, name, AtFlags :: SYMLINK_FOLLOW )
99
96
. map_err ( Into :: into)
100
97
} )
101
98
. map ( |( _, name) | name)
0 commit comments