mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
introduce_named_lifetime assist wasn't applicable when type parameter
followed anonymous lifetime token (fixes #4684)
This commit is contained in:
parent
65a3cc21ed
commit
921306757b
1 changed files with 17 additions and 2 deletions
|
@ -41,8 +41,6 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
|
|||
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) {
|
||||
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
|
||||
} else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) {
|
||||
// only allow naming the last anonymous lifetime
|
||||
lifetime_token.next_token().filter(|tok| tok.kind() == SyntaxKind::R_ANGLE)?;
|
||||
generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
|
||||
} else {
|
||||
None
|
||||
|
@ -190,6 +188,23 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_impl_with_other_type_param() {
|
||||
check_assist(
|
||||
introduce_named_lifetime,
|
||||
"impl<I> fmt::Display for SepByBuilder<'_<|>, I>
|
||||
where
|
||||
I: Iterator,
|
||||
I::Item: fmt::Display,
|
||||
{",
|
||||
"impl<I, 'a> fmt::Display for SepByBuilder<'a, I>
|
||||
where
|
||||
I: Iterator,
|
||||
I::Item: fmt::Display,
|
||||
{",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_example_case_cursor_before_tick() {
|
||||
check_assist(
|
||||
|
|
Loading…
Reference in a new issue