rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.35k stars 1.62k forks source link

doc: mark out experimental diagnostics to avoid confusion #18288

Open hanayashiki opened 1 month ago

hanayashiki commented 1 month ago

rust-analyzer version: 0.3.2137-standalone (2b750da1a 2024-10-06) [/Users/chenyuwang/.vscode/extensions/rust-lang.rust-analyzer-0.3.2137-darwin-arm64/server/rust-analyzer]

rustc version: -

editor or extension: -

relevant settings: - repository link (if public, optional): - code snippet to reproduce:

fn main() {
    let n = 3;
    let b = n();
   // show `expected function, found i32rust-analyzer[E0618](https://doc.rust-lang.org/stable/error_codes/E0618.html)`
   // only when "rust-analyzer.diagnostics.experimental.enable": true
}

I'd like to test out the diagnostics https://rust-analyzer.github.io/manual.html#expected-function but it seems it is actually "experimental" and is only enabled when "rust-analyzer.diagnostics.experimental.enable": true is set to true in .vscode/settings.json. I think the documentation is supposed to make it clear with the configuration of experimental diagnostics in the auto-generated documentation. If possible I think I can make a PR to help.

darichey commented 1 month ago

Whether a Diagnostic is experimental technically isn't known statically, since it's just set like https://github.com/rust-lang/rust-analyzer/blob/0fb804acb375b02a3beeaceeb75b71969ef37b15/crates/ide-diagnostics/src/handlers/expected_function.rs#L12-L18

In practice a heuristic of "check if the text contains .experimental()" would probably work fine https://github.com/rust-lang/rust-analyzer/blob/0fb804acb375b02a3beeaceeb75b71969ef37b15/xtask/src/codegen/diagnostics_docs.rs#L40-L41

Or we could just manually add a note to each experimental diagnostic, with the only risk being them becoming out of sync.

hanayashiki commented 1 month ago

Or just breakingly prefix them to be experimental_xxx since they are experimental anyways?