mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Merge pull request #18887 from vishruth-thimmaiah/refactor_completions_tests
refactor test helpers within ide-completions
This commit is contained in:
commit
d3a49d3783
@ -214,25 +214,13 @@ fn complete_methods(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{
|
use crate::tests::{check_edit, check_no_kw, check_with_private_editable};
|
||||||
check_edit, completion_list_no_kw, completion_list_no_kw_with_private_editable,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_with_private_editable(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw_with_private_editable(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_field_and_method_completion() {
|
fn test_struct_field_and_method_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S { foo: u32 }
|
struct S { foo: u32 }
|
||||||
impl S {
|
impl S {
|
||||||
@ -249,7 +237,7 @@ fn foo(s: S) { s.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_unstable_method_on_stable() {
|
fn no_unstable_method_on_stable() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
fn foo(s: std::S) { s.$0 }
|
fn foo(s: std::S) { s.$0 }
|
||||||
@ -266,7 +254,7 @@ impl S {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unstable_method_on_nightly() {
|
fn unstable_method_on_nightly() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
@ -286,7 +274,7 @@ impl S {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_field_completion_self() {
|
fn test_struct_field_completion_self() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S { the_field: (u32,) }
|
struct S { the_field: (u32,) }
|
||||||
impl S {
|
impl S {
|
||||||
@ -302,7 +290,7 @@ impl S {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_field_completion_autoderef() {
|
fn test_struct_field_completion_autoderef() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A { the_field: (u32, i32) }
|
struct A { the_field: (u32, i32) }
|
||||||
impl A {
|
impl A {
|
||||||
@ -318,7 +306,7 @@ impl A {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_struct_field_completion_for_method_call() {
|
fn test_no_struct_field_completion_for_method_call() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A { the_field: u32 }
|
struct A { the_field: u32 }
|
||||||
fn foo(a: A) { a.$0() }
|
fn foo(a: A) { a.$0() }
|
||||||
@ -329,7 +317,7 @@ fn foo(a: A) { a.$0() }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_visibility_filtering() {
|
fn test_visibility_filtering() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib new_source_root:local
|
//- /lib.rs crate:lib new_source_root:local
|
||||||
pub mod m {
|
pub mod m {
|
||||||
@ -348,7 +336,7 @@ fn foo(a: lib::m::A) { a.$0 }
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib new_source_root:library
|
//- /lib.rs crate:lib new_source_root:library
|
||||||
pub mod m {
|
pub mod m {
|
||||||
@ -367,7 +355,7 @@ fn foo(a: lib::m::A) { a.$0 }
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib new_source_root:library
|
//- /lib.rs crate:lib new_source_root:library
|
||||||
pub mod m {
|
pub mod m {
|
||||||
@ -384,7 +372,7 @@ fn foo(a: lib::m::A) { a.$0 }
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib new_source_root:local
|
//- /lib.rs crate:lib new_source_root:local
|
||||||
pub struct A {}
|
pub struct A {}
|
||||||
@ -402,7 +390,7 @@ fn foo(a: lib::A) { a.$0 }
|
|||||||
me pub_method() fn(&self)
|
me pub_method() fn(&self)
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib new_source_root:library
|
//- /lib.rs crate:lib new_source_root:library
|
||||||
pub struct A {}
|
pub struct A {}
|
||||||
@ -524,7 +512,7 @@ fn foo(a: lib::A) { a.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_local_impls() {
|
fn test_local_impls() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
pub struct A {}
|
pub struct A {}
|
||||||
mod m {
|
mod m {
|
||||||
@ -553,7 +541,7 @@ fn foo(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_doc_hidden_filtering() {
|
fn test_doc_hidden_filtering() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs crate:lib deps:dep
|
//- /lib.rs crate:lib deps:dep
|
||||||
fn foo(a: dep::A) { a.$0 }
|
fn foo(a: dep::A) { a.$0 }
|
||||||
@ -580,7 +568,7 @@ impl A {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_union_field_completion() {
|
fn test_union_field_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
union U { field: u8, other: u16 }
|
union U { field: u8, other: u16 }
|
||||||
fn foo(u: U) { u.$0 }
|
fn foo(u: U) { u.$0 }
|
||||||
@ -594,7 +582,7 @@ fn foo(u: U) { u.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_method_completion_only_fitting_impls() {
|
fn test_method_completion_only_fitting_impls() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A<T> {}
|
struct A<T> {}
|
||||||
impl A<u32> {
|
impl A<u32> {
|
||||||
@ -613,7 +601,7 @@ fn foo(a: A<u32>) { a.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trait_method_completion() {
|
fn test_trait_method_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A {}
|
struct A {}
|
||||||
trait Trait { fn the_method(&self); }
|
trait Trait { fn the_method(&self); }
|
||||||
@ -643,7 +631,7 @@ fn foo(a: A) { a.the_method();$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trait_method_completion_deduplicated() {
|
fn test_trait_method_completion_deduplicated() {
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
struct A {}
|
struct A {}
|
||||||
trait Trait { fn the_method(&self); }
|
trait Trait { fn the_method(&self); }
|
||||||
@ -658,7 +646,7 @@ fn foo(a: &A) { a.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_trait_method_from_other_module() {
|
fn completes_trait_method_from_other_module() {
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
struct A {}
|
struct A {}
|
||||||
mod m {
|
mod m {
|
||||||
@ -676,7 +664,7 @@ fn foo(a: A) { a.$0 }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_non_self_method() {
|
fn test_no_non_self_method() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A {}
|
struct A {}
|
||||||
impl A {
|
impl A {
|
||||||
@ -692,7 +680,7 @@ fn foo(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_field_completion() {
|
fn test_tuple_field_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let b = (0, 3.14);
|
let b = (0, 3.14);
|
||||||
@ -708,7 +696,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_struct_field_completion() {
|
fn test_tuple_struct_field_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S(i32, f64);
|
struct S(i32, f64);
|
||||||
fn foo() {
|
fn foo() {
|
||||||
@ -725,7 +713,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_field_inference() {
|
fn test_tuple_field_inference() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
pub struct S;
|
pub struct S;
|
||||||
impl S { pub fn blah(&self) {} }
|
impl S { pub fn blah(&self) {} }
|
||||||
@ -747,7 +735,7 @@ impl T {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_field_no_same_name() {
|
fn test_field_no_same_name() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
struct A { field: u8 }
|
struct A { field: u8 }
|
||||||
@ -770,7 +758,7 @@ fn test(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_field_no_same_index() {
|
fn test_tuple_field_no_same_index() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
struct A(u8);
|
struct A(u8);
|
||||||
@ -793,7 +781,7 @@ fn test(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_struct_deref_to_tuple_no_same_index() {
|
fn test_tuple_struct_deref_to_tuple_no_same_index() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
struct A(u8);
|
struct A(u8);
|
||||||
@ -815,7 +803,7 @@ fn test(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_completion_works_in_consts() {
|
fn test_completion_works_in_consts() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct A { the_field: u32 }
|
struct A { the_field: u32 }
|
||||||
const X: u32 = {
|
const X: u32 = {
|
||||||
@ -830,7 +818,7 @@ const X: u32 = {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn works_in_simple_macro_1() {
|
fn works_in_simple_macro_1() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
struct A { the_field: u32 }
|
struct A { the_field: u32 }
|
||||||
@ -847,7 +835,7 @@ fn foo(a: A) {
|
|||||||
#[test]
|
#[test]
|
||||||
fn works_in_simple_macro_2() {
|
fn works_in_simple_macro_2() {
|
||||||
// this doesn't work yet because the macro doesn't expand without the token -- maybe it can be fixed with better recovery
|
// this doesn't work yet because the macro doesn't expand without the token -- maybe it can be fixed with better recovery
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
struct A { the_field: u32 }
|
struct A { the_field: u32 }
|
||||||
@ -863,7 +851,7 @@ fn foo(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn works_in_simple_macro_recursive_1() {
|
fn works_in_simple_macro_recursive_1() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
struct A { the_field: u32 }
|
struct A { the_field: u32 }
|
||||||
@ -879,7 +867,7 @@ fn foo(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_expansion_resilient() {
|
fn macro_expansion_resilient() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! d {
|
macro_rules! d {
|
||||||
() => {};
|
() => {};
|
||||||
@ -905,7 +893,7 @@ fn foo(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_method_completion_issue_3547() {
|
fn test_method_completion_issue_3547() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct HashSet<T> {}
|
struct HashSet<T> {}
|
||||||
impl<T> HashSet<T> {
|
impl<T> HashSet<T> {
|
||||||
@ -924,7 +912,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_method_call_when_receiver_is_a_macro_call() {
|
fn completes_method_call_when_receiver_is_a_macro_call() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S;
|
struct S;
|
||||||
impl S { fn foo(&self) {} }
|
impl S { fn foo(&self) {} }
|
||||||
@ -939,7 +927,7 @@ fn main() { make_s!().f$0; }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_after_macro_call_in_submodule() {
|
fn completes_after_macro_call_in_submodule() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! empty {
|
macro_rules! empty {
|
||||||
() => {};
|
() => {};
|
||||||
@ -967,7 +955,7 @@ mod foo {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_8931() {
|
fn issue_8931() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fn
|
//- minicore: fn
|
||||||
struct S;
|
struct S;
|
||||||
@ -994,7 +982,7 @@ impl S {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_bare_fields_and_methods_in_methods() {
|
fn completes_bare_fields_and_methods_in_methods() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { field: i32 }
|
struct Foo { field: i32 }
|
||||||
|
|
||||||
@ -1008,7 +996,7 @@ impl Foo { fn foo(&self) { $0 } }"#,
|
|||||||
bt u32 u32
|
bt u32 u32
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct Foo(i32);
|
struct Foo(i32);
|
||||||
|
|
||||||
@ -1026,7 +1014,7 @@ impl Foo { fn foo(&mut self) { $0 } }"#,
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_completion_after_dot() {
|
fn macro_completion_after_dot() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m {
|
macro_rules! m {
|
||||||
($e:expr) => { $e };
|
($e:expr) => { $e };
|
||||||
@ -1051,7 +1039,7 @@ fn f() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_method_call_when_receiver_type_has_errors_issue_10297() {
|
fn completes_method_call_when_receiver_type_has_errors_issue_10297() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: iterator, sized
|
//- minicore: iterator, sized
|
||||||
struct Vec<T>;
|
struct Vec<T>;
|
||||||
@ -1102,7 +1090,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_12484() {
|
fn issue_12484() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: sized
|
//- minicore: sized
|
||||||
trait SizeUser {
|
trait SizeUser {
|
||||||
@ -1124,7 +1112,7 @@ fn test(thing: impl Encrypt) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn only_consider_same_type_once() {
|
fn only_consider_same_type_once() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
struct A(u8);
|
struct A(u8);
|
||||||
@ -1150,7 +1138,7 @@ fn test(a: A) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_inference_var_in_completion() {
|
fn no_inference_var_in_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S<T>(T);
|
struct S<T>(T);
|
||||||
fn test(s: S<Unknown>) {
|
fn test(s: S<Unknown>) {
|
||||||
@ -1165,7 +1153,7 @@ fn test(s: S<Unknown>) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn assoc_impl_1() {
|
fn assoc_impl_1() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -1206,7 +1194,7 @@ impl<F: core::ops::Deref<Target = impl Bar>> Foo<F> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn assoc_impl_2() {
|
fn assoc_impl_2() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: deref
|
//- minicore: deref
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -1242,7 +1230,7 @@ impl<B: Bar, F: core::ops::Deref<Target = B>> Foo<F> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_function_field_completion() {
|
fn test_struct_function_field_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct S { va_field: u32, fn_field: fn() }
|
struct S { va_field: u32, fn_field: fn() }
|
||||||
fn foo() { S { va_field: 0, fn_field: || {} }.fi$0() }
|
fn foo() { S { va_field: 0, fn_field: || {} }.fi$0() }
|
||||||
@ -1267,7 +1255,7 @@ fn foo() { (S { va_field: 0, fn_field: || {} }.fn_field)() }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tuple_function_field_completion() {
|
fn test_tuple_function_field_completion() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct B(u32, fn())
|
struct B(u32, fn())
|
||||||
fn foo() {
|
fn foo() {
|
||||||
@ -1301,7 +1289,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fn_field_dot_access_method_has_parens_false() {
|
fn test_fn_field_dot_access_method_has_parens_false() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { baz: fn() }
|
struct Foo { baz: fn() }
|
||||||
impl Foo {
|
impl Foo {
|
||||||
|
@ -65,18 +65,13 @@ pub(crate) fn complete_extern_abi(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list_no_kw};
|
use crate::tests::{check_edit, check_no_kw};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn only_completes_in_string_literals() {
|
fn only_completes_in_string_literals() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
$0 fn foo {}
|
$0 fn foo {}
|
||||||
"#,
|
"#,
|
||||||
@ -86,7 +81,7 @@ $0 fn foo {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn requires_extern_prefix() {
|
fn requires_extern_prefix() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
"$0" fn foo {}
|
"$0" fn foo {}
|
||||||
"#,
|
"#,
|
||||||
@ -96,7 +91,7 @@ $0 fn foo {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn works() {
|
fn works() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
extern "$0" fn foo {}
|
extern "$0" fn foo {}
|
||||||
"#,
|
"#,
|
||||||
|
@ -61,18 +61,13 @@ pub(crate) fn format_string(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list_no_kw};
|
use crate::tests::{check_edit, check_no_kw};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn works_when_wrapped() {
|
fn works_when_wrapped() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
@ -89,7 +84,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_without_brace() {
|
fn no_completion_without_brace() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -514,18 +514,13 @@ fn function_declaration(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list_no_kw};
|
use crate::tests::{check_edit, check_no_kw};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_inside_fn() {
|
fn no_completion_inside_fn() {
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(); fn test2(); }
|
trait Test { fn test(); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -544,7 +539,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(); fn test2(); }
|
trait Test { fn test(); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -558,7 +553,7 @@ impl Test for T {
|
|||||||
expect![[""]],
|
expect![[""]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(); fn test2(); }
|
trait Test { fn test(); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -573,7 +568,7 @@ impl Test for T {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// https://github.com/rust-lang/rust-analyzer/pull/5976#issuecomment-692332191
|
// https://github.com/rust-lang/rust-analyzer/pull/5976#issuecomment-692332191
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(); fn test2(); }
|
trait Test { fn test(); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -587,7 +582,7 @@ impl Test for T {
|
|||||||
expect![[r#""#]],
|
expect![[r#""#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(_: i32); fn test2(); }
|
trait Test { fn test(_: i32); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -606,7 +601,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { fn test(_: fn()); fn test2(); }
|
trait Test { fn test(_: fn()); fn test2(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -624,7 +619,7 @@ impl Test for T {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_inside_const() {
|
fn no_completion_inside_const() {
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: fn(); const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: fn(); const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -636,7 +631,7 @@ impl Test for T {
|
|||||||
expect![[r#""#]],
|
expect![[r#""#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -653,7 +648,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -670,7 +665,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -689,7 +684,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -703,7 +698,7 @@ impl Test for T {
|
|||||||
expect![[""]],
|
expect![[""]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -720,7 +715,7 @@ impl Test for T {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_inside_type() {
|
fn no_completion_inside_type() {
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { type Test; type Test2; fn test(); }
|
trait Test { type Test; type Test2; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -737,7 +732,7 @@ impl Test for T {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_no_kw(
|
||||||
r"
|
r"
|
||||||
trait Test { type Test; type Test2; fn test(); }
|
trait Test { type Test; type Test2; fn test(); }
|
||||||
struct T;
|
struct T;
|
||||||
@ -1263,7 +1258,7 @@ impl Foo<u32> for Bar {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn works_directly_in_impl() {
|
fn works_directly_in_impl() {
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
trait Tr {
|
trait Tr {
|
||||||
fn required();
|
fn required();
|
||||||
@ -1277,7 +1272,7 @@ impl Tr for () {
|
|||||||
fn fn required()
|
fn fn required()
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_no_kw(
|
||||||
r#"
|
r#"
|
||||||
trait Tr {
|
trait Tr {
|
||||||
fn provided() {}
|
fn provided() {}
|
||||||
|
@ -32,14 +32,9 @@ pub(crate) fn complete_for_and_where(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list};
|
use crate::tests::{check, check_edit};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_else_edit_after_if() {
|
fn test_else_edit_after_if() {
|
||||||
|
@ -59,14 +59,9 @@ pub(crate) fn complete_label(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list};
|
use crate::tests::{check, check_edit};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_lifetime_edit() {
|
fn check_lifetime_edit() {
|
||||||
|
@ -159,14 +159,9 @@ fn module_chain_to_containing_module_file(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::completion_list;
|
use crate::tests::check;
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lib_module_completion() {
|
fn lib_module_completion() {
|
||||||
|
@ -401,18 +401,13 @@ fn add_custom_postfix_completions(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests::{check_edit, check_edit_with_config, completion_list, TEST_CONFIG},
|
tests::{check, check_edit, check_edit_with_config, TEST_CONFIG},
|
||||||
CompletionConfig, Snippet,
|
CompletionConfig, Snippet,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn postfix_completion_works_for_trivial_path_expression() {
|
fn postfix_completion_works_for_trivial_path_expression() {
|
||||||
check(
|
check(
|
||||||
|
@ -253,11 +253,34 @@ pub(crate) fn check_edit_with_config(
|
|||||||
assert_eq_text!(&ra_fixture_after, &actual)
|
assert_eq_text!(&ra_fixture_after, &actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_empty(ra_fixture: &str, expect: Expect) {
|
pub(crate) fn check(ra_fixture: &str, expect: Expect) {
|
||||||
let actual = completion_list(ra_fixture);
|
let actual = completion_list(ra_fixture);
|
||||||
expect.assert_eq(&actual);
|
expect.assert_eq(&actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_with_base_items(ra_fixture: &str, expect: Expect) {
|
||||||
|
check(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"), expect)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_no_kw(ra_fixture: &str, expect: Expect) {
|
||||||
|
let actual = completion_list_no_kw(ra_fixture);
|
||||||
|
expect.assert_eq(&actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_with_private_editable(ra_fixture: &str, expect: Expect) {
|
||||||
|
let actual = completion_list_no_kw_with_private_editable(ra_fixture);
|
||||||
|
expect.assert_eq(&actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_with_trigger_character(
|
||||||
|
ra_fixture: &str,
|
||||||
|
trigger_character: Option<char>,
|
||||||
|
expect: Expect,
|
||||||
|
) {
|
||||||
|
let actual = completion_list_with_trigger_character(ra_fixture, trigger_character);
|
||||||
|
expect.assert_eq(&actual)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_all_items(
|
pub(crate) fn get_all_items(
|
||||||
config: CompletionConfig<'_>,
|
config: CompletionConfig<'_>,
|
||||||
code: &str,
|
code: &str,
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
//! Completion tests for attributes.
|
//! Completion tests for attributes.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, completion_list};
|
use crate::tests::{check, check_edit};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_helpers() {
|
fn derive_helpers() {
|
||||||
@ -788,14 +783,9 @@ mod cfg {
|
|||||||
mod derive {
|
mod derive {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn check_derive(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_for_incorrect_derive() {
|
fn no_completion_for_incorrect_derive() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
||||||
#[derive{$0)] struct Test;
|
#[derive{$0)] struct Test;
|
||||||
@ -806,7 +796,7 @@ mod derive {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_derive() {
|
fn empty_derive() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
||||||
#[derive($0)] struct Test;
|
#[derive($0)] struct Test;
|
||||||
@ -828,7 +818,7 @@ mod derive {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_with_input_before() {
|
fn derive_with_input_before() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
||||||
#[derive(serde::Serialize, PartialEq, $0)] struct Test;
|
#[derive(serde::Serialize, PartialEq, $0)] struct Test;
|
||||||
@ -849,7 +839,7 @@ mod derive {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_with_input_after() {
|
fn derive_with_input_after() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
||||||
#[derive($0 serde::Serialize, PartialEq)] struct Test;
|
#[derive($0 serde::Serialize, PartialEq)] struct Test;
|
||||||
@ -870,7 +860,7 @@ mod derive {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_with_existing_derives() {
|
fn derive_with_existing_derives() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
//- minicore: derive, copy, clone, ord, eq, default, fmt
|
||||||
#[derive(PartialEq, Eq, Or$0)] struct Test;
|
#[derive(PartialEq, Eq, Or$0)] struct Test;
|
||||||
@ -890,7 +880,7 @@ mod derive {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_flyimport() {
|
fn derive_flyimport() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- proc_macros: derive_identity
|
//- proc_macros: derive_identity
|
||||||
//- minicore: derive
|
//- minicore: derive
|
||||||
@ -904,7 +894,7 @@ mod derive {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- proc_macros: derive_identity
|
//- proc_macros: derive_identity
|
||||||
//- minicore: derive
|
//- minicore: derive
|
||||||
@ -940,7 +930,7 @@ use proc_macros::DeriveIdentity;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn qualified() {
|
fn qualified() {
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- proc_macros: derive_identity
|
//- proc_macros: derive_identity
|
||||||
//- minicore: derive, copy, clone
|
//- minicore: derive, copy, clone
|
||||||
@ -950,7 +940,7 @@ use proc_macros::DeriveIdentity;
|
|||||||
de DeriveIdentity proc_macro DeriveIdentity
|
de DeriveIdentity proc_macro DeriveIdentity
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_derive(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- proc_macros: derive_identity
|
//- proc_macros: derive_identity
|
||||||
//- minicore: derive, copy, clone
|
//- minicore: derive, copy, clone
|
||||||
@ -1056,19 +1046,14 @@ mod lint {
|
|||||||
mod repr {
|
mod repr {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn check_repr(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completion_for_incorrect_repr() {
|
fn no_completion_for_incorrect_repr() {
|
||||||
check_repr(r#"#[repr{$0)] struct Test;"#, expect![[]])
|
check(r#"#[repr{$0)] struct Test;"#, expect![[]])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty() {
|
fn empty() {
|
||||||
check_repr(
|
check(
|
||||||
r#"#[repr($0)] struct Test;"#,
|
r#"#[repr($0)] struct Test;"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ba C
|
ba C
|
||||||
@ -1093,12 +1078,12 @@ mod repr {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transparent() {
|
fn transparent() {
|
||||||
check_repr(r#"#[repr(transparent, $0)] struct Test;"#, expect![[r#""#]]);
|
check(r#"#[repr(transparent, $0)] struct Test;"#, expect![[r#""#]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn align() {
|
fn align() {
|
||||||
check_repr(
|
check(
|
||||||
r#"#[repr(align(1), $0)] struct Test;"#,
|
r#"#[repr(align(1), $0)] struct Test;"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ba C
|
ba C
|
||||||
@ -1121,7 +1106,7 @@ mod repr {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn packed() {
|
fn packed() {
|
||||||
check_repr(
|
check(
|
||||||
r#"#[repr(packed, $0)] struct Test;"#,
|
r#"#[repr(packed, $0)] struct Test;"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ba C
|
ba C
|
||||||
@ -1144,7 +1129,7 @@ mod repr {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn c() {
|
fn c() {
|
||||||
check_repr(
|
check(
|
||||||
r#"#[repr(C, $0)] struct Test;"#,
|
r#"#[repr(C, $0)] struct Test;"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ba align($0)
|
ba align($0)
|
||||||
@ -1167,7 +1152,7 @@ mod repr {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prim() {
|
fn prim() {
|
||||||
check_repr(
|
check(
|
||||||
r#"#[repr(usize, $0)] struct Test;"#,
|
r#"#[repr(usize, $0)] struct Test;"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ba C
|
ba C
|
||||||
|
@ -4,17 +4,12 @@ use expect_test::{expect, Expect};
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::AutoImportExclusionType,
|
config::AutoImportExclusionType,
|
||||||
tests::{
|
tests::{
|
||||||
check_edit, check_empty, completion_list, completion_list_with_config, BASE_ITEMS_FIXTURE,
|
check, check_edit, check_with_base_items, completion_list_with_config, BASE_ITEMS_FIXTURE,
|
||||||
TEST_CONFIG,
|
TEST_CONFIG,
|
||||||
},
|
},
|
||||||
CompletionConfig,
|
CompletionConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_with_config(config: CompletionConfig<'_>, ra_fixture: &str, expect: Expect) {
|
fn check_with_config(config: CompletionConfig<'_>, ra_fixture: &str, expect: Expect) {
|
||||||
let actual = completion_list_with_config(
|
let actual = completion_list_with_config(
|
||||||
config,
|
config,
|
||||||
@ -28,7 +23,7 @@ fn check_with_config(config: CompletionConfig<'_>, ra_fixture: &str, expect: Exp
|
|||||||
#[test]
|
#[test]
|
||||||
fn complete_literal_struct_with_a_private_field() {
|
fn complete_literal_struct_with_a_private_field() {
|
||||||
// `FooDesc.bar` is private, the completion should not be triggered.
|
// `FooDesc.bar` is private, the completion should not be triggered.
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
mod _69latrick {
|
mod _69latrick {
|
||||||
pub struct FooDesc { pub six: bool, pub neuf: Vec<String>, bar: bool }
|
pub struct FooDesc { pub six: bool, pub neuf: Vec<String>, bar: bool }
|
||||||
@ -79,7 +74,7 @@ fn baz() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_various_bindings() {
|
fn completes_various_bindings() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn func(param0 @ (param1, param2): (i32, i32)) {
|
fn func(param0 @ (param1, param2): (i32, i32)) {
|
||||||
let letlocal = 92;
|
let letlocal = 92;
|
||||||
@ -125,7 +120,7 @@ fn func(param0 @ (param1, param2): (i32, i32)) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_all_the_things_in_fn_body() {
|
fn completes_all_the_things_in_fn_body() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
use non_existent::Unresolved;
|
use non_existent::Unresolved;
|
||||||
mod qualified { pub enum Enum { Variant } }
|
mod qualified { pub enum Enum { Variant } }
|
||||||
@ -191,7 +186,7 @@ impl Unit {
|
|||||||
?? Unresolved
|
?? Unresolved
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
use non_existent::Unresolved;
|
use non_existent::Unresolved;
|
||||||
mod qualified { pub enum Enum { Variant } }
|
mod qualified { pub enum Enum { Variant } }
|
||||||
@ -224,7 +219,7 @@ impl Unit {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_in_block() {
|
fn complete_in_block() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
if true {
|
if true {
|
||||||
@ -273,7 +268,7 @@ fn complete_in_block() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_after_if_expr() {
|
fn complete_after_if_expr() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
if true {}
|
if true {}
|
||||||
@ -321,7 +316,7 @@ fn complete_after_if_expr() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_in_match_arm() {
|
fn complete_in_match_arm() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
match () {
|
match () {
|
||||||
@ -351,7 +346,7 @@ fn complete_in_match_arm() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_loop_ctx() {
|
fn completes_in_loop_ctx() {
|
||||||
check_empty(
|
check(
|
||||||
r"fn my() { loop { $0 } }",
|
r"fn my() { loop { $0 } }",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fn my() fn()
|
fn my() fn()
|
||||||
@ -390,7 +385,7 @@ fn completes_in_loop_ctx() {
|
|||||||
sn ppd
|
sn ppd
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r"fn my() { loop { foo.$0 } }",
|
r"fn my() { loop { foo.$0 } }",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
sn box Box::new(expr)
|
sn box Box::new(expr)
|
||||||
@ -415,7 +410,7 @@ fn completes_in_loop_ctx() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_let_initializer() {
|
fn completes_in_let_initializer() {
|
||||||
check_empty(
|
check(
|
||||||
r#"fn main() { let _ = $0 }"#,
|
r#"fn main() { let _ = $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fn main() fn()
|
fn main() fn()
|
||||||
@ -439,7 +434,7 @@ fn completes_in_let_initializer() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn struct_initializer_field_expr() {
|
fn struct_initializer_field_expr() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo {
|
struct Foo {
|
||||||
pub f: i32,
|
pub f: i32,
|
||||||
@ -475,7 +470,7 @@ fn foo() {
|
|||||||
fn shadowing_shows_single_completion() {
|
fn shadowing_shows_single_completion() {
|
||||||
cov_mark::check!(shadowing_shows_single_completion);
|
cov_mark::check!(shadowing_shows_single_completion);
|
||||||
|
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let bar = 92;
|
let bar = 92;
|
||||||
@ -508,7 +503,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_macro_expr_frag() {
|
fn in_macro_expr_frag() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
fn quux(x: i32) {
|
fn quux(x: i32) {
|
||||||
@ -535,7 +530,7 @@ fn quux(x: i32) {
|
|||||||
kw while let
|
kw while let
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r"
|
r"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
fn quux(x: i32) {
|
fn quux(x: i32) {
|
||||||
@ -562,7 +557,7 @@ fn quux(x: i32) {
|
|||||||
kw while let
|
kw while let
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
fn quux(x: i32) {
|
fn quux(x: i32) {
|
||||||
@ -595,7 +590,7 @@ fn quux(x: i32) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enum_qualified() {
|
fn enum_qualified() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Enum {
|
impl Enum {
|
||||||
type AssocType = ();
|
type AssocType = ();
|
||||||
@ -619,7 +614,7 @@ fn func() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ty_qualified_no_drop() {
|
fn ty_qualified_no_drop() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: drop
|
//- minicore: drop
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -636,7 +631,7 @@ fn func() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn with_parens() {
|
fn with_parens() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
Variant()
|
Variant()
|
||||||
@ -657,7 +652,7 @@ fn func() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn detail_impl_trait_in_return_position() {
|
fn detail_impl_trait_in_return_position() {
|
||||||
check_empty(
|
check(
|
||||||
r"
|
r"
|
||||||
//- minicore: sized
|
//- minicore: sized
|
||||||
trait Trait<T> {}
|
trait Trait<T> {}
|
||||||
@ -676,7 +671,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn detail_async_fn() {
|
fn detail_async_fn() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: future, sized
|
//- minicore: future, sized
|
||||||
trait Trait<T> {}
|
trait Trait<T> {}
|
||||||
@ -697,7 +692,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn detail_impl_trait_in_argument_position() {
|
fn detail_impl_trait_in_argument_position() {
|
||||||
check_empty(
|
check(
|
||||||
r"
|
r"
|
||||||
//- minicore: sized
|
//- minicore: sized
|
||||||
trait Trait<T> {}
|
trait Trait<T> {}
|
||||||
@ -717,7 +712,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_record_expr_path() {
|
fn complete_record_expr_path() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Zulu;
|
struct Zulu;
|
||||||
impl Zulu {
|
impl Zulu {
|
||||||
@ -738,7 +733,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn variant_with_struct() {
|
fn variant_with_struct() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
pub struct YoloVariant {
|
pub struct YoloVariant {
|
||||||
pub f: usize
|
pub f: usize
|
||||||
@ -813,7 +808,7 @@ fn return_value_no_block() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn else_completion_after_if() {
|
fn else_completion_after_if() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { if foo {} $0 }
|
fn foo() { if foo {} $0 }
|
||||||
"#,
|
"#,
|
||||||
@ -854,7 +849,7 @@ fn foo() { if foo {} $0 }
|
|||||||
sn ppd
|
sn ppd
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { if foo {} el$0 }
|
fn foo() { if foo {} el$0 }
|
||||||
"#,
|
"#,
|
||||||
@ -895,7 +890,7 @@ fn foo() { if foo {} el$0 }
|
|||||||
sn ppd
|
sn ppd
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { bar(if foo {} $0) }
|
fn foo() { bar(if foo {} $0) }
|
||||||
"#,
|
"#,
|
||||||
@ -919,7 +914,7 @@ fn foo() { bar(if foo {} $0) }
|
|||||||
kw while let
|
kw while let
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { bar(if foo {} el$0) }
|
fn foo() { bar(if foo {} el$0) }
|
||||||
"#,
|
"#,
|
||||||
@ -943,7 +938,7 @@ fn foo() { bar(if foo {} el$0) }
|
|||||||
kw while let
|
kw while let
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { if foo {} $0 let x = 92; }
|
fn foo() { if foo {} $0 let x = 92; }
|
||||||
"#,
|
"#,
|
||||||
@ -984,7 +979,7 @@ fn foo() { if foo {} $0 let x = 92; }
|
|||||||
sn ppd
|
sn ppd
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { if foo {} el$0 let x = 92; }
|
fn foo() { if foo {} el$0 let x = 92; }
|
||||||
"#,
|
"#,
|
||||||
@ -1025,7 +1020,7 @@ fn foo() { if foo {} el$0 let x = 92; }
|
|||||||
sn ppd
|
sn ppd
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { if foo {} el$0 { let x = 92; } }
|
fn foo() { if foo {} el$0 { let x = 92; } }
|
||||||
"#,
|
"#,
|
||||||
@ -1070,7 +1065,7 @@ fn foo() { if foo {} el$0 { let x = 92; } }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn expr_no_unstable_item_on_stable() {
|
fn expr_no_unstable_item_on_stable() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
use std::*;
|
use std::*;
|
||||||
@ -1121,7 +1116,7 @@ pub struct UnstableThisShouldNotBeListed;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn expr_unstable_item_on_nightly() {
|
fn expr_unstable_item_on_nightly() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
@ -1174,7 +1169,7 @@ pub struct UnstableButWeAreOnNightlyAnyway;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inside_format_args_completions_work() {
|
fn inside_format_args_completions_work() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1200,7 +1195,7 @@ fn main() {
|
|||||||
sn unsafe unsafe {}
|
sn unsafe unsafe {}
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1230,7 +1225,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inside_faulty_format_args_completions_work() {
|
fn inside_faulty_format_args_completions_work() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1256,7 +1251,7 @@ fn main() {
|
|||||||
sn unsafe unsafe {}
|
sn unsafe unsafe {}
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1282,7 +1277,7 @@ fn main() {
|
|||||||
sn unsafe unsafe {}
|
sn unsafe unsafe {}
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1308,7 +1303,7 @@ fn main() {
|
|||||||
sn unsafe unsafe {}
|
sn unsafe unsafe {}
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: fmt
|
//- minicore: fmt
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -1340,7 +1335,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_that_ignores_completion_marker() {
|
fn macro_that_ignores_completion_marker() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! helper {
|
macro_rules! helper {
|
||||||
($v:ident) => {};
|
($v:ident) => {};
|
||||||
@ -1788,7 +1783,7 @@ fn foo<T: ExcludedTrait>() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hide_ragennew_synthetic_identifiers() {
|
fn hide_ragennew_synthetic_identifiers() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- minicore: iterator
|
//- minicore: iterator
|
||||||
fn bar() {
|
fn bar() {
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{completion_list, completion_list_with_trigger_character};
|
use crate::tests::{check, check_with_trigger_character};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_with_trigger_character(ra_fixture: &str, trigger_character: char, expect: Expect) {
|
|
||||||
let actual = completion_list_with_trigger_character(ra_fixture, Some(trigger_character));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn only_param() {
|
fn only_param() {
|
||||||
@ -124,7 +114,7 @@ fn trigger_by_l_paren() {
|
|||||||
r#"
|
r#"
|
||||||
fn foo($0)
|
fn foo($0)
|
||||||
"#,
|
"#,
|
||||||
'(',
|
Some('('),
|
||||||
expect![[]],
|
expect![[]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,13 @@
|
|||||||
//!
|
//!
|
||||||
//! Except for use items which are tested in [super::use_tree] and mod declarations with are tested
|
//! Except for use items which are tested in [super::use_tree] and mod declarations with are tested
|
||||||
//! in [crate::completions::mod_].
|
//! in [crate::completions::mod_].
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
use crate::tests::{check_edit, check_with_base_items};
|
||||||
|
|
||||||
use super::check_edit;
|
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn target_type_or_trait_in_impl_block() {
|
fn target_type_or_trait_in_impl_block() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Tra$0
|
impl Tra$0
|
||||||
"#,
|
"#,
|
||||||
@ -37,7 +30,7 @@ impl Tra$0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn target_type_in_trait_impl_block() {
|
fn target_type_in_trait_impl_block() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Trait for Str$0
|
impl Trait for Str$0
|
||||||
"#,
|
"#,
|
||||||
@ -59,7 +52,7 @@ impl Trait for Str$0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_trait_name_in_trait_def() {
|
fn after_trait_name_in_trait_def() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r"trait A $0",
|
r"trait A $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
@ -69,21 +62,21 @@ fn after_trait_name_in_trait_def() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_target_name_in_impl() {
|
fn after_target_name_in_impl() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r"impl Trait $0",
|
r"impl Trait $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw for
|
kw for
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"impl Trait f$0",
|
r"impl Trait f$0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw for
|
kw for
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"impl Trait for Type $0",
|
r"impl Trait for Type $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
@ -93,44 +86,44 @@ fn after_target_name_in_impl() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_where() {
|
fn completes_where() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r"struct Struct $0",
|
r"struct Struct $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"struct Struct $0 {}",
|
r"struct Struct $0 {}",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
// FIXME: This shouldn't be completed here
|
// FIXME: This shouldn't be completed here
|
||||||
check(
|
check_with_base_items(
|
||||||
r"struct Struct $0 ()",
|
r"struct Struct $0 ()",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"fn func() $0",
|
r"fn func() $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"enum Enum $0",
|
r"enum Enum $0",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"enum Enum $0 {}",
|
r"enum Enum $0 {}",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r"trait Trait $0 {}",
|
r"trait Trait $0 {}",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw where
|
kw where
|
||||||
@ -140,7 +133,7 @@ fn completes_where() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn before_record_field() {
|
fn before_record_field() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo {
|
struct Foo {
|
||||||
$0
|
$0
|
||||||
@ -244,7 +237,7 @@ impl Copy for S where $0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_is_not_considered_macro() {
|
fn test_is_not_considered_macro() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
#[rustc_builtin]
|
#[rustc_builtin]
|
||||||
pub macro test($item:item) {
|
pub macro test($item:item) {
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
//! Completion tests for item list position.
|
//! Completion tests for item list position.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, check_empty, completion_list, BASE_ITEMS_FIXTURE};
|
use crate::tests::{check, check_edit, check_with_base_items};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_mod_item_list() {
|
fn in_mod_item_list() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"mod tests { $0 }"#,
|
r#"mod tests { $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -43,7 +38,7 @@ fn in_mod_item_list() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_source_file_item_list() {
|
fn in_source_file_item_list() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"$0"#,
|
r#"$0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -76,7 +71,7 @@ fn in_source_file_item_list() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_item_list_after_attr() {
|
fn in_item_list_after_attr() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"#[attr] $0"#,
|
r#"#[attr] $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -109,7 +104,7 @@ fn in_item_list_after_attr() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_qualified_path() {
|
fn in_qualified_path() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"crate::$0"#,
|
r#"crate::$0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -120,7 +115,7 @@ fn in_qualified_path() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_unsafe_token() {
|
fn after_unsafe_token() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"unsafe $0"#,
|
r#"unsafe $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw async
|
kw async
|
||||||
@ -134,7 +129,7 @@ fn after_unsafe_token() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_async_token() {
|
fn after_async_token() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"async $0"#,
|
r#"async $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw fn
|
kw fn
|
||||||
@ -145,7 +140,7 @@ fn after_async_token() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_visibility() {
|
fn after_visibility() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"pub $0"#,
|
r#"pub $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw async
|
kw async
|
||||||
@ -167,7 +162,7 @@ fn after_visibility() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_visibility_unsafe() {
|
fn after_visibility_unsafe() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"pub unsafe $0"#,
|
r#"pub unsafe $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw async
|
kw async
|
||||||
@ -179,7 +174,7 @@ fn after_visibility_unsafe() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_impl_assoc_item_list() {
|
fn in_impl_assoc_item_list() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"impl Struct { $0 }"#,
|
r#"impl Struct { $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -199,7 +194,7 @@ fn in_impl_assoc_item_list() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_impl_assoc_item_list_after_attr() {
|
fn in_impl_assoc_item_list_after_attr() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"impl Struct { #[attr] $0 }"#,
|
r#"impl Struct { #[attr] $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -219,7 +214,7 @@ fn in_impl_assoc_item_list_after_attr() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_assoc_item_list() {
|
fn in_trait_assoc_item_list() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r"trait Foo { $0 }",
|
r"trait Foo { $0 }",
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -237,7 +232,7 @@ fn in_trait_assoc_item_list() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_assoc_fn_missing_body() {
|
fn in_trait_assoc_fn_missing_body() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"trait Foo { fn function(); $0 }"#,
|
r#"trait Foo { fn function(); $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -255,7 +250,7 @@ fn in_trait_assoc_fn_missing_body() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_assoc_const_missing_body() {
|
fn in_trait_assoc_const_missing_body() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"trait Foo { const CONST: (); $0 }"#,
|
r#"trait Foo { const CONST: (); $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -273,7 +268,7 @@ fn in_trait_assoc_const_missing_body() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_assoc_type_aliases_missing_ty() {
|
fn in_trait_assoc_type_aliases_missing_ty() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"trait Foo { type Type; $0 }"#,
|
r#"trait Foo { type Type; $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -291,7 +286,7 @@ fn in_trait_assoc_type_aliases_missing_ty() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_impl_assoc_item_list() {
|
fn in_trait_impl_assoc_item_list() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait Test {
|
trait Test {
|
||||||
type Type0;
|
type Type0;
|
||||||
@ -326,7 +321,7 @@ impl Test for () {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_impl_no_unstable_item_on_stable() {
|
fn in_trait_impl_no_unstable_item_on_stable() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
trait Test {
|
trait Test {
|
||||||
#[unstable]
|
#[unstable]
|
||||||
@ -350,7 +345,7 @@ impl Test for () {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_trait_impl_unstable_item_on_nightly() {
|
fn in_trait_impl_unstable_item_on_nightly() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
trait Test {
|
trait Test {
|
||||||
@ -378,7 +373,7 @@ impl Test for () {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn after_unit_struct() {
|
fn after_unit_struct() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"struct S; f$0"#,
|
r#"struct S; f$0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -500,7 +495,7 @@ type O = $0;
|
|||||||
#[test]
|
#[test]
|
||||||
fn inside_extern_blocks() {
|
fn inside_extern_blocks() {
|
||||||
// Should suggest `fn`, `static`, `unsafe`
|
// Should suggest `fn`, `static`, `unsafe`
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"extern { $0 }"#,
|
r#"extern { $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -517,7 +512,7 @@ fn inside_extern_blocks() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Should suggest `fn`, `static`, `safe`, `unsafe`
|
// Should suggest `fn`, `static`, `safe`, `unsafe`
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"unsafe extern { $0 }"#,
|
r#"unsafe extern { $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
ma makro!(…) macro_rules! makro
|
ma makro!(…) macro_rules! makro
|
||||||
@ -534,7 +529,7 @@ fn inside_extern_blocks() {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"unsafe extern { pub safe $0 }"#,
|
r#"unsafe extern { pub safe $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw fn
|
kw fn
|
||||||
@ -542,7 +537,7 @@ fn inside_extern_blocks() {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"unsafe extern { pub unsafe $0 }"#,
|
r#"unsafe extern { pub unsafe $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw fn
|
kw fn
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
//! Completion tests for pattern position.
|
//! Completion tests for pattern position.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_edit, check_empty, completion_list, BASE_ITEMS_FIXTURE};
|
use crate::tests::{check, check_edit, check_with_base_items};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wildcard() {
|
fn wildcard() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let _$0
|
let _$0
|
||||||
@ -22,7 +17,7 @@ fn quux() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ident_rebind_pat() {
|
fn ident_rebind_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let en$0 @ x
|
let en$0 @ x
|
||||||
@ -37,7 +32,7 @@ fn quux() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ident_ref_pat() {
|
fn ident_ref_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let ref en$0
|
let ref en$0
|
||||||
@ -47,7 +42,7 @@ fn quux() {
|
|||||||
kw mut
|
kw mut
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let ref en$0 @ x
|
let ref en$0 @ x
|
||||||
@ -61,7 +56,7 @@ fn quux() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ident_ref_mut_pat() {
|
fn ident_ref_mut_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let ref mut en$0
|
let ref mut en$0
|
||||||
@ -69,7 +64,7 @@ fn quux() {
|
|||||||
"#,
|
"#,
|
||||||
expect![[r#""#]],
|
expect![[r#""#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let ref mut en$0 @ x
|
let ref mut en$0 @ x
|
||||||
@ -81,7 +76,7 @@ fn quux() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ref_pat() {
|
fn ref_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let &en$0
|
let &en$0
|
||||||
@ -91,7 +86,7 @@ fn quux() {
|
|||||||
kw mut
|
kw mut
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn quux() {
|
fn quux() {
|
||||||
let &mut en$0
|
let &mut en$0
|
||||||
@ -99,7 +94,7 @@ fn quux() {
|
|||||||
"#,
|
"#,
|
||||||
expect![[r#""#]],
|
expect![[r#""#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
for &$0 in () {}
|
for &$0 in () {}
|
||||||
@ -113,7 +108,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn refutable() {
|
fn refutable() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
if let a$0
|
if let a$0
|
||||||
@ -139,7 +134,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn irrefutable() {
|
fn irrefutable() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
enum SingleVariantEnum {
|
enum SingleVariantEnum {
|
||||||
Variant
|
Variant
|
||||||
@ -168,7 +163,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_param() {
|
fn in_param() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo(a$0) {
|
fn foo(a$0) {
|
||||||
}
|
}
|
||||||
@ -185,7 +180,7 @@ fn foo(a$0) {
|
|||||||
kw ref
|
kw ref
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo(a$0: Tuple) {
|
fn foo(a$0: Tuple) {
|
||||||
}
|
}
|
||||||
@ -207,7 +202,7 @@ fn foo(a$0: Tuple) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn only_fn_like_macros() {
|
fn only_fn_like_macros() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
|
|
||||||
@ -228,7 +223,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_simple_macro_call() {
|
fn in_simple_macro_call() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
macro_rules! m { ($e:expr) => { $e } }
|
macro_rules! m { ($e:expr) => { $e } }
|
||||||
enum E { X }
|
enum E { X }
|
||||||
@ -249,7 +244,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn omits_private_fields_pat() {
|
fn omits_private_fields_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
mod foo {
|
mod foo {
|
||||||
pub struct Record { pub field: i32, _field: i32 }
|
pub struct Record { pub field: i32, _field: i32 }
|
||||||
@ -277,7 +272,7 @@ fn outer() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_self_pats() {
|
fn completes_self_pats() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo(i32);
|
struct Foo(i32);
|
||||||
impl Foo {
|
impl Foo {
|
||||||
@ -301,7 +296,7 @@ impl Foo {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enum_qualified() {
|
fn enum_qualified() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Enum {
|
impl Enum {
|
||||||
type AssocType = ();
|
type AssocType = ();
|
||||||
@ -323,7 +318,7 @@ fn func() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_record_field_pat() {
|
fn completes_in_record_field_pat() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { bar: Bar }
|
struct Foo { bar: Bar }
|
||||||
struct Bar(u32);
|
struct Bar(u32);
|
||||||
@ -342,7 +337,7 @@ fn outer(Foo { bar: $0 }: Foo) {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn skips_in_record_field_pat_name() {
|
fn skips_in_record_field_pat_name() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { bar: Bar }
|
struct Foo { bar: Bar }
|
||||||
struct Bar(u32);
|
struct Bar(u32);
|
||||||
@ -357,7 +352,7 @@ fn outer(Foo { bar$0 }: Foo) {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_record_field_pat_with_generic_type_alias() {
|
fn completes_in_record_field_pat_with_generic_type_alias() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
type Wrap<T> = T;
|
type Wrap<T> = T;
|
||||||
|
|
||||||
@ -386,7 +381,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_fn_param() {
|
fn completes_in_fn_param() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { bar: Bar }
|
struct Foo { bar: Bar }
|
||||||
struct Bar(u32);
|
struct Bar(u32);
|
||||||
@ -405,7 +400,7 @@ fn foo($0) {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_in_closure_param() {
|
fn completes_in_closure_param() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { bar: Bar }
|
struct Foo { bar: Bar }
|
||||||
struct Bar(u32);
|
struct Bar(u32);
|
||||||
@ -426,7 +421,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_no_delims_if_existing() {
|
fn completes_no_delims_if_existing() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Bar(u32);
|
struct Bar(u32);
|
||||||
fn foo() {
|
fn foo() {
|
||||||
@ -441,7 +436,7 @@ fn foo() {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Foo { bar: u32 }
|
struct Foo { bar: u32 }
|
||||||
fn foo() {
|
fn foo() {
|
||||||
@ -456,7 +451,7 @@ fn foo() {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
TupleVariant(u32)
|
TupleVariant(u32)
|
||||||
@ -471,7 +466,7 @@ fn foo() {
|
|||||||
bn TupleVariant TupleVariant
|
bn TupleVariant TupleVariant
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
RecordVariant { field: u32 }
|
RecordVariant { field: u32 }
|
||||||
@ -519,7 +514,7 @@ fn foo() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn completes_enum_variant_pat_escape() {
|
fn completes_enum_variant_pat_escape() {
|
||||||
cov_mark::check!(enum_variant_pattern_path);
|
cov_mark::check!(enum_variant_pattern_path);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
A,
|
A,
|
||||||
@ -544,7 +539,7 @@ fn foo() {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum {
|
enum Enum {
|
||||||
A,
|
A,
|
||||||
@ -569,7 +564,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_associated_const() {
|
fn completes_associated_const() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
struct Ty(u8);
|
struct Ty(u8);
|
||||||
@ -590,7 +585,7 @@ fn f(t: Ty) {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum MyEnum {}
|
enum MyEnum {}
|
||||||
|
|
||||||
@ -612,7 +607,7 @@ fn f(e: MyEnum) {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
union U {
|
union U {
|
||||||
i: i32,
|
i: i32,
|
||||||
@ -637,7 +632,7 @@ fn f(u: U) {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
#![rustc_coherence_is_core]
|
#![rustc_coherence_is_core]
|
||||||
#[lang = "u32"]
|
#[lang = "u32"]
|
||||||
@ -659,7 +654,7 @@ fn f(v: u32) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_method_param() {
|
fn in_method_param() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Ty(u8);
|
struct Ty(u8);
|
||||||
|
|
||||||
@ -680,7 +675,7 @@ impl Ty {
|
|||||||
kw ref
|
kw ref
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Ty(u8);
|
struct Ty(u8);
|
||||||
|
|
||||||
@ -701,7 +696,7 @@ impl Ty {
|
|||||||
kw ref
|
kw ref
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Ty(u8);
|
struct Ty(u8);
|
||||||
|
|
||||||
@ -722,7 +717,7 @@ impl Ty {
|
|||||||
kw ref
|
kw ref
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Ty(u8);
|
struct Ty(u8);
|
||||||
|
|
||||||
@ -743,7 +738,7 @@ impl Ty {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn through_alias() {
|
fn through_alias() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
enum Enum<T> {
|
enum Enum<T> {
|
||||||
Unit,
|
Unit,
|
||||||
@ -770,7 +765,7 @@ fn f(x: EnumAlias<u8>) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pat_no_unstable_item_on_stable() {
|
fn pat_no_unstable_item_on_stable() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
use std::*;
|
use std::*;
|
||||||
@ -795,7 +790,7 @@ pub enum Enum {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pat_unstable_item_on_nightly() {
|
fn pat_unstable_item_on_nightly() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
@ -908,7 +903,7 @@ fn foo() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Do not suggest reserved keywords
|
// Do not suggest reserved keywords
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
struct Struct;
|
struct Struct;
|
||||||
|
|
||||||
@ -926,7 +921,7 @@ fn foo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn private_item_in_module_in_function_body() {
|
fn private_item_in_module_in_function_body() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
mod foo {
|
mod foo {
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
//! Completion tests for predicates and bounds.
|
//! Completion tests for predicates and bounds.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_empty, completion_list, BASE_ITEMS_FIXTURE};
|
use crate::tests::{check, check_with_base_items};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn predicate_start() {
|
fn predicate_start() {
|
||||||
// FIXME: `for` kw
|
// FIXME: `for` kw
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> where $0 {}
|
struct Foo<'lt, T, const C: usize> where $0 {}
|
||||||
"#,
|
"#,
|
||||||
@ -34,7 +29,7 @@ struct Foo<'lt, T, const C: usize> where $0 {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bound_for_type_pred() {
|
fn bound_for_type_pred() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> where T: $0 {}
|
struct Foo<'lt, T, const C: usize> where T: $0 {}
|
||||||
"#,
|
"#,
|
||||||
@ -52,7 +47,7 @@ struct Foo<'lt, T, const C: usize> where T: $0 {}
|
|||||||
fn bound_for_lifetime_pred() {
|
fn bound_for_lifetime_pred() {
|
||||||
// FIXME: should only show lifetimes here, that is we shouldn't get any completions here when not typing
|
// FIXME: should only show lifetimes here, that is we shouldn't get any completions here when not typing
|
||||||
// a `'`
|
// a `'`
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> where 'lt: $0 {}
|
struct Foo<'lt, T, const C: usize> where 'lt: $0 {}
|
||||||
"#,
|
"#,
|
||||||
@ -68,7 +63,7 @@ struct Foo<'lt, T, const C: usize> where 'lt: $0 {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bound_for_for_pred() {
|
fn bound_for_for_pred() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {}
|
struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {}
|
||||||
"#,
|
"#,
|
||||||
@ -84,7 +79,7 @@ struct Foo<'lt, T, const C: usize> where for<'a> T: $0 {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn param_list_for_for_pred() {
|
fn param_list_for_for_pred() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
|
struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
|
||||||
"#,
|
"#,
|
||||||
@ -107,7 +102,7 @@ struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pred_on_fn_in_impl() {
|
fn pred_on_fn_in_impl() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Record {
|
impl Record {
|
||||||
fn method(self) where $0 {}
|
fn method(self) where $0 {}
|
||||||
@ -132,7 +127,7 @@ impl Record {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pred_no_unstable_item_on_stable() {
|
fn pred_no_unstable_item_on_stable() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
use std::*;
|
use std::*;
|
||||||
@ -151,7 +146,7 @@ pub trait Trait {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pred_unstable_item_on_nightly() {
|
fn pred_unstable_item_on_nightly() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
//! Completion tests for expressions.
|
//! Completion tests for expressions.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::completion_list;
|
use crate::tests::check;
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_dot_in_attr() {
|
fn complete_dot_in_attr() {
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::completion_list;
|
use crate::tests::check;
|
||||||
|
|
||||||
use super::check_edit;
|
use super::check_edit;
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn without_default_impl() {
|
fn without_default_impl() {
|
||||||
check(
|
check(
|
||||||
|
@ -5,32 +5,12 @@ use ide_db::SymbolKind;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests::{
|
tests::{
|
||||||
check_edit, completion_list, completion_list_no_kw, completion_list_with_trigger_character,
|
check, check_edit, check_no_kw, check_with_trigger_character, do_completion_with_config,
|
||||||
|
TEST_CONFIG,
|
||||||
},
|
},
|
||||||
CompletionItemKind,
|
CompletionItemKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{do_completion_with_config, TEST_CONFIG};
|
|
||||||
|
|
||||||
fn check_no_kw(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn check_with_trigger_character(
|
|
||||||
ra_fixture: &str,
|
|
||||||
trigger_character: Option<char>,
|
|
||||||
expect: Expect,
|
|
||||||
) {
|
|
||||||
let actual = completion_list_with_trigger_character(ra_fixture, trigger_character);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_if_prefix_is_keyword() {
|
fn completes_if_prefix_is_keyword() {
|
||||||
check_edit(
|
check_edit(
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
//! Completion tests for type position.
|
//! Completion tests for type position.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{check_empty, completion_list, BASE_ITEMS_FIXTURE};
|
use crate::tests::{check, check_with_base_items};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}\n{ra_fixture}"));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn record_field_ty() {
|
fn record_field_ty() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize> {
|
struct Foo<'lt, T, const C: usize> {
|
||||||
f: $0
|
f: $0
|
||||||
@ -37,7 +32,7 @@ struct Foo<'lt, T, const C: usize> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tuple_struct_field() {
|
fn tuple_struct_field() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<'lt, T, const C: usize>(f$0);
|
struct Foo<'lt, T, const C: usize>(f$0);
|
||||||
"#,
|
"#,
|
||||||
@ -65,7 +60,7 @@ struct Foo<'lt, T, const C: usize>(f$0);
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fn_return_type() {
|
fn fn_return_type() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn x<'lt, T, const C: usize>() -> $0
|
fn x<'lt, T, const C: usize>() -> $0
|
||||||
"#,
|
"#,
|
||||||
@ -88,7 +83,7 @@ fn x<'lt, T, const C: usize>() -> $0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fn_return_type_no_local_items() {
|
fn fn_return_type_no_local_items() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo() -> B$0 {
|
fn foo() -> B$0 {
|
||||||
struct Bar;
|
struct Bar;
|
||||||
@ -118,7 +113,7 @@ fn foo() -> B$0 {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_const() {
|
fn inferred_type_const() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<T>(T);
|
struct Foo<T>(T);
|
||||||
const FOO: $0 = Foo(2);
|
const FOO: $0 = Foo(2);
|
||||||
@ -143,7 +138,7 @@ const FOO: $0 = Foo(2);
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_closure_param() {
|
fn inferred_type_closure_param() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn f1(f: fn(i32) -> i32) {}
|
fn f1(f: fn(i32) -> i32) {}
|
||||||
fn f2() {
|
fn f2() {
|
||||||
@ -169,7 +164,7 @@ fn f2() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_closure_return() {
|
fn inferred_type_closure_return() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn f1(f: fn(u64) -> u64) {}
|
fn f1(f: fn(u64) -> u64) {}
|
||||||
fn f2() {
|
fn f2() {
|
||||||
@ -197,7 +192,7 @@ fn f2() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_fn_return() {
|
fn inferred_type_fn_return() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn f2(x: u64) -> $0 {
|
fn f2(x: u64) -> $0 {
|
||||||
x + 5
|
x + 5
|
||||||
@ -222,7 +217,7 @@ fn f2(x: u64) -> $0 {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_fn_param() {
|
fn inferred_type_fn_param() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn f1(x: i32) {}
|
fn f1(x: i32) {}
|
||||||
fn f2(x: $0) {
|
fn f2(x: $0) {
|
||||||
@ -248,7 +243,7 @@ fn f2(x: $0) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_not_in_the_scope() {
|
fn inferred_type_not_in_the_scope() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
mod a {
|
mod a {
|
||||||
pub struct Foo<T>(T);
|
pub struct Foo<T>(T);
|
||||||
@ -282,7 +277,7 @@ fn foo<'lt, T, const C: usize>() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inferred_type_let() {
|
fn inferred_type_let() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo<T>(T);
|
struct Foo<T>(T);
|
||||||
fn foo<'lt, T, const C: usize>() {
|
fn foo<'lt, T, const C: usize>() {
|
||||||
@ -311,7 +306,7 @@ fn foo<'lt, T, const C: usize>() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn body_type_pos() {
|
fn body_type_pos() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo<'lt, T, const C: usize>() {
|
fn foo<'lt, T, const C: usize>() {
|
||||||
let local = ();
|
let local = ();
|
||||||
@ -333,7 +328,7 @@ fn foo<'lt, T, const C: usize>() {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
fn foo<'lt, T, const C: usize>() {
|
fn foo<'lt, T, const C: usize>() {
|
||||||
let local = ();
|
let local = ();
|
||||||
@ -356,7 +351,7 @@ fn foo<'lt, T, const C: usize>() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn completes_types_and_const_in_arg_list() {
|
fn completes_types_and_const_in_arg_list() {
|
||||||
cov_mark::check!(complete_assoc_type_in_generics_list);
|
cov_mark::check!(complete_assoc_type_in_generics_list);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait Trait1 {
|
trait Trait1 {
|
||||||
type Super;
|
type Super;
|
||||||
@ -372,7 +367,7 @@ fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
|
|||||||
ta Super = (as Trait1) type Super
|
ta Super = (as Trait1) type Super
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait Trait1 {
|
trait Trait1 {
|
||||||
type Super;
|
type Super;
|
||||||
@ -400,7 +395,7 @@ fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait Trait2<T> {
|
trait Trait2<T> {
|
||||||
type Foo;
|
type Foo;
|
||||||
@ -424,7 +419,7 @@ fn foo<'lt, T: Trait2<self::$0>, const CONST_PARAM: usize>(_: T) {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_assoc_completion_outside_type_bounds() {
|
fn no_assoc_completion_outside_type_bounds() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct S;
|
struct S;
|
||||||
trait Tr<T> {
|
trait Tr<T> {
|
||||||
@ -454,7 +449,7 @@ impl Tr<$0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enum_qualified() {
|
fn enum_qualified() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
impl Enum {
|
impl Enum {
|
||||||
type AssocType = ();
|
type AssocType = ();
|
||||||
@ -471,7 +466,7 @@ fn func(_: Enum::$0) {}
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_type_parameter_or_associated_type() {
|
fn completes_type_parameter_or_associated_type() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U> {
|
trait MyTrait<T, U> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -496,7 +491,7 @@ fn f(t: impl MyTrait<u$0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U> {
|
trait MyTrait<T, U> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -521,7 +516,7 @@ fn f(t: impl MyTrait<u8, u$0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U> {
|
trait MyTrait<T, U> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -539,7 +534,7 @@ fn f(t: impl MyTrait<u8, u8, I$0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_type_parameter_or_associated_type_with_default_value() {
|
fn completes_type_parameter_or_associated_type_with_default_value() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U = u8> {
|
trait MyTrait<T, U = u8> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -564,7 +559,7 @@ fn f(t: impl MyTrait<u$0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U = u8> {
|
trait MyTrait<T, U = u8> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -591,7 +586,7 @@ fn f(t: impl MyTrait<u8, u$0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait<T, U = u8> {
|
trait MyTrait<T, U = u8> {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -609,7 +604,7 @@ fn f(t: impl MyTrait<u8, u8, I$0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_types_after_associated_type() {
|
fn completes_types_after_associated_type() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait {
|
trait MyTrait {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -634,7 +629,7 @@ fn f(t: impl MyTrait<Item1 = $0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait {
|
trait MyTrait {
|
||||||
type Item1;
|
type Item1;
|
||||||
@ -659,7 +654,7 @@ fn f(t: impl MyTrait<Item1 = u8, Item2 = $0
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait MyTrait {
|
trait MyTrait {
|
||||||
const C: usize;
|
const C: usize;
|
||||||
@ -678,7 +673,7 @@ fn f(t: impl MyTrait<C = $0
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn type_pos_no_unstable_type_on_stable() {
|
fn type_pos_no_unstable_type_on_stable() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
use std::*;
|
use std::*;
|
||||||
@ -702,7 +697,7 @@ pub struct S;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn type_pos_unstable_type_on_nightly() {
|
fn type_pos_unstable_type_on_nightly() {
|
||||||
check_empty(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- toolchain:nightly
|
//- toolchain:nightly
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
@ -729,7 +724,7 @@ pub struct S;
|
|||||||
#[test]
|
#[test]
|
||||||
fn completes_const_and_type_generics_separately() {
|
fn completes_const_and_type_generics_separately() {
|
||||||
// Function generic params
|
// Function generic params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo;
|
struct Foo;
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
@ -756,7 +751,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
// FIXME: This should probably also suggest completions for types, at least those that have
|
// FIXME: This should probably also suggest completions for types, at least those that have
|
||||||
// associated constants usable in this position. For example, a user could be typing
|
// associated constants usable in this position. For example, a user could be typing
|
||||||
// `foo::<_, { usize::MAX }>()`, but we currently don't suggest `usize` in constant position.
|
// `foo::<_, { usize::MAX }>()`, but we currently don't suggest `usize` in constant position.
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct Foo;
|
struct Foo;
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
@ -775,7 +770,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Method generic params
|
// Method generic params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -799,7 +794,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -818,7 +813,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Associated type generic params
|
// Associated type generic params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -843,7 +838,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo;
|
struct Foo;
|
||||||
@ -862,7 +857,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Type generic params
|
// Type generic params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo<T, const N: usize>(T);
|
struct Foo<T, const N: usize>(T);
|
||||||
@ -880,7 +875,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Type alias generic params
|
// Type alias generic params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
struct Foo<T, const N: usize>(T);
|
struct Foo<T, const N: usize>(T);
|
||||||
@ -899,7 +894,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Enum variant params
|
// Enum variant params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
enum Foo<T, const N: usize> { A(T), B }
|
enum Foo<T, const N: usize> { A(T), B }
|
||||||
@ -917,7 +912,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Trait params
|
// Trait params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
trait Foo<T, const N: usize> {}
|
trait Foo<T, const N: usize> {}
|
||||||
@ -933,7 +928,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Trait alias params
|
// Trait alias params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
const X: usize = 0;
|
const X: usize = 0;
|
||||||
@ -951,7 +946,7 @@ fn completes_const_and_type_generics_separately() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Omitted lifetime params
|
// Omitted lifetime params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
||||||
fn foo<'a>() { S::<F$0, _>; }
|
fn foo<'a>() { S::<F$0, _>; }
|
||||||
@ -964,7 +959,7 @@ fn foo<'a>() { S::<F$0, _>; }
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
// Explicit lifetime params
|
// Explicit lifetime params
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
||||||
fn foo<'a>() { S::<'static, 'static, F$0, _>; }
|
fn foo<'a>() { S::<'static, 'static, F$0, _>; }
|
||||||
@ -976,7 +971,7 @@ fn foo<'a>() { S::<'static, 'static, F$0, _>; }
|
|||||||
kw self::
|
kw self::
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
struct S<'a, 'b, const C: usize, T>(core::marker::PhantomData<&'a &'b T>);
|
||||||
fn foo<'a>() { S::<'static, F$0, _, _>; }
|
fn foo<'a>() { S::<'static, F$0, _, _>; }
|
||||||
@ -992,7 +987,7 @@ fn foo<'a>() { S::<'static, F$0, _, _>; }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_traits_on_impl_trait_block() {
|
fn complete_traits_on_impl_trait_block() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
|
|
||||||
@ -1012,7 +1007,7 @@ impl $0 for Bar { }
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn complete_traits_with_path_on_impl_trait_block() {
|
fn complete_traits_with_path_on_impl_trait_block() {
|
||||||
check(
|
check_with_base_items(
|
||||||
r#"
|
r#"
|
||||||
mod outer {
|
mod outer {
|
||||||
pub trait Foo {}
|
pub trait Foo {}
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
//! Completion tests for use trees.
|
//! Completion tests for use trees.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::completion_list;
|
use crate::tests::check;
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn use_tree_completion() {
|
fn use_tree_completion() {
|
||||||
|
@ -1,17 +1,7 @@
|
|||||||
//! Completion tests for visibility modifiers.
|
//! Completion tests for visibility modifiers.
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::expect;
|
||||||
|
|
||||||
use crate::tests::{completion_list, completion_list_with_trigger_character};
|
use crate::tests::{check, check_with_trigger_character};
|
||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
|
||||||
let actual = completion_list(ra_fixture);
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_with_trigger_character(ra_fixture: &str, trigger_character: char, expect: Expect) {
|
|
||||||
let actual = completion_list_with_trigger_character(ra_fixture, Some(trigger_character));
|
|
||||||
expect.assert_eq(&actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_pub() {
|
fn empty_pub() {
|
||||||
@ -20,7 +10,7 @@ fn empty_pub() {
|
|||||||
r#"
|
r#"
|
||||||
pub($0)
|
pub($0)
|
||||||
"#,
|
"#,
|
||||||
'(',
|
Some('('),
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
kw crate
|
kw crate
|
||||||
kw in
|
kw in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user