2020-07-04 10:03:27 +02:00
|
|
|
//! Completes references after dot (fields and method calls).
|
2019-09-30 11:58:53 +03:00
|
|
|
|
2020-04-17 10:29:32 +02:00
|
|
|
use hir::{HasVisibility, Type};
|
2020-07-04 10:03:27 +02:00
|
|
|
use rustc_hash::FxHashSet;
|
2020-07-04 10:36:12 +02:00
|
|
|
use test_utils::mark;
|
2019-01-08 22:33:36 +03:00
|
|
|
|
2020-10-25 11:26:38 +03:00
|
|
|
use crate::{context::CompletionContext, Completions};
|
2019-01-08 22:33:36 +03:00
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
/// Complete dot accesses, i.e. fields or methods.
|
2020-10-25 10:59:15 +03:00
|
|
|
pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
|
2019-08-04 08:03:17 +07:00
|
|
|
let dot_receiver = match &ctx.dot_receiver {
|
|
|
|
Some(expr) => expr,
|
|
|
|
_ => return,
|
|
|
|
};
|
2019-08-03 01:15:43 +07:00
|
|
|
|
2020-02-18 18:35:10 +01:00
|
|
|
let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) {
|
2019-08-04 08:03:17 +07:00
|
|
|
Some(ty) => ty,
|
|
|
|
_ => return,
|
|
|
|
};
|
2019-08-03 01:15:43 +07:00
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
if ctx.is_call {
|
|
|
|
mark::hit!(test_no_struct_field_completion_for_method_call);
|
|
|
|
} else {
|
2019-11-26 14:02:57 +03:00
|
|
|
complete_fields(acc, ctx, &receiver_ty);
|
2019-08-04 08:03:17 +07:00
|
|
|
}
|
2019-11-26 14:02:57 +03:00
|
|
|
complete_methods(acc, ctx, &receiver_ty);
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|
|
|
|
|
2019-11-26 14:02:57 +03:00
|
|
|
fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: &Type) {
|
|
|
|
for receiver in receiver.autoderef(ctx.db) {
|
2020-04-17 10:29:32 +02:00
|
|
|
for (field, ty) in receiver.fields(ctx.db) {
|
2020-07-11 01:26:24 +02:00
|
|
|
if ctx.scope.module().map_or(false, |m| !field.is_visible_from(ctx.db, m)) {
|
2019-12-24 21:46:07 +01:00
|
|
|
// Skip private field. FIXME: If the definition location of the
|
|
|
|
// field is editable, we should show the completion
|
|
|
|
continue;
|
|
|
|
}
|
2019-11-26 14:02:57 +03:00
|
|
|
acc.add_field(ctx, field, &ty);
|
|
|
|
}
|
|
|
|
for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() {
|
2019-12-24 21:46:07 +01:00
|
|
|
// FIXME: Handle visibility
|
2019-11-26 14:02:57 +03:00
|
|
|
acc.add_tuple_field(ctx, i, &ty);
|
|
|
|
}
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-26 14:02:57 +03:00
|
|
|
fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &Type) {
|
2020-03-07 17:53:22 +01:00
|
|
|
if let Some(krate) = ctx.krate {
|
2020-01-14 14:42:52 +01:00
|
|
|
let mut seen_methods = FxHashSet::default();
|
2020-07-11 01:26:24 +02:00
|
|
|
let traits_in_scope = ctx.scope.traits_in_scope();
|
2020-01-14 14:42:52 +01:00
|
|
|
receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| {
|
2020-08-19 15:16:24 +02:00
|
|
|
if func.self_param(ctx.db).is_some()
|
2020-07-11 01:26:24 +02:00
|
|
|
&& ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m))
|
2020-03-07 23:03:56 +01:00
|
|
|
&& seen_methods.insert(func.name(ctx.db))
|
|
|
|
{
|
2020-04-03 19:33:12 +02:00
|
|
|
acc.add_function(ctx, func, None);
|
2020-01-14 14:42:52 +01:00
|
|
|
}
|
|
|
|
None::<()>
|
|
|
|
});
|
|
|
|
}
|
2019-01-07 19:12:19 +01:00
|
|
|
}
|
|
|
|
|
2019-01-08 22:33:36 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2020-08-21 13:19:31 +02:00
|
|
|
use expect_test::{expect, Expect};
|
2020-07-04 10:36:12 +02:00
|
|
|
use test_utils::mark;
|
|
|
|
|
2020-10-18 13:09:00 +03:00
|
|
|
use crate::{test_utils::completion_list, CompletionKind};
|
2019-01-08 22:33:36 +03:00
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
fn check(ra_fixture: &str, expect: Expect) {
|
|
|
|
let actual = completion_list(ra_fixture, CompletionKind::Reference);
|
|
|
|
expect.assert_eq(&actual);
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_struct_field_and_method_completion() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct S { foo: u32 }
|
|
|
|
impl S {
|
|
|
|
fn bar(&self) {}
|
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(s: S) { s.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2020-07-04 19:03:58 +02:00
|
|
|
fd foo u32
|
2021-01-22 18:59:22 +03:00
|
|
|
me bar() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-01-08 22:33:36 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_struct_field_completion_self() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct S { the_field: (u32,) }
|
|
|
|
impl S {
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(self) { self.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field (u32,)
|
2021-01-22 18:59:22 +03:00
|
|
|
me foo() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
|
|
|
)
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_struct_field_completion_autoderef() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A { the_field: (u32, i32) }
|
|
|
|
impl A {
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(&self) { self.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field (u32, i32)
|
2021-01-22 18:59:22 +03:00
|
|
|
me foo() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
|
|
|
)
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_no_struct_field_completion_for_method_call() {
|
2020-07-04 10:36:12 +02:00
|
|
|
mark::check!(test_no_struct_field_completion_for_method_call);
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A { the_field: u32 }
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: A) { a.$0() }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[""]],
|
2019-01-08 22:33:36 +03:00
|
|
|
);
|
|
|
|
}
|
2019-01-07 19:12:19 +01:00
|
|
|
|
2019-12-24 21:46:07 +01:00
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_visibility_filtering() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
mod inner {
|
|
|
|
pub struct A {
|
|
|
|
private_field: u32,
|
|
|
|
pub pub_field: u32,
|
|
|
|
pub(crate) crate_field: u32,
|
2020-10-25 10:59:15 +03:00
|
|
|
pub(crate) super_field: u32,
|
2020-04-28 22:45:46 +02:00
|
|
|
}
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: inner::A) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2020-07-04 19:03:58 +02:00
|
|
|
fd pub_field u32
|
2020-12-19 13:18:40 +02:00
|
|
|
fd crate_field u32
|
2020-07-04 10:36:12 +02:00
|
|
|
fd super_field u32
|
|
|
|
"#]],
|
2019-12-24 21:46:07 +01:00
|
|
|
);
|
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A {}
|
|
|
|
mod m {
|
|
|
|
impl super::A {
|
|
|
|
fn private_method(&self) {}
|
2020-10-25 10:59:15 +03:00
|
|
|
pub(crate) fn the_method(&self) {}
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: A) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-01-07 19:12:19 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-12-02 19:27:31 +01:00
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_union_field_completion() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
union U { field: u8, other: u16 }
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(u: U) { u.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd field u8
|
|
|
|
fd other u16
|
|
|
|
"#]],
|
2019-12-02 19:27:31 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-07 23:03:56 +01:00
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_method_completion_only_fitting_impls() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A<T> {}
|
|
|
|
impl A<u32> {
|
|
|
|
fn the_method(&self) {}
|
|
|
|
}
|
|
|
|
impl A<i32> {
|
|
|
|
fn the_other_method(&self) {}
|
|
|
|
}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: A<u32>) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
|
|
|
)
|
2020-03-07 23:03:56 +01:00
|
|
|
}
|
|
|
|
|
2019-04-14 16:08:10 +02:00
|
|
|
#[test]
|
|
|
|
fn test_trait_method_completion() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A {}
|
|
|
|
trait Trait { fn the_method(&self); }
|
|
|
|
impl Trait for A {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: A) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-04-14 16:08:10 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-29 12:19:03 +02:00
|
|
|
#[test]
|
|
|
|
fn test_trait_method_completion_deduplicated() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r"
|
|
|
|
struct A {}
|
|
|
|
trait Trait { fn the_method(&self); }
|
|
|
|
impl<T> Trait for T {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: &A) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
",
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-06-29 12:19:03 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-14 20:48:36 +01:00
|
|
|
#[test]
|
|
|
|
fn completes_trait_method_from_other_module() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
2019-01-07 19:12:19 +01:00
|
|
|
r"
|
2020-07-04 10:36:12 +02:00
|
|
|
struct A {}
|
|
|
|
mod m {
|
|
|
|
pub trait Trait { fn the_method(&self); }
|
|
|
|
}
|
|
|
|
use m::Trait;
|
|
|
|
impl Trait for A {}
|
2021-01-06 20:15:48 +00:00
|
|
|
fn foo(a: A) { a.$0 }
|
2020-07-04 10:36:12 +02:00
|
|
|
",
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-01-07 19:12:19 +01:00
|
|
|
);
|
|
|
|
}
|
2019-01-24 08:25:35 -05:00
|
|
|
|
2019-02-12 19:58:36 +02:00
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_no_non_self_method() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A {}
|
|
|
|
impl A {
|
|
|
|
fn the_method() {}
|
|
|
|
}
|
|
|
|
fn foo(a: A) {
|
2021-01-06 20:15:48 +00:00
|
|
|
a.$0
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[""]],
|
2019-02-12 19:58:36 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-24 08:25:35 -05:00
|
|
|
#[test]
|
|
|
|
fn test_tuple_field_completion() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
fn foo() {
|
|
|
|
let b = (0, 3.14);
|
2021-01-06 20:15:48 +00:00
|
|
|
b.$0
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd 0 i32
|
|
|
|
fd 1 f64
|
|
|
|
"#]],
|
|
|
|
)
|
2019-01-24 08:25:35 -05:00
|
|
|
}
|
2019-04-05 22:59:55 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_tuple_field_inference() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
pub struct S;
|
|
|
|
impl S { pub fn blah(&self) {} }
|
2019-04-05 22:59:55 +02:00
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
struct T(S);
|
2019-04-05 22:59:55 +02:00
|
|
|
|
2020-07-04 10:36:12 +02:00
|
|
|
impl T {
|
|
|
|
fn foo(&self) {
|
|
|
|
// FIXME: This doesn't work without the trailing `a` as `0.` is a float
|
2021-01-06 20:15:48 +00:00
|
|
|
self.0.a$0
|
2019-04-11 16:22:10 +03:00
|
|
|
}
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me blah() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2019-04-05 22:59:55 +02:00
|
|
|
);
|
|
|
|
}
|
2019-08-03 01:15:43 +07:00
|
|
|
|
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_completion_works_in_consts() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct A { the_field: u32 }
|
|
|
|
const X: u32 = {
|
2021-01-06 20:15:48 +00:00
|
|
|
A { the_field: 92 }.$0
|
2020-07-04 10:36:12 +02:00
|
|
|
};
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field u32
|
|
|
|
"#]],
|
2020-02-29 20:53:01 -08:00
|
|
|
);
|
|
|
|
}
|
2020-03-07 15:27:03 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn works_in_simple_macro_1() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
macro_rules! m { ($e:expr) => { $e } }
|
|
|
|
struct A { the_field: u32 }
|
|
|
|
fn foo(a: A) {
|
2021-01-06 20:15:48 +00:00
|
|
|
m!(a.x$0)
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field u32
|
|
|
|
"#]],
|
2020-03-07 15:27:03 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
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
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
macro_rules! m { ($e:expr) => { $e } }
|
|
|
|
struct A { the_field: u32 }
|
|
|
|
fn foo(a: A) {
|
2021-01-06 20:15:48 +00:00
|
|
|
m!(a.$0)
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field u32
|
|
|
|
"#]],
|
2020-03-07 15:27:03 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn works_in_simple_macro_recursive_1() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
macro_rules! m { ($e:expr) => { $e } }
|
|
|
|
struct A { the_field: u32 }
|
|
|
|
fn foo(a: A) {
|
2021-01-06 20:15:48 +00:00
|
|
|
m!(m!(m!(a.x$0)))
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field u32
|
|
|
|
"#]],
|
2020-03-07 15:27:03 +01:00
|
|
|
);
|
|
|
|
}
|
2020-03-10 20:56:26 +01:00
|
|
|
|
2020-03-13 13:03:31 +01:00
|
|
|
#[test]
|
|
|
|
fn macro_expansion_resilient() {
|
2020-07-04 10:36:12 +02:00
|
|
|
check(
|
|
|
|
r#"
|
2020-12-28 01:20:44 +08:00
|
|
|
macro_rules! d {
|
2020-07-04 10:36:12 +02:00
|
|
|
() => {};
|
|
|
|
($val:expr) => {
|
|
|
|
match $val { tmp => { tmp } }
|
|
|
|
};
|
|
|
|
// Trailing comma with single argument is ignored
|
2020-12-28 01:20:44 +08:00
|
|
|
($val:expr,) => { $crate::d!($val) };
|
2020-07-04 10:36:12 +02:00
|
|
|
($($val:expr),+ $(,)?) => {
|
2020-12-28 01:20:44 +08:00
|
|
|
($($crate::d!($val)),+,)
|
2020-07-04 10:36:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
struct A { the_field: u32 }
|
|
|
|
fn foo(a: A) {
|
2020-12-28 01:20:44 +08:00
|
|
|
d!(a.$0)
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
fd the_field u32
|
|
|
|
"#]],
|
2020-03-13 13:03:31 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-10 20:56:26 +01:00
|
|
|
#[test]
|
2020-07-04 10:36:12 +02:00
|
|
|
fn test_method_completion_issue_3547() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct HashSet<T> {}
|
|
|
|
impl<T> HashSet<T> {
|
|
|
|
pub fn the_method(&self) {}
|
|
|
|
}
|
|
|
|
fn foo() {
|
|
|
|
let s: HashSet<_>;
|
2021-01-06 20:15:48 +00:00
|
|
|
s.$0
|
2020-07-04 10:36:12 +02:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me the_method() -> ()
|
2020-07-04 10:36:12 +02:00
|
|
|
"#]],
|
2020-03-10 20:56:26 +01:00
|
|
|
);
|
|
|
|
}
|
2020-10-17 23:43:13 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn completes_method_call_when_receiver_is_a_macro_call() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
struct S;
|
|
|
|
impl S { fn foo(&self) {} }
|
|
|
|
macro_rules! make_s { () => { S }; }
|
2021-01-06 20:15:48 +00:00
|
|
|
fn main() { make_s!().f$0; }
|
2020-10-17 23:43:13 +02:00
|
|
|
"#,
|
|
|
|
expect![[r#"
|
2021-01-22 18:59:22 +03:00
|
|
|
me foo() -> ()
|
2020-10-17 23:43:13 +02:00
|
|
|
"#]],
|
|
|
|
)
|
|
|
|
}
|
2021-02-23 14:54:01 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn completes_after_macro_call_in_submodule() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
macro_rules! empty {
|
|
|
|
() => {};
|
|
|
|
}
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
struct Template2 {}
|
|
|
|
|
|
|
|
impl Template2 {
|
|
|
|
fn private(&self) {}
|
|
|
|
}
|
|
|
|
fn baz() {
|
|
|
|
let goo: Template2 = Template2 {};
|
|
|
|
empty!();
|
|
|
|
goo.$0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
me private() -> ()
|
|
|
|
"#]],
|
|
|
|
);
|
|
|
|
}
|
2019-01-08 22:33:36 +03:00
|
|
|
}
|