1 //! Completion tests for expressions.
2 use expect_test::{expect, Expect};
4 use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
6 fn check(ra_fixture: &str, expect: Expect) {
7 let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
8 expect.assert_eq(&actual)
11 fn check_empty(ra_fixture: &str, expect: Expect) {
12 let actual = completion_list(ra_fixture);
13 expect.assert_eq(&actual);
17 fn complete_literal_struct_with_a_private_field() {
18 // `FooDesc.bar` is private, the completion should not be triggered.
22 pub struct FooDesc { pub six: bool, pub neuf: Vec<String>, bar: bool }
23 pub fn create_foo(foo_desc: &FooDesc) -> () { () }
29 let foo = create_foo(&$0);
32 // This should not contain `FooDesc {…}`.
50 fn create_foo(…) fn(&FooDesc)
60 ma makro!(…) #[macro_export] macro_rules! makro
71 fn completes_various_bindings() {
74 fn func(param0 @ (param1, param2): (i32, i32)) {
76 if let ifletlocal = 100 {
106 fn func(…) fn((i32, i32))
113 fn completes_all_the_things_in_fn_body() {
114 cov_mark::check!(unqualified_skip_lifetime_completion);
117 use non_existant::Unresolved;
118 mod qualified { pub enum Enum { Variant } }
121 fn foo<'lifetime, TypeParam, const CONST_PARAM: usize>(self) {
127 // `self` is in here twice, once as the module, once as the local
168 ma makro!(…) #[macro_export] macro_rules! makro
175 me self.foo() fn(self)
180 use non_existant::Unresolved;
181 mod qualified { pub enum Enum { Variant } }
184 fn foo<'lifetime, TypeParam, const CONST_PARAM: usize>(self) {
198 ma makro!(…) #[macro_export] macro_rules! makro
210 fn complete_in_block() {
253 fn complete_after_if_expr() {
297 fn complete_in_match_arm() {
328 fn completes_in_loop_ctx() {
330 r"fn my() { loop { $0 } }",
367 fn completes_in_let_initializer() {
369 r#"fn main() { let _ = $0 }"#,
392 fn struct_initializer_field_expr() {
427 fn shadowing_shows_single_completion() {
428 cov_mark::check!(shadowing_shows_single_completion);
463 fn in_macro_expr_frag() {
466 macro_rules! m { ($e:expr) => { $e } }
489 ma m!(…) macro_rules! m
494 macro_rules! m { ($e:expr) => { $e } }
517 ma m!(…) macro_rules! m
522 macro_rules! m { ($e:expr) => { $e } }
533 fn enum_qualified() {
538 const ASSOC_CONST: () = ();
547 ev RecordV {field: u32}
549 ct ASSOC_CONST const ASSOC_CONST: ()
551 ta AssocType type AssocType;