aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-05 11:04:58 +0000
committerGitHub <[email protected]>2021-01-05 11:04:58 +0000
commit5c10f2f705d6757b9821387a5be759789b7ee480 (patch)
tree961570d2245c2e62ce7f20c2437fe5d8abb92166 /crates/assists/src/tests
parent4bc1ed7d592819bf2a29f7be376e0c09f190c345 (diff)
parent7b4b4ef02681053299dda5111c0d4b0113e29224 (diff)
Merge #7131
7131: Created an assist for inlining a function's body into its caller r=matklad a=Michael-F-Bryan This introduces an `inline_function` assist which will convert code like this: ```rust fn add(a: u32, b: u32) -> u32 { a + b } fn main() { let x = add<|>(1, 2); } ``` Into something like this: ```rust fn add(a: u32, b: u32) -> u32 { a + b } fn main() { let x = { let a = 1; let b = 2; a + b }; } ``` Fixes #6863. Co-authored-by: Michael-F-Bryan <[email protected]>
Diffstat (limited to 'crates/assists/src/tests')
-rw-r--r--crates/assists/src/tests/generated.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/assists/src/tests/generated.rs b/crates/assists/src/tests/generated.rs
index 85e3c6742..b15352cf3 100644
--- a/crates/assists/src/tests/generated.rs
+++ b/crates/assists/src/tests/generated.rs
@@ -531,6 +531,29 @@ fn foo() -> i32 { 42i32 }
531} 531}
532 532
533#[test] 533#[test]
534fn doctest_inline_function() {
535 check_doc_test(
536 "inline_function",
537 r#####"
538fn add(a: u32, b: u32) -> u32 { a + b }
539fn main() {
540 let x = add<|>(1, 2);
541}
542"#####,
543 r#####"
544fn add(a: u32, b: u32) -> u32 { a + b }
545fn main() {
546 let x = {
547 let a = 1;
548 let b = 2;
549 a + b
550 };
551}
552"#####,
553 )
554}
555
556#[test]
534fn doctest_inline_local_variable() { 557fn doctest_inline_local_variable() {
535 check_doc_test( 558 check_doc_test(
536 "inline_local_variable", 559 "inline_local_variable",