Skip to content

Commit 2488606

Browse files
committed
fix gen_rust_project
1 parent b01a800 commit 2488606

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tools/rust_analyzer/bin/gen_rust_project.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
env,
3-
fs::File,
3+
fs::OpenOptions,
44
io::{BufWriter, ErrorKind},
55
};
66

@@ -36,11 +36,14 @@ fn write_rust_project(
3636
}
3737

3838
// Write the new rust-project.json file.
39-
let file = File::open(rust_project_path)
40-
.with_context(|| "could not open: {rust_project_path}")
39+
let file = OpenOptions::new()
40+
.write(true)
41+
.create(true)
42+
.open(rust_project_path)
43+
.with_context(|| format!("could not open: {rust_project_path}"))
4144
.map(BufWriter::new)?;
42-
serde_json::to_writer(file, &rust_project)?;
4345

46+
serde_json::to_writer(file, &rust_project)?;
4447
Ok(())
4548
}
4649

0 commit comments

Comments
 (0)