Merge #6510
6510: Fix panic when extracting struct r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
2fd29d0470
@ -277,10 +277,11 @@ pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) {
|
||||
algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit)
|
||||
}
|
||||
pub(crate) fn rewrite(&mut self, rewriter: SyntaxRewriter) {
|
||||
let node = rewriter.rewrite_root().unwrap();
|
||||
if let Some(node) = rewriter.rewrite_root() {
|
||||
let new = rewriter.rewrite(&node);
|
||||
algo::diff(&node, &new).into_text_edit(&mut self.edit);
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(mut self) -> SourceChange {
|
||||
self.commit();
|
||||
|
@ -378,6 +378,36 @@ enum E {
|
||||
fn f() {
|
||||
let e = E::V(V(9, 2));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_several_files_record() {
|
||||
// FIXME: this should fix the usage as well!
|
||||
check_assist(
|
||||
extract_struct_from_enum_variant,
|
||||
r#"
|
||||
//- /main.rs
|
||||
enum E {
|
||||
<|>V { i: i32, j: i32 }
|
||||
}
|
||||
mod foo;
|
||||
|
||||
//- /foo.rs
|
||||
use crate::E;
|
||||
fn f() {
|
||||
let e = E::V { i: 9, j: 2 };
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct V{ pub i: i32, pub j: i32 }
|
||||
|
||||
enum E {
|
||||
V(V)
|
||||
}
|
||||
mod foo;
|
||||
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user