introduce_named_lifetime assist wasn't applicable when type parameter

followed anonymous lifetime token

(fixes #4684)
This commit is contained in:
Jess Balint 2020-06-03 17:54:23 -05:00
parent 65a3cc21ed
commit 921306757b

View file

@ -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(