This commit is contained in:
A4-Tacks 2025-12-22 16:36:16 +01:00 committed by GitHub
commit 7b39ee7dbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1346,6 +1346,9 @@ fn node_to_insert_after(body: &FunctionBody, anchor: Anchor) -> Option<SyntaxNod
if ancestors.peek().map(SyntaxNode::kind) == Some(SyntaxKind::IMPL) {
break;
}
if anchor == Anchor::Method {
break;
}
}
_ => (),
}
@ -2907,6 +2910,35 @@ impl S {
);
}
#[test]
fn method_in_trait() {
check_assist(
extract_function,
r#"
trait Foo {
fn f(&self) -> i32;
fn foo(&self) -> i32 {
$0self.f()+self.f()$0
}
}
"#,
r#"
trait Foo {
fn f(&self) -> i32;
fn foo(&self) -> i32 {
self.fun_name()
}
fn $0fun_name(&self) -> i32 {
self.f()+self.f()
}
}
"#,
);
}
#[test]
fn variable_defined_inside_and_used_after_no_ret() {
check_assist(