Skip to content

Commit 1f9e02c

Browse files
committed
fix generated docs issue
1 parent 6594235 commit 1f9e02c

File tree

3 files changed

+72
-23
lines changed

3 files changed

+72
-23
lines changed

crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ use crate::{AssistContext, AssistId, Assists};
22
use ra_syntax::{ast, ast::TypeParamsOwner, AstNode, SyntaxKind};
33
use std::collections::HashSet;
44

5-
/// Assist: change_lifetime_anon_to_named
6-
///
7-
/// Change an anonymous lifetime to a named lifetime.
8-
///
9-
/// ```
10-
/// impl Cursor<'_<|>> {
11-
/// fn node(self) -> &SyntaxNode {
12-
/// match self {
13-
/// Cursor::Replace(node) | Cursor::Before(node) => node,
14-
/// }
15-
/// }
16-
/// }
17-
/// ```
18-
/// ->
19-
/// ```
20-
/// impl<'a> Cursor<'a> {
21-
/// fn node(self) -> &SyntaxNode {
22-
/// match self {
23-
/// Cursor::Replace(node) | Cursor::Before(node) => node,
24-
/// }
25-
/// }
26-
/// }
27-
/// ```
5+
// Assist: change_lifetime_anon_to_named
6+
//
7+
// Change an anonymous lifetime to a named lifetime.
8+
//
9+
// ```
10+
// impl Cursor<'_<|>> {
11+
// fn node(self) -> &SyntaxNode {
12+
// match self {
13+
// Cursor::Replace(node) | Cursor::Before(node) => node,
14+
// }
15+
// }
16+
// }
17+
// ```
18+
// ->
19+
// ```
20+
// impl<'a> Cursor<'a> {
21+
// fn node(self) -> &SyntaxNode {
22+
// match self {
23+
// Cursor::Replace(node) | Cursor::Before(node) => node,
24+
// }
25+
// }
26+
// }
27+
// ```
2828
// FIXME: How can we handle renaming any one of multiple anonymous lifetimes?
2929
pub(crate) fn change_lifetime_anon_to_named(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
3030
let lifetime_token = ctx.find_token_at_offset(SyntaxKind::LIFETIME)?;

crates/ra_assists/src/tests/generated.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,31 @@ pub mod std { pub mod collections { pub struct HashMap { } } }
268268
)
269269
}
270270

271+
#[test]
272+
fn doctest_change_lifetime_anon_to_named() {
273+
check_doc_test(
274+
"change_lifetime_anon_to_named",
275+
r#####"
276+
impl Cursor<'_<|>> {
277+
fn node(self) -> &SyntaxNode {
278+
match self {
279+
Cursor::Replace(node) | Cursor::Before(node) => node,
280+
}
281+
}
282+
}
283+
"#####,
284+
r#####"
285+
impl<'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+
271296
#[test]
272297
fn doctest_change_return_type_to_result() {
273298
check_doc_test(

docs/user/assists.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,30 @@ fn main() {
259259
}
260260
```
261261

262+
## `change_lifetime_anon_to_named`
263+
264+
Change an anonymous lifetime to a named lifetime.
265+
266+
```rust
267+
// BEFORE
268+
impl Cursor<'_┃> {
269+
fn node(self) -> &SyntaxNode {
270+
match self {
271+
Cursor::Replace(node) | Cursor::Before(node) => node,
272+
}
273+
}
274+
}
275+
276+
// AFTER
277+
impl<'a> Cursor<'a> {
278+
fn node(self) -> &SyntaxNode {
279+
match self {
280+
Cursor::Replace(node) | Cursor::Before(node) => node,
281+
}
282+
}
283+
}
284+
```
285+
262286
## `change_return_type_to_result`
263287

264288
Change the function's return type to Result.

0 commit comments

Comments
 (0)