Skip to content

I want to make path completion in macro but I have no idea how to do it #10106

Answered by vlad20012
Wireless4024 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!
You seem to be doing everything right, but there is a bug is on our side. That is, any special handling of IDE completion in your macro should not be needed and just expanding to std::path::Path::new(#path) should work. I'm not sure what exactly the bug is, I'll try to investigate it.

By the way, I'd suggest to check whether the macro is invoked from an IDE for completion purposes using this function:

fn is_ide_completion() -> bool {
    match std::env::var_os("RUST_IDE_PROC_MACRO_COMPLETION_DUMMY_IDENTIFIER") {
        None => false,
        Some(dummy_identifier) => !dummy_identifier.is_empty(),
    }
}

But again, in your case it seems like checking these variables is not needed.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Wireless4024
Comment options

Answer selected by Wireless4024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants