cargo format

This commit is contained in:
Phil Ellison 2019-07-28 12:08:06 +01:00
parent 9f6909c0ce
commit 5c4df97996
5 changed files with 117 additions and 117 deletions

View file

@ -122,7 +122,7 @@ impl ImportResolver {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind}; 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<CompletionItem> { fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)
@ -131,16 +131,16 @@ mod tests {
#[test] #[test]
fn completes_bindings_from_let() { fn completes_bindings_from_let() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn quux(x: i32) { fn quux(x: i32) {
let y = 92; let y = 92;
1 + <|>; 1 + <|>;
let z = (); let z = ();
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "quux", label: "quux",
@ -168,14 +168,14 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_bindings_from_if_let() { fn completes_bindings_from_if_let() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn quux() { fn quux() {
if let Some(x) = foo() { if let Some(x) = foo() {
let y = 92; let y = 92;
@ -186,8 +186,8 @@ mod tests {
} }
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "a", label: "a",
@ -214,22 +214,22 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_bindings_from_for() { fn completes_bindings_from_for() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn quux() { fn quux() {
for x in &[1, 2, 3] { for x in &[1, 2, 3] {
<|> <|>
} }
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "quux", label: "quux",
@ -248,20 +248,20 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_generic_params() { fn completes_generic_params() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn quux<T>() { fn quux<T>() {
<|> <|>
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "T", label: "T",
@ -280,20 +280,20 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_generic_params_in_struct() { fn completes_generic_params_in_struct() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
struct X<T> { struct X<T> {
x: <|> x: <|>
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "T", label: "T",
@ -311,22 +311,22 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_module_items() { fn completes_module_items() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
struct Foo; struct Foo;
enum Baz {} enum Baz {}
fn quux() { fn quux() {
<|> <|>
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "Baz", label: "Baz",
@ -352,22 +352,22 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_extern_prelude() { fn completes_extern_prelude() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
//- /lib.rs //- /lib.rs
use <|>; use <|>;
//- /other_crate/lib.rs //- /other_crate/lib.rs
// nothing here // nothing here
" "
), ),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "other_crate", label: "other_crate",
source_range: [4; 4), source_range: [4; 4),
@ -376,22 +376,22 @@ mod tests {
kind: Module, kind: Module,
}, },
]"# ]"#
); );
} }
#[test] #[test]
fn completes_module_items_in_nested_modules() { fn completes_module_items_in_nested_modules() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
struct Foo; struct Foo;
mod m { mod m {
struct Bar; struct Bar;
fn quux() { <|> } fn quux() { <|> }
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "Bar", label: "Bar",
@ -410,19 +410,19 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_return_type() { fn completes_return_type() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
struct Foo; struct Foo;
fn x() -> <|> fn x() -> <|>
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "Foo", label: "Foo",
@ -441,14 +441,14 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn dont_show_both_completions_for_shadowing() { fn dont_show_both_completions_for_shadowing() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn foo() { fn foo() {
let bar = 92; let bar = 92;
{ {
@ -457,8 +457,8 @@ mod tests {
} }
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "bar", label: "bar",
@ -478,14 +478,14 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn completes_self_in_methods() { fn completes_self_in_methods() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion(r"impl S { fn foo(&self) { <|> } }"), do_reference_completion(r"impl S { fn foo(&self) { <|> } }"),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "Self", label: "Self",
source_range: [25; 25), source_range: [25; 25),
@ -502,14 +502,14 @@ mod tests {
detail: "&{unknown}", detail: "&{unknown}",
}, },
]"# ]"#
); );
} }
#[test] #[test]
fn completes_prelude() { fn completes_prelude() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
" "
//- /main.rs //- /main.rs
fn foo() { let x: <|> } fn foo() { let x: <|> }
@ -521,8 +521,8 @@ mod tests {
struct Option; struct Option;
} }
" "
), ),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "Option", label: "Option",
source_range: [18; 18), source_range: [18; 18),
@ -546,6 +546,6 @@ mod tests {
kind: Module, kind: Module,
}, },
]"# ]"#
); );
} }
} }

View file

@ -40,7 +40,7 @@ fn ${1:feature}() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind}; 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<CompletionItem> { fn do_snippet_completion(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Snippet) do_completion(code, CompletionKind::Snippet)
@ -49,8 +49,8 @@ mod tests {
#[test] #[test]
fn completes_snippets_in_expressions() { fn completes_snippets_in_expressions() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_snippet_completion(r"fn foo(x: i32) { <|> }"), do_snippet_completion(r"fn foo(x: i32) { <|> }"),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "pd", label: "pd",
source_range: [17; 17), source_range: [17; 17),
@ -66,33 +66,33 @@ mod tests {
kind: Snippet, kind: Snippet,
}, },
]"# ]"#
); );
} }
#[test] #[test]
fn should_not_complete_snippets_in_path() { fn should_not_complete_snippets_in_path() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"),
@r#"[]"# @r#"[]"#
); );
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), do_snippet_completion(r"fn foo(x: i32) { ::<|> }"),
@r#"[]"# @r#"[]"#
); );
} }
#[test] #[test]
fn completes_snippets_in_items() { fn completes_snippets_in_items() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_snippet_completion( do_snippet_completion(
r" r"
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
<|> <|>
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "Test function", label: "Test function",
@ -111,6 +111,6 @@ mod tests {
}, },
] ]
"### "###
); );
} }
} }

View file

@ -182,9 +182,9 @@ impl Completions {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_utils::covers;
use crate::completion::{do_completion, CompletionItem, CompletionKind}; 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<CompletionItem> { fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)
@ -194,13 +194,13 @@ mod tests {
fn inserts_parens_for_function_calls() { fn inserts_parens_for_function_calls() {
covers!(inserts_parens_for_function_calls); covers!(inserts_parens_for_function_calls);
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn no_args() {} fn no_args() {}
fn main() { no_<|> } fn main() { no_<|> }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "main", label: "main",
@ -220,15 +220,15 @@ mod tests {
}, },
] ]
"### "###
); );
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
fn with_args(x: i32, y: String) {} fn with_args(x: i32, y: String) {}
fn main() { with_<|> } fn main() { with_<|> }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "main", label: "main",
@ -248,10 +248,10 @@ mod tests {
}, },
] ]
"### "###
); );
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
r" r"
struct S {} struct S {}
impl S { impl S {
fn foo(&self) {} fn foo(&self) {}
@ -260,8 +260,8 @@ mod tests {
s.f<|> s.f<|>
} }
" "
), ),
@r###" @r###"
[ [
CompletionItem { CompletionItem {
label: "foo", label: "foo",
@ -273,20 +273,20 @@ mod tests {
}, },
] ]
"### "###
); );
} }
#[test] #[test]
fn dont_render_function_parens_in_use_item() { fn dont_render_function_parens_in_use_item() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
" "
//- /lib.rs //- /lib.rs
mod m { pub fn foo() {} } mod m { pub fn foo() {} }
use crate::m::f<|>; use crate::m::f<|>;
" "
), ),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "foo", label: "foo",
source_range: [40; 41), source_range: [40; 41),
@ -296,22 +296,22 @@ mod tests {
detail: "pub fn foo()", detail: "pub fn foo()",
}, },
]"# ]"#
); );
} }
#[test] #[test]
fn dont_render_function_parens_if_already_call() { fn dont_render_function_parens_if_already_call() {
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
" "
//- /lib.rs //- /lib.rs
fn frobnicate() {} fn frobnicate() {}
fn main() { fn main() {
frob<|>(); frob<|>();
} }
" "
), ),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "frobnicate", label: "frobnicate",
source_range: [35; 39), source_range: [35; 39),
@ -329,10 +329,10 @@ mod tests {
detail: "fn main()", detail: "fn main()",
}, },
]"# ]"#
); );
assert_debug_snapshot_matches!( assert_debug_snapshot_matches!(
do_reference_completion( do_reference_completion(
" "
//- /lib.rs //- /lib.rs
struct Foo {} struct Foo {}
impl Foo { fn new() -> Foo {} } impl Foo { fn new() -> Foo {} }
@ -340,8 +340,8 @@ mod tests {
Foo::ne<|>(); Foo::ne<|>();
} }
" "
), ),
@r#"[ @r#"[
CompletionItem { CompletionItem {
label: "new", label: "new",
source_range: [67; 69), source_range: [67; 69),
@ -351,6 +351,6 @@ mod tests {
detail: "fn new() -> Foo", detail: "fn new() -> Foo",
}, },
]"# ]"#
); );
} }
} }

View file

@ -205,7 +205,7 @@ fn very_obsolete() {}
.unwrap(); .unwrap();
let structure = file_structure(&file); let structure = file_structure(&file);
assert_debug_snapshot_matches!(structure, assert_debug_snapshot_matches!(structure,
@r#"[ @r#"[
StructureNode { StructureNode {
parent: None, parent: None,
label: "Foo", label: "Foo",
@ -390,6 +390,6 @@ fn very_obsolete() {}
deprecated: true, deprecated: true,
}, },
]"# ]"#
); );
} }
} }

View file

@ -93,7 +93,7 @@ mod tests {
); );
let runnables = analysis.runnables(pos.file_id).unwrap(); let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot_matches!(&runnables, assert_debug_snapshot_matches!(&runnables,
@r#"[ @r#"[
Runnable { Runnable {
range: [1; 21), range: [1; 21),
kind: Bin, kind: Bin,
@ -111,7 +111,7 @@ mod tests {
}, },
}, },
]"# ]"#
); );
} }
#[test] #[test]
@ -127,8 +127,8 @@ mod tests {
"#, "#,
); );
let runnables = analysis.runnables(pos.file_id).unwrap(); let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot_matches!(&runnables, assert_debug_snapshot_matches!(&runnables,
@r#"[ @r#"[
Runnable { Runnable {
range: [1; 59), range: [1; 59),
kind: TestMod { kind: TestMod {
@ -142,7 +142,7 @@ mod tests {
}, },
}, },
]"# ]"#
); );
} }
#[test] #[test]
@ -161,7 +161,7 @@ mod tests {
); );
let runnables = analysis.runnables(pos.file_id).unwrap(); let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot_matches!(&runnables, assert_debug_snapshot_matches!(&runnables,
@r#"[ @r#"[
Runnable { Runnable {
range: [23; 85), range: [23; 85),
kind: TestMod { kind: TestMod {
@ -175,7 +175,7 @@ mod tests {
}, },
}, },
]"# ]"#
); );
} }
#[test] #[test]
@ -196,7 +196,7 @@ mod tests {
); );
let runnables = analysis.runnables(pos.file_id).unwrap(); let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot_matches!(&runnables, assert_debug_snapshot_matches!(&runnables,
@r#"[ @r#"[
Runnable { Runnable {
range: [41; 115), range: [41; 115),
kind: TestMod { kind: TestMod {
@ -210,7 +210,7 @@ mod tests {
}, },
}, },
]"# ]"#
); );
} }
#[test] #[test]