mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Merge #6271
6271: Complete methods when receiver is a macro r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
aed7b6d98a
@ -105,14 +105,16 @@ impl Expander {
|
||||
|
||||
let macro_call = InFile::new(self.current_file_id, ¯o_call);
|
||||
|
||||
if let Some(call_id) = macro_call.as_call_id(db, self.crate_def_map.krate, |path| {
|
||||
let resolver = |path: ModPath| -> Option<MacroDefId> {
|
||||
if let Some(local_scope) = local_scope {
|
||||
if let Some(def) = path.as_ident().and_then(|n| local_scope.get_legacy_macro(n)) {
|
||||
return Some(def);
|
||||
}
|
||||
}
|
||||
self.resolve_path_as_macro(db, &path)
|
||||
}) {
|
||||
};
|
||||
|
||||
if let Some(call_id) = macro_call.as_call_id(db, self.crate_def_map.krate, resolver) {
|
||||
let file_id = call_id.as_file();
|
||||
if let Some(node) = db.parse_or_expand(file_id) {
|
||||
if let Some(expr) = T::cast(node) {
|
||||
|
@ -389,6 +389,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
|
||||
CALL_EXPR => FragmentKind::Expr,
|
||||
INDEX_EXPR => FragmentKind::Expr,
|
||||
METHOD_CALL_EXPR => FragmentKind::Expr,
|
||||
FIELD_EXPR => FragmentKind::Expr,
|
||||
AWAIT_EXPR => FragmentKind::Expr,
|
||||
CAST_EXPR => FragmentKind::Expr,
|
||||
REF_EXPR => FragmentKind::Expr,
|
||||
|
@ -413,4 +413,19 @@ fn foo() {
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[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 }; }
|
||||
fn main() { make_s!().f<|>; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
me foo() fn foo(&self)
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user