I am running into an unexpected issue when it comes to toolchains in CLion. I want to use the stable channel for the compiler while using the nightly for rustfmt. The reason is that I want to use rustfmt features that are not available in the stable version. Unfortunately CLion only picks up the currently selected toolchain without any way to override or customize this and thus has not option to select the nightly of rustfmt for formatting. Is there any workaround or option I did not notice when looking for it?
In the comment there was the suggestion that cargo +nightly fmt might be what I am looking for. Even though it allows to used the nightly of rustfmt it is not integrated into the flow of CLion which seems to use the currently enabled version of the entire toolchain.
Under Clion | Preferences...:
search for formatter
select Rustfmt on the left column
add +nightly to the Additional arguments: box
check Use rustfmt instead of the built-in formatter
click Ok
Now Code | Reformat File with rustfmt should respect rustfmt nightly settings. (CLion 2022.2.4)
Related
My main function is decorated with two proc macros like this:
#[paw::main]
#[tokio::main]
pub async fn main(args: Args) -> Result<()>
This compiles and runs as I expect it but VS code's rust-analyzer gives me this error on both lines of attribute macros #[paw::main] and #[tokio::main]. The error message is:
proc macro `main` not expanded: proc macro not found rust-analyzer (unresolved-proc-macro)
Judging by this GitHub issue, and in particular this comment, it seems that proc macro expansion is quite dependent on the version of the Rust compiler. The suggested fix is to keep your rust-analyzer updated. Switching to the pre-release version of rust-analyzer fixed this for me on rustc 1.61, which is the latest stable in time of writing. Presumably the pre-release version of rust-analyzer is always most likely to be ABI-compatible with the latest stable version of rustc.
There might be a better way, but this will make the error go away:
Go to settings and find rust-analyzer > Diagnostics: Disabled. You can search for "rust analyzer diagnostics" to find this option.
Press Add Item
Add the item unresolved-proc-macro and press OK.
Source for this solution was found here.
Is it possible to set a certain compiler switch if a feature is enabled? For example I would like to add a feature instrument and compile everything with -Z instrument-mcount. I did take a look at the options available for .cargo/config.toml but could not find anything useful.
After installing extensions for Rust, I get this error:
To properly function, the extension needs to know what toolchain you
want to use.
Press Close to select toolchain :)
The extension will provide a prompt after you close that prompt, which allows you to select the toolchain you want. You can see the toolchain that you selected in your preferences file.
As the message says, you must choose a toolchain (documentation here):
$ rustup default stable
for the stable Rust, or
$ rustup default nightly
for the newest development version.
If you only want to play with Rust, I advise you to use nightly Rust because there are more new things in it.
Add this to your configuration with toolchain you want to use to enforce it in VS Code:
"rust.rustup": {
"toolchain": "stable-x86_64-apple-darwin"
}
I have installed cvim plugin for vim in Ubuntu from this link :
http://www.thegeekstuff.com/2009/01/tutorial-make-vim-as-your-cc-ide-using-cvim-plugin/
Now I want to run c++11 standard programs in vim.How to configure vim so that it can compile and run c++11 programs ?
The plugin defaults to gcc as the C compiler, configured by g:C_VimCompilerName (as per the help). You need to have a compiler version installed that supports the new C++11 features.
To inquire about general plugin support for C++11 (e.g. in its snippets and other features), best directly ask the plugin author (the plugin page even references a mailing list), and ideally offer patches and your help.
I am makeing a small mod to SMPlayer; the Linux version...
The make, sudo make install from the command line works, but I would like to have the project in an IDE.
I want to use CodeBlocks IDE, only because I've used it before, but if some other IDE is required, I can use that instead... (I use Codeblocks because it is simple, and that suits my current ability to handle an IDE)..
Is there some way to use SMPlayer's Makefile, or some such thing?
This depends on the IDE and has little to nothing to do with Linux.
Does your program come with something like cmake or another setup tool? That normally makes it much easier. For example in KDevelop you can import straight from CMakeLists.txt and Makefiles.
If all else fails it might be quite easy to do something like this (not knowing your specific IDE):
Add new Project
Set build directory and other necessary settings (like compiler and compiler flags)
Add the already existing files to it.
Press "Compile"-button.
This is obviously depending on the project structure, setup and size.
Code::Blocks has builtin support for Makefile projects. See the FAQ.
Also you could just use vim or emacs ;)