mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
parent
38fa47fd79
commit
23cfe0702d
1 changed files with 42 additions and 1 deletions
|
@ -168,7 +168,7 @@ fn edit_struct_references(
|
||||||
let arg_list = call_expr.syntax().descendants().find_map(ast::ArgList::cast)?;
|
let arg_list = call_expr.syntax().descendants().find_map(ast::ArgList::cast)?;
|
||||||
|
|
||||||
edit.replace(
|
edit.replace(
|
||||||
call_expr.syntax().text_range(),
|
ctx.sema.original_range(&node).range,
|
||||||
ast::make::record_expr(
|
ast::make::record_expr(
|
||||||
path,
|
path,
|
||||||
ast::make::record_expr_field_list(arg_list.args().zip(names).map(
|
ast::make::record_expr_field_list(arg_list.args().zip(names).map(
|
||||||
|
@ -249,6 +249,24 @@ mod tests {
|
||||||
);
|
);
|
||||||
check_assist_not_applicable(convert_tuple_struct_to_named_struct, r#"struct Foo$0;"#);
|
check_assist_not_applicable(convert_tuple_struct_to_named_struct, r#"struct Foo$0;"#);
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn convert_in_macro_args() {
|
||||||
|
check_assist(
|
||||||
|
convert_tuple_struct_to_named_struct,
|
||||||
|
r#"
|
||||||
|
macro_rules! foo {($i:expr) => {$i} }
|
||||||
|
struct T$0(u8);
|
||||||
|
fn test() {
|
||||||
|
foo!(T(1));
|
||||||
|
}"#,
|
||||||
|
r#"
|
||||||
|
macro_rules! foo {($i:expr) => {$i} }
|
||||||
|
struct T { field1: u8 }
|
||||||
|
fn test() {
|
||||||
|
foo!(T { field1: 1 });
|
||||||
|
}"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convert_simple_struct() {
|
fn convert_simple_struct() {
|
||||||
|
@ -554,6 +572,29 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn convert_variant_in_macro_args() {
|
||||||
|
check_assist(
|
||||||
|
convert_tuple_struct_to_named_struct,
|
||||||
|
r#"
|
||||||
|
macro_rules! foo {($i:expr) => {$i} }
|
||||||
|
enum T {
|
||||||
|
V$0(u8)
|
||||||
|
}
|
||||||
|
fn test() {
|
||||||
|
foo!(T::V(1));
|
||||||
|
}"#,
|
||||||
|
r#"
|
||||||
|
macro_rules! foo {($i:expr) => {$i} }
|
||||||
|
enum T {
|
||||||
|
V { field1: u8 }
|
||||||
|
}
|
||||||
|
fn test() {
|
||||||
|
foo!(T::V { field1: 1 });
|
||||||
|
}"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convert_simple_variant() {
|
fn convert_simple_variant() {
|
||||||
check_assist(
|
check_assist(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue