Skip to content

Commit 913a623

Browse files
bors[bot]jbalint
andauthored
Merge #4750
4750: introduce_named_lifetime assist wasn't applicable when type parameter r=matklad a=jbalint followed anonymous lifetime token (fixes #4684) Co-authored-by: Jess Balint <[email protected]>
2 parents e66c7b3 + 9213067 commit 913a623

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

crates/ra_assists/src/handlers/introduce_named_lifetime.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
4141
if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) {
4242
generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
4343
} else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) {
44-
// only allow naming the last anonymous lifetime
45-
lifetime_token.next_token().filter(|tok| tok.kind() == SyntaxKind::R_ANGLE)?;
4644
generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
4745
} else {
4846
None
@@ -190,6 +188,23 @@ mod tests {
190188
);
191189
}
192190

191+
#[test]
192+
fn test_impl_with_other_type_param() {
193+
check_assist(
194+
introduce_named_lifetime,
195+
"impl<I> fmt::Display for SepByBuilder<'_<|>, I>
196+
where
197+
I: Iterator,
198+
I::Item: fmt::Display,
199+
{",
200+
"impl<I, 'a> fmt::Display for SepByBuilder<'a, I>
201+
where
202+
I: Iterator,
203+
I::Item: fmt::Display,
204+
{",
205+
)
206+
}
207+
193208
#[test]
194209
fn test_example_case_cursor_before_tick() {
195210
check_assist(

0 commit comments

Comments
 (0)