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)]
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<CompletionItem> {
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<T>() {
<|>
}
"
),
@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<T> {
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,
},
]"#
);
);
}
}

View file

@ -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<CompletionItem> {
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 {
},
]
"###
);
);
}
}

View file

@ -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<CompletionItem> {
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",
},
]"#
);
);
}
}

View file

@ -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,
},
]"#
);
);
}
}

View file

@ -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]