@@ -5,26 +5,26 @@ use std::fs::{File, remove_file};
55use  std:: io:: { Read ,  Write } ; 
66
77fn  main ( )  { 
8-     let  path = "miri_test_fs.txt" ; 
8+     let  path = std :: env :: temp_dir ( ) . join ( "miri_test_fs.txt" ) ; 
99    let  bytes = b"Hello, World!\n " ; 
1010    // Test creating, writing and closing a file (closing is tested when `file` is dropped). 
11-     let  mut  file = File :: create ( path) . unwrap ( ) ; 
11+     let  mut  file = File :: create ( & path) . unwrap ( ) ; 
1212    // Writing 0 bytes should not change the file contents. 
1313    file. write ( & mut  [ ] ) . unwrap ( ) ; 
1414
1515    file. write ( bytes) . unwrap ( ) ; 
1616    // Test opening, reading and closing a file. 
17-     let  mut  file = File :: open ( path) . unwrap ( ) ; 
17+     let  mut  file = File :: open ( & path) . unwrap ( ) ; 
1818    let  mut  contents = Vec :: new ( ) ; 
1919    // Reading 0 bytes should not move the file pointer. 
2020    file. read ( & mut  [ ] ) . unwrap ( ) ; 
2121    // Reading until EOF should get the whole text. 
2222    file. read_to_end ( & mut  contents) . unwrap ( ) ; 
2323    assert_eq ! ( bytes,  contents. as_slice( ) ) ; 
2424    // Removing file should succeed 
25-     remove_file ( path) . unwrap ( ) ; 
25+     remove_file ( & path) . unwrap ( ) ; 
2626    // Opening non-existing file should fail 
27-     assert ! ( File :: open( path) . is_err( ) ) ; 
27+     assert ! ( File :: open( & path) . is_err( ) ) ; 
2828    // Removing non-existing file should fail 
29-     assert ! ( remove_file( path) . is_err( ) ) ; 
29+     assert ! ( remove_file( & path) . is_err( ) ) ; 
3030} 
0 commit comments