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

Manual updates #7113

Merged
merged 2 commits into from
Jan 3, 2021
Merged

Manual updates #7113

merged 2 commits into from
Jan 3, 2021

Conversation

tekul
Copy link
Contributor

@tekul tekul commented Dec 31, 2020

Add some details on how to build the manual and some clarification on how to deal with "proc macro2 warnings.

For context, this arose from this question on users.rust-lang.org.

- Add link to asciidoc website
- Explain how to create the generated adoc files from the source code
- How to run asciidoctor to generate the manual
@matklad
Copy link
Member

matklad commented Dec 31, 2020

bors r+

Thanks!

bors bot added a commit that referenced this pull request Dec 31, 2020
7113: Manual updates r=matklad a=tekul

Add some details on how to build the manual and some clarification on how to deal with "proc macro2 warnings.

For context, this arose from [this question](https://users.rust-lang.org/t/how-to-disable-rust-analyzer-proc-macro-warnings-in-neovim/53150) on users.rust-lang.org.

Co-authored-by: Luke Taylor <[email protected]>
@bors
Copy link
Contributor

bors bot commented Dec 31, 2020

Build failed:

@tekul
Copy link
Contributor Author

tekul commented Dec 31, 2020

Looks like I screwed a couple of things up. How do I update the package.json file 🤔 ? Do I just paste the output from the tests into it?

@lnicola
Copy link
Member

lnicola commented Jan 1, 2021

See rust-analyzer --print-config-schema.

@@ -153,7 +153,8 @@ config_data! {
/// Whether to show `can't find Cargo.toml` error message.
notifications_cargoTomlNotFound: bool = "true",
/// Enable Proc macro support, `#rust-analyzer.cargo.loadOutDirsFromCheck#` must be
/// enabled.
/// enabled. This has nothing to do with "proc macro not expanded" warnings. See the
Copy link
Member

Choose a reason for hiding this comment

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

This has nothing to do with "proc macro not expanded" warnings

That doesn't seem right to me? The "proc macro not expanded" warnings are emitted when we encounter proc macro calls, but this setting is disabled, so they have a lot to do with each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The warnings seem to be shown whether this setting is enabled or not. That is what I was attempting to capture here. I hadn't actually heard of a "proc macro" before this (though I now have some idea what they are 🙂 ). I expect a lot of users who see this message when using rust-analyzer won't really know either. I'm still not sure what this setting is for, but I guess it is only required if you are writing macros and have the corresponding flag set in your crate. Is that correct?

Copy link
Member

@lnicola lnicola Jan 1, 2021

Choose a reason for hiding this comment

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

I hadn't actually heard of a "proc macro" before this

If you've used serde, that was a proc macro. They're called procedural macros because they're Rust functions that are called with bits of text and return other bits of Rust code. That's unlike declarative macros (or "macros by example"), which define input templates and rules for how they need to be transformed.

A proc macro lives in a Rust crate that needs to be compiled, then loaded at run-time by the compiler (so that it's able to call the function in there). We're not the compiler, but we do the same thing to expand procedural macros, but only if rust-analyzer.procMacro.enable (because of #6448).

The warnings seem to be shown whether this setting is enabled or not.

I think they shouldn't be shown if it's enabled. They shouldn't even be warnings, I guess. That message is there only to tell users about the setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, you are right. The warnings do go away with this enabled. I'm not sure why this didn't work for me the first time I tried it. I probably had a typo in the nvim lua settings. So this change is definitely wrong. Shall I change it to to something along the lines of "If you are seeing 'proc macro not expanded' warnings, enabling this property should stop them. Alternatively you can disable the unresolved-proc-macro diagnostic"?

Copy link
Member

Choose a reason for hiding this comment

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

Shall I change it to to something along the lines of "If you are seeing 'proc macro not expanded' warnings, enabling this property should stop them. Alternatively you can disable the unresolved-proc-macro diagnostic"?

That sounds correct. It might be too verbose, but I'm not sure how verbose the descriptions usually are.

@tekul
Copy link
Contributor Author

tekul commented Jan 1, 2021

See rust-analyzer --print-config-schema.

This seems to print the same output as running the test, but it's not obvious how to update the package.json file which contains other properties (e.g rust-analyzer.updates.askBeforeDownload, rust-analyzer.updates.channel). How do you merge them?

@lnicola
Copy link
Member

lnicola commented Jan 1, 2021

How do you merge them?

I've no idea, those were added only recently. The difference is that these two (at least) only apply to the Code extension, and not to the language server (so the Rust code doesn't care about them).

Added the error message to the doc for the UnresolvedProcMacro
diagnostic, explaining that either enabling the procMacro setting
or disabling this diagnostic should make the warnings go away.
@tekul
Copy link
Contributor Author

tekul commented Jan 1, 2021

I've redone this, removing the doc from the procMacro section (since that is the only bit which affects the config) and just expanding the unresolved-proc-macro section to explain that either of these settings can be used to stop the warnings appearing. This way the generated config remains unchanged and I don't need to worry about rebuilding package.json.

@matklad
Copy link
Member

matklad commented Jan 3, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 3, 2021

@bors bors bot merged commit 5b86ff3 into rust-lang:master Jan 3, 2021
@tekul tekul deleted the manual_updates branch January 3, 2021 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants