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

Request: Show rustdoc warnings #9131

Open
Tracked by #86
KSXGitHub opened this issue Jun 3, 2021 · 8 comments
Open
Tracked by #86

Request: Show rustdoc warnings #9131

KSXGitHub opened this issue Jun 3, 2021 · 8 comments
Labels
A-diagnostics diagnostics / error reporting C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) E-unknown It's unclear if the issue is E-hard or E-easy without digging in

Comments

@KSXGitHub
Copy link

KSXGitHub commented Jun 3, 2021

Example code:

use super::NewName;

/// Create an instance of [`OldName`].
pub fn create() -> NewName {
    unimplemented!()
}

In the code above, OldName has been renamed to NewName but I forget updating the doc. Running cargo doc would print warnings but I don't always remember it.

Request: Show rustdoc warnings like compiler warnings.

Edit: One had suggested that I set rust-analyzer.checkOnSave.command to doc, but I have already set it to clippy.

@flodiebold flodiebold added A-diagnostics diagnostics / error reporting C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) E-unknown It's unclear if the issue is E-hard or E-easy without digging in labels Jun 3, 2021
@bjorn3
Copy link
Member

bjorn3 commented Jun 3, 2021

You can use "rust-analyzer.checkOnSave.command": "doc" to run cargo doc instead of cargo check. It is not possible to get all warnings in doc comments as rustc doesn't interpret doc comments beyond what is necessary to parse your code. Rustdoc is responsible for getting them. I guess it should be possible to implement a warning for unresolved item links inside doc comments directly inside rust-analyzer though. They are already resolved I believe for semantic syntax highlighting.

@KSXGitHub
Copy link
Author

@bjorn3 I currently set it to clippy. Would doc also report Clippy lints?

@bjorn3
Copy link
Member

bjorn3 commented Jun 3, 2021

No, it wouldn't. There is no way to get both rustdoc and clippy lints without running both tools.

@Walther
Copy link
Contributor

Walther commented Aug 10, 2021

Would it be possible to consider a feature request then for the rust-analyzer.checkOnSave.command (or a new setting) to support a list of commands then? I would guess many people would appreciate seeing all three of rustc, clippy and doc issues in the IDE "Problems" lists that rust-analyzer is able to populate - without having to switch back and forth between the commands

@lnicola
Copy link
Member

lnicola commented Aug 10, 2021

cargo clippy should also include rustc warnings. For cargo doc, making a shell script or batch file that calls both might work.

@Walther
Copy link
Contributor

Walther commented Aug 10, 2021

You are describing a possible workaround, which I appreciate being brought up as it could unblock some people.

However - is it completely out of question for rust-analyzer to consider supporting this by itself - considering how common it is to use the language's builtin documentation support?

@lnicola
Copy link
Member

lnicola commented Aug 10, 2021

I don't know if it's out of scope. I certainly wouldn't use it because it slows down the builds and maybe I save a file 100 times, but only run cargo doc once (if even).

But it's totally fair to request ask for it.

@soareschen
Copy link

When I changed the checkOnSave command to doc, I get the following error:

[ERROR flycheck] Flycheck failed to run the following command: "cargo" "doc" "--workspace" "--message-format=json-diagnostic-rendered-ansi" "--manifest-path" "/path/to/Cargo.toml" "--all-targets" "--all-features"
[ERROR rust_analyzer::lsp_utils] cargo check failed:
Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(256))):
error: Found argument '--all-targets' which wasn't expected, or isn't valid in this context

  Did you mean '--all-features'?

Usage: cargo doc --workspace --message-format <FMT> --manifest-path <PATH> --all-features

For more information try '--help'

So there is really no viable workaround to check for rustdoc warnings within Rust Analyzer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) E-unknown It's unclear if the issue is E-hard or E-easy without digging in
Projects
None yet
Development

No branches or pull requests

6 participants