rust-lang / rust-lang/rust-analyzer
Allow to pass arguments to the check that disable debug_assertions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Right now, with a code such as:
fn check_multiple_instances() -> Result<HANDLE>{
#[cfg(not(debug_assertions))]
unsafe {
let handle = CreateMutexW(None, false, w!("MyAppMutex-Instance"))?;
match WaitForSingleObject(handle, 0) {
WAIT_TIMEOUT => panic!("Another instance is running"),
WAIT_FAILED => {
panic!("{:?}",GetLastError().unwrap_err().message());
},
_ => println!("We got the onwership of the mutex"),
}
Ok(handle)
}
#[cfg(debug_assertions)]
Ok(HANDLE(0))
}
The rust analyzer states that the whole unsafe scope is not used and grayed out. If all the release code wants to be edited, there is no way to make rust analyzer disable the debug_assertions configuration. Even passing the --release/-r flag in cargo check does not seem to work and the code is still analyzed as if it was a debug build (I guess the debug profile is used)
More tests and info can be found when I asked the rust community on reddit about this problem:
https://www.reddit.com/r/rust/comments/18qojeb
I would like to have a dropdown to choose which profile to use (potentially reading the custom profiles from Cargo.toml. The dropdown could be added at the bottom next to the rust-analyzer or inside this menu if possible. This would make it similar to the dropdown in Visual Studio 20XX where you can change the build option with the dropdown. Otherwise, a dropdown in the extension settings would be appreciated.
As far as I am concerned, right now there is no way to change the profile / disable a specific option such as debug_assertions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by tracing how rust-analyzer selects Cargo profiles and configures debug_assertions, then inspect the existing settings or menu entry points; done should mean users can select the intended profile, including custom Cargo profiles, for analysis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100