简体   繁体   中英

Rust autocompletion not working with certain crates

I am experiencing issues with the autocompletion feature of my IDE when using certain crates, like pnet . I am using CLion with the Rust extension but the problem also occurs with VSCode. It seems like the IDE is completely unaware of certain parts of the library.

let packet = pnet::packet::ipv4::Ipv4Packet::new(&data);

Here for example I am losing autocompletion after ipv4:: . Also syntax highlighting does not work.

Does this have something to do with the way this crate is utilizing macros? Has anybody an idea on how to make autocompletion work?

Auto-completion engines have known issues with Rust macros and generated code.

This is likely what is causing the issue with pnet .

pnet::packet is defined as

extern crate pnet_packet;

/// Support for packet parsing and manipulation.
pub mod packet {
    pub use pnet_packet::*;
}

with pnet_packet being a crate with a build.rs script that generates most of the code.

There is not much you can do to help your IDE as far as I know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM