From 5c4df97996ac88133c12069debff1f86d3a9f7cb Mon Sep 17 00:00:00 2001 From: Phil Ellison Date: Sun, 28 Jul 2019 12:08:06 +0100 Subject: cargo format --- crates/ra_ide_api/src/completion/complete_scope.rs | 118 ++++++++++----------- .../ra_ide_api/src/completion/complete_snippet.rs | 30 +++--- crates/ra_ide_api/src/completion/presentation.rs | 64 +++++------ crates/ra_ide_api/src/display/structure.rs | 4 +- crates/ra_ide_api/src/runnables.rs | 18 ++-- 5 files changed, 117 insertions(+), 117 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 1baa5227a..07c2e5f94 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -122,7 +122,7 @@ impl ImportResolver { #[cfg(test)] mod tests { use crate::completion::{do_completion, CompletionItem, CompletionKind}; - use insta::assert_debug_snapshot_matches; + use insta::assert_debug_snapshot_matches; fn do_reference_completion(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) @@ -131,16 +131,16 @@ mod tests { #[test] fn completes_bindings_from_let() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn quux(x: i32) { let y = 92; 1 + <|>; let z = (); } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "quux", @@ -168,14 +168,14 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_bindings_from_if_let() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn quux() { if let Some(x) = foo() { let y = 92; @@ -186,8 +186,8 @@ mod tests { } } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "a", @@ -214,22 +214,22 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_bindings_from_for() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn quux() { for x in &[1, 2, 3] { <|> } } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "quux", @@ -248,20 +248,20 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_generic_params() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn quux() { <|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "T", @@ -280,20 +280,20 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_generic_params_in_struct() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" struct X { x: <|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "T", @@ -311,22 +311,22 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_module_items() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" struct Foo; enum Baz {} fn quux() { <|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "Baz", @@ -352,22 +352,22 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_extern_prelude() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" //- /lib.rs use <|>; //- /other_crate/lib.rs // nothing here " - ), -@r#"[ + ), + @r#"[ CompletionItem { label: "other_crate", source_range: [4; 4), @@ -376,22 +376,22 @@ mod tests { kind: Module, }, ]"# - ); + ); } #[test] fn completes_module_items_in_nested_modules() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" struct Foo; mod m { struct Bar; fn quux() { <|> } } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "Bar", @@ -410,19 +410,19 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_return_type() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" struct Foo; fn x() -> <|> " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "Foo", @@ -441,14 +441,14 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn dont_show_both_completions_for_shadowing() { assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn foo() { let bar = 92; { @@ -457,8 +457,8 @@ mod tests { } } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "bar", @@ -478,14 +478,14 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn completes_self_in_methods() { assert_debug_snapshot_matches!( - do_reference_completion(r"impl S { fn foo(&self) { <|> } }"), -@r#"[ + do_reference_completion(r"impl S { fn foo(&self) { <|> } }"), + @r#"[ CompletionItem { label: "Self", source_range: [25; 25), @@ -502,14 +502,14 @@ mod tests { detail: "&{unknown}", }, ]"# - ); + ); } #[test] fn completes_prelude() { assert_debug_snapshot_matches!( - do_reference_completion( - " + do_reference_completion( + " //- /main.rs fn foo() { let x: <|> } @@ -521,8 +521,8 @@ mod tests { struct Option; } " - ), -@r#"[ + ), + @r#"[ CompletionItem { label: "Option", source_range: [18; 18), @@ -546,6 +546,6 @@ mod tests { kind: Module, }, ]"# - ); + ); } } diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index 063b69319..e0368b3b2 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -40,7 +40,7 @@ fn ${1:feature}() { #[cfg(test)] mod tests { use crate::completion::{do_completion, CompletionItem, CompletionKind}; - use insta::assert_debug_snapshot_matches; + use insta::assert_debug_snapshot_matches; fn do_snippet_completion(code: &str) -> Vec { do_completion(code, CompletionKind::Snippet) @@ -49,8 +49,8 @@ mod tests { #[test] fn completes_snippets_in_expressions() { assert_debug_snapshot_matches!( - do_snippet_completion(r"fn foo(x: i32) { <|> }"), -@r#"[ + do_snippet_completion(r"fn foo(x: i32) { <|> }"), + @r#"[ CompletionItem { label: "pd", source_range: [17; 17), @@ -66,33 +66,33 @@ mod tests { kind: Snippet, }, ]"# - ); + ); } #[test] fn should_not_complete_snippets_in_path() { assert_debug_snapshot_matches!( - do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), -@r#"[]"# - ); + do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), + @r#"[]"# + ); assert_debug_snapshot_matches!( - do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), -@r#"[]"# - ); + do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), + @r#"[]"# + ); } #[test] fn completes_snippets_in_items() { assert_debug_snapshot_matches!( - do_snippet_completion( - r" + do_snippet_completion( + r" #[cfg(test)] mod tests { <|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "Test function", @@ -111,6 +111,6 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } } diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index fe7581adf..5df19990c 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -182,9 +182,9 @@ impl Completions { #[cfg(test)] mod tests { - use test_utils::covers; use crate::completion::{do_completion, CompletionItem, CompletionKind}; - use insta::assert_debug_snapshot_matches; + use insta::assert_debug_snapshot_matches; + use test_utils::covers; fn do_reference_completion(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) @@ -194,13 +194,13 @@ mod tests { fn inserts_parens_for_function_calls() { covers!(inserts_parens_for_function_calls); assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn no_args() {} fn main() { no_<|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "main", @@ -220,15 +220,15 @@ mod tests { ⋮ }, ⋮] "### - ); + ); assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" fn with_args(x: i32, y: String) {} fn main() { with_<|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "main", @@ -248,10 +248,10 @@ mod tests { ⋮ }, ⋮] "### - ); + ); assert_debug_snapshot_matches!( - do_reference_completion( - r" + do_reference_completion( + r" struct S {} impl S { fn foo(&self) {} @@ -260,8 +260,8 @@ mod tests { s.f<|> } " - ), -@r###" + ), + @r###" ⋮[ ⋮ CompletionItem { ⋮ label: "foo", @@ -273,20 +273,20 @@ mod tests { ⋮ }, ⋮] "### - ); + ); } #[test] fn dont_render_function_parens_in_use_item() { assert_debug_snapshot_matches!( - do_reference_completion( - " + do_reference_completion( + " //- /lib.rs mod m { pub fn foo() {} } use crate::m::f<|>; " - ), -@r#"[ + ), + @r#"[ CompletionItem { label: "foo", source_range: [40; 41), @@ -296,22 +296,22 @@ mod tests { detail: "pub fn foo()", }, ]"# - ); + ); } #[test] fn dont_render_function_parens_if_already_call() { assert_debug_snapshot_matches!( - do_reference_completion( - " + do_reference_completion( + " //- /lib.rs fn frobnicate() {} fn main() { frob<|>(); } " - ), -@r#"[ + ), + @r#"[ CompletionItem { label: "frobnicate", source_range: [35; 39), @@ -329,10 +329,10 @@ mod tests { detail: "fn main()", }, ]"# - ); + ); assert_debug_snapshot_matches!( - do_reference_completion( - " + do_reference_completion( + " //- /lib.rs struct Foo {} impl Foo { fn new() -> Foo {} } @@ -340,8 +340,8 @@ mod tests { Foo::ne<|>(); } " - ), -@r#"[ + ), + @r#"[ CompletionItem { label: "new", source_range: [67; 69), @@ -351,6 +351,6 @@ mod tests { detail: "fn new() -> Foo", }, ]"# - ); + ); } } diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index 38e1fe323..b026dfa59 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs @@ -205,7 +205,7 @@ fn very_obsolete() {} .unwrap(); let structure = file_structure(&file); assert_debug_snapshot_matches!(structure, -@r#"[ + @r#"[ StructureNode { parent: None, label: "Foo", @@ -390,6 +390,6 @@ fn very_obsolete() {} deprecated: true, }, ]"# - ); + ); } } diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 7a3a574ad..09c082de9 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -93,7 +93,7 @@ mod tests { ); let runnables = analysis.runnables(pos.file_id).unwrap(); assert_debug_snapshot_matches!(&runnables, -@r#"[ + @r#"[ Runnable { range: [1; 21), kind: Bin, @@ -111,7 +111,7 @@ mod tests { }, }, ]"# - ); + ); } #[test] @@ -127,8 +127,8 @@ mod tests { "#, ); let runnables = analysis.runnables(pos.file_id).unwrap(); - assert_debug_snapshot_matches!(&runnables, -@r#"[ + assert_debug_snapshot_matches!(&runnables, + @r#"[ Runnable { range: [1; 59), kind: TestMod { @@ -142,7 +142,7 @@ mod tests { }, }, ]"# - ); + ); } #[test] @@ -161,7 +161,7 @@ mod tests { ); let runnables = analysis.runnables(pos.file_id).unwrap(); assert_debug_snapshot_matches!(&runnables, -@r#"[ + @r#"[ Runnable { range: [23; 85), kind: TestMod { @@ -175,7 +175,7 @@ mod tests { }, }, ]"# - ); + ); } #[test] @@ -196,7 +196,7 @@ mod tests { ); let runnables = analysis.runnables(pos.file_id).unwrap(); assert_debug_snapshot_matches!(&runnables, -@r#"[ + @r#"[ Runnable { range: [41; 115), kind: TestMod { @@ -210,7 +210,7 @@ mod tests { }, }, ]"# - ); + ); } #[test] -- cgit v1.2.3