mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-23 08:48:08 +00:00
Merge 6fb908cbb7 into 624761a864
This commit is contained in:
commit
7b39ee7dbc
1 changed files with 32 additions and 0 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue