aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess Balint <[email protected]>2020-05-22 15:25:55 +0100
committerJess Balint <[email protected]>2020-05-22 15:25:55 +0100
commit1f9e02c74e7822a490466a605fa384ce1b5e3afe (patch)
tree5fe797ce562a33be1a56fc9fec816866e1454ebc
parent6594235dd80d337dd7bfaa8be876ba5e111526b1 (diff)
fix generated docs issue
-rw-r--r--crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs46
-rw-r--r--crates/ra_assists/src/tests/generated.rs25
-rw-r--r--docs/user/assists.md24
3 files changed, 72 insertions, 23 deletions
diff --git a/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs b/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs
index 8d8f7833f..7101d9aaf 100644
--- a/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs
+++ b/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs
@@ -2,29 +2,29 @@ use crate::{AssistContext, AssistId, Assists};
2use ra_syntax::{ast, ast::TypeParamsOwner, AstNode, SyntaxKind}; 2use ra_syntax::{ast, ast::TypeParamsOwner, AstNode, SyntaxKind};
3use std::collections::HashSet; 3use std::collections::HashSet;
4 4
5/// Assist: change_lifetime_anon_to_named 5// Assist: change_lifetime_anon_to_named
6/// 6//
7/// Change an anonymous lifetime to a named lifetime. 7// Change an anonymous lifetime to a named lifetime.
8/// 8//
9/// ``` 9// ```
10/// impl Cursor<'_<|>> { 10// impl Cursor<'_<|>> {
11/// fn node(self) -> &SyntaxNode { 11// fn node(self) -> &SyntaxNode {
12/// match self { 12// match self {
13/// Cursor::Replace(node) | Cursor::Before(node) => node, 13// Cursor::Replace(node) | Cursor::Before(node) => node,
14/// } 14// }
15/// } 15// }
16/// } 16// }
17/// ``` 17// ```
18/// -> 18// ->
19/// ``` 19// ```
20/// impl<'a> Cursor<'a> { 20// impl<'a> Cursor<'a> {
21/// fn node(self) -> &SyntaxNode { 21// fn node(self) -> &SyntaxNode {
22/// match self { 22// match self {
23/// Cursor::Replace(node) | Cursor::Before(node) => node, 23// Cursor::Replace(node) | Cursor::Before(node) => node,
24/// } 24// }
25/// } 25// }
26/// } 26// }
27/// ``` 27// ```
28// FIXME: How can we handle renaming any one of multiple anonymous lifetimes? 28// FIXME: How can we handle renaming any one of multiple anonymous lifetimes?
29pub(crate) fn change_lifetime_anon_to_named(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 29pub(crate) fn change_lifetime_anon_to_named(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
30 let lifetime_token = ctx.find_token_at_offset(SyntaxKind::LIFETIME)?; 30 let lifetime_token = ctx.find_token_at_offset(SyntaxKind::LIFETIME)?;
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs
index 250e56a69..abffbf97c 100644
--- a/crates/ra_assists/src/tests/generated.rs
+++ b/crates/ra_assists/src/tests/generated.rs
@@ -269,6 +269,31 @@ pub mod std { pub mod collections { pub struct HashMap { } } }
269} 269}
270 270
271#[test] 271#[test]
272fn doctest_change_lifetime_anon_to_named() {
273 check_doc_test(
274 "change_lifetime_anon_to_named",
275 r#####"
276impl Cursor<'_<|>> {
277 fn node(self) -> &SyntaxNode {
278 match self {
279 Cursor::Replace(node) | Cursor::Before(node) => node,
280 }
281 }
282}
283"#####,
284 r#####"
285impl<'a> Cursor<'a> {
286 fn node(self) -> &SyntaxNode {
287 match self {
288 Cursor::Replace(node) | Cursor::Before(node) => node,
289 }
290 }
291}
292"#####,
293 )
294}
295
296#[test]
272fn doctest_change_return_type_to_result() { 297fn doctest_change_return_type_to_result() {
273 check_doc_test( 298 check_doc_test(
274 "change_return_type_to_result", 299 "change_return_type_to_result",
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 4ad7ea59d..a1058ecde 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -259,6 +259,30 @@ fn main() {
259} 259}
260``` 260```
261 261
262## `change_lifetime_anon_to_named`
263
264Change an anonymous lifetime to a named lifetime.
265
266```rust
267// BEFORE
268impl Cursor<'_┃> {
269 fn node(self) -> &SyntaxNode {
270 match self {
271 Cursor::Replace(node) | Cursor::Before(node) => node,
272 }
273 }
274}
275
276// AFTER
277impl<'a> Cursor<'a> {
278 fn node(self) -> &SyntaxNode {
279 match self {
280 Cursor::Replace(node) | Cursor::Before(node) => node,
281 }
282 }
283}
284```
285
262## `change_return_type_to_result` 286## `change_return_type_to_result`
263 287
264Change the function's return type to Result. 288Change the function's return type to Result.