Skip to content

flyimport for macros does not work at root level of module. #12656

@jhgg

Description

@jhgg

Consider the following macro_rules macro defined in another crate:

#[macro_export]
macro_rules! define_struct {
    () => {
        pub struct Foo;
    };
}

It does not complete when it is at the "root" of a module (not sure if this is the right terminology, it's direct parent in AST is SourceFile)

defi$0

fn main() {
    defi$1
}

Completion works for $1, but not $0. Completion will work at $0 if there is a use some_crate::define_struct; at the top of the file.

This is somewhat a recent regression most likely, because I think this was working in the past!

rust-analyzer version: 0.0.0 (b0102bd 2022-06-28)
rustc 1.63.0-nightly (12cd71f 2022-06-01)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionautocompletionC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions