rust/crates
bors[bot] 855b00cbe6
Merge #7570 #7571
7570: Add doc gen to the `generate_enum_match_method` assist r=yoshuawuyts a=yoshuawuyts

Implements a small extension to https://github.com/rust-analyzer/rust-analyzer/pull/7562, generating default comments. I wasn't sure if this would fit the goals of Rust-Analyzer, so I chose to split it into a separate PR. This is especially useful when writing code in a codebase which uses `#![warn(missing_docs)]` lint, as many production-grade libraries do.

The comments we're generating here are similar to the ones found on [`Option::is_some`](https://doc.rust-lang.org/std/option/enum.Option.html#method.is_some) and [`Result::is_err`](https://doc.rust-lang.org/std/result/enum.Result.html#method.is_err). I briefly considered only generating these for `pub` types, but they seem small and unobtrusive enough that they're probably useful in the general case. Thanks!

## Example

__input__
```rust
pub(crate) enum Variant {
    Undefined,
    Minor, // cursor here
    Major,
}
```

__output__
```rust
pub(crate) enum Variant {
    Undefined,
    Minor,
    Major,
}

impl Variant {
    /// Returns `true` if the variant is [`Minor`].
    pub(crate) fn is_minor(&self) -> bool {
        matches!(self, Self::Minor)
    }
}
```

## Future Directions

This opens up the path to adding an assist for generating these comments on existing `is_` methods. This would make it both easy to document new code, and update existing code with documentation.

7571: Cleanup decl_check r=Veykril a=Veykril

bors r+

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-05 15:17:41 +00:00
..
assists Merge #7570 #7571 2021-02-05 15:17:41 +00:00
base_db Fix warnings when running cargo doc --document-private-items 2021-01-18 16:44:40 -05:00
cfg Upgrade expect-test to 1.1 2021-01-03 14:43:29 +01:00
completion Make ModPath's representation private 2021-02-04 20:49:24 +01:00
flycheck Make logger-based debugging more pleasant 2021-01-28 17:07:53 +03:00
hir Prefer ValueNS when resolving hir path for PathExpressions 2021-01-29 15:59:52 +01:00
hir_def Fix merging of segment_index in path resolution 2021-02-05 15:14:33 +01:00
hir_expand add more counts 2021-01-27 12:39:19 +03:00
hir_ty Merge #7570 #7571 2021-02-05 15:17:41 +00:00
ide Show alias underlying type 2021-02-02 17:47:56 +03:00
ide_db Make ModPath's representation private 2021-02-04 20:49:24 +01:00
mbe Make sure normal dependencies always have version 2021-02-03 12:51:07 +00:00
parser Add validation for mutable const items 2021-01-24 02:17:41 +01:00
paths Document paths items 2021-01-22 15:38:33 +01:00
proc_macro_api Reap proc macro server instances 2021-02-01 21:24:09 +02:00
proc_macro_srv Use non-deprecated memmap2 crate 2021-02-02 10:25:17 -05:00
proc_macro_test Add description for crates that will be published 2020-08-24 13:07:22 +02:00
profile add more counts 2021-01-27 12:39:19 +03:00
project_model Async Loading outdir and proc-macro 2021-01-29 01:04:14 +08:00
rust-analyzer Make ModPath's representation private 2021-02-04 20:49:24 +01:00
ssr . 2021-01-20 01:56:11 +03:00
stdx Cleanup decl_check 2021-02-05 16:09:45 +01:00
syntax Merge #7535 2021-02-05 02:55:56 +00:00
test_utils Fixed typos in code comments 2021-01-09 15:41:29 +01:00
text_edit Avoid turning completion objects into builders 2020-11-16 23:16:41 +02:00
toolchain Add description for crates that will be published 2020-08-24 13:07:22 +02:00
tt Refactor TokenBuffer for reduc cloning 2021-01-05 02:00:46 +08:00
vfs Document vfs private items 2021-01-12 18:01:47 +01:00
vfs-notify Follow symlinks when walking project trees 2020-10-15 14:22:36 -04:00