From 1f624d4c2a4ee0441ffce842591a8e37e329d309 Mon Sep 17 00:00:00 2001 From: Ali Bektas Date: Thu, 12 Sep 2024 15:26:40 +0200 Subject: [PATCH 1/2] Add rust-analyzer.toml file --- dev-rust-analyzer.toml | 4 ++++ src/init.rs | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 dev-rust-analyzer.toml diff --git a/dev-rust-analyzer.toml b/dev-rust-analyzer.toml new file mode 100644 index 00000000..b0b88fae --- /dev/null +++ b/dev-rust-analyzer.toml @@ -0,0 +1,4 @@ +# rust-analyzer configuration file +# DO NOT edit what is already defined. +# You may add new configurations as needed. +check.extraArgs = ["--profile", "test"] diff --git a/src/init.rs b/src/init.rs index 332bf52e..24dcfa68 100644 --- a/src/init.rs +++ b/src/init.rs @@ -130,6 +130,10 @@ pub fn init() -> Result<()> { fs::write("Cargo.toml", updated_cargo_toml) .context("Failed to create the file `rustlings/Cargo.toml`")?; + let ra_toml = include_str!("../dev-rust-analyzer.toml"); + fs::write("rust-analyzer.toml", ra_toml) + .context("Failed to create the file `rustlings/rust-analyzer.toml`")?; + fs::write(".gitignore", GITIGNORE) .context("Failed to create the file `rustlings/.gitignore`")?; From 88e10a9e54eb06217a3c45d330b6a3ba66577b01 Mon Sep 17 00:00:00 2001 From: Ali Bektas Date: Thu, 12 Sep 2024 15:46:09 +0200 Subject: [PATCH 2/2] hardcode ratoml in init.rs --- dev-rust-analyzer.toml | 4 ---- src/init.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 dev-rust-analyzer.toml diff --git a/dev-rust-analyzer.toml b/dev-rust-analyzer.toml deleted file mode 100644 index b0b88fae..00000000 --- a/dev-rust-analyzer.toml +++ /dev/null @@ -1,4 +0,0 @@ -# rust-analyzer configuration file -# DO NOT edit what is already defined. -# You may add new configurations as needed. -check.extraArgs = ["--profile", "test"] diff --git a/src/init.rs b/src/init.rs index 24dcfa68..63224325 100644 --- a/src/init.rs +++ b/src/init.rs @@ -130,8 +130,7 @@ pub fn init() -> Result<()> { fs::write("Cargo.toml", updated_cargo_toml) .context("Failed to create the file `rustlings/Cargo.toml`")?; - let ra_toml = include_str!("../dev-rust-analyzer.toml"); - fs::write("rust-analyzer.toml", ra_toml) + fs::write("rust-analyzer.toml", RATOML) .context("Failed to create the file `rustlings/rust-analyzer.toml`")?; fs::write(".gitignore", GITIGNORE) @@ -173,6 +172,11 @@ const INIT_SOLUTION_FILE: &[u8] = b"fn main() { } "; +const RATOML: &[u8] = br#"# rust-analyzer configuration file +# DO NOT edit what is already defined. +# You may add new configurations as needed. +check.extraArgs = ["--profile", "test"]"#; + const GITIGNORE: &[u8] = b"Cargo.lock target/ .vscode/