Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation regarding suggestion for expanding proc macros #1341

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/building/suggested.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ you can write: <!-- date: 2022-04 --><!-- the date comment is for the edition be
],
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.buildScripts.enable": true,
"rust-analyzer.cargo.buildScripts.useRustcWrapper": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be set by default, why set it explicitly here?
(Same for the enable options.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to not have these lines.

  • If people have this explicitly globally disabled, we should respect that.
  • For the libs suggestion, we can just have another code block saying "also add these things".

"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"./build/$TARGET_TRIPLE/stage0/bin/cargo",
"check",
"-p",
"rustc_driver",
Expand All @@ -56,10 +57,10 @@ you can write: <!-- date: 2022-04 --><!-- the date comment is for the edition be
in your `.vscode/settings.json` file. This will ask `rust-analyzer` to use
`./x.py check` to check the sources, and the stage 0 rustfmt to format them.

> NOTE: Make sure to replace `TARGET_TRIPLE` in the `rust-analyzer.rustfmt.overrideCommand`
> setting with the appropriate target triple for your machine. An example of such
> a triple is `x86_64-unknown-linux-gnu`. An easy way to check your target triple
> is to run `rustc -vV` and checking the `host` value of its output.
> NOTE: Make sure to replace `TARGET_TRIPLE` with the appropriate target triple
> for your machine. An example of such a triple is `x86_64-unknown-linux-gnu`.
> An easy way to check your target triple is to run `rustc -vV` and checking the
> `host` value of its output.

If you have enough free disk space and you would like to be able to run `x.py` commands while
rust-analyzer runs in the background, you can also add `--build-dir build-rust-analyzer` to the
Expand All @@ -70,6 +71,17 @@ If you're running `coc.nvim`, you can use `:CocLocalConfig` to create a
`editor.formatOnSave: true,` with
`"coc.preferences.formatOnSaveFiletypes": ["rust"],`.

> NOTE: The configuration once suggested disabling build scripts, but after
> the version `2022-04-14` this was fixed by introducing an option for customizing
> the command rust-analyzer uses to run build scripts. Please ensure that `rust-analyzer`
> is up to date before enabling these options. If you do not wish to enable
> `rust-analyzer.cargo.useRustcWrapperForBuildScripts`, the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above the option is called rust-analyzer.cargo.buildScripts.useRustcWrapper, but here it is called by a different name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It got renamed, rust-analyzer.cargo.buildScripts.useRustcWrapper is the new name and rust-analyzer.cargo.useRustcWrapperForBuildScripts is the old name that would still work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence should be left out anyway.

> `rust-analyzer.cargo.buildScripts.overrideCommand` option should be set as same as
> `rust-analyzer.checkOnSave.overrideCommand` instead of the suggested value.
>
> If you are not developing for the compiler, you do not need to configure the build scripts
> like in the configuration and you can disable proc macros and build scripts.

If running `./x.py check` on save is inconvenient, in VS Code you can use a [Build
Task] instead:

Expand Down