intellij-rust: Syntax highlighting/code completion not working for (some) tokio modules
Environment
- IntelliJ Rust plugin version: 0.2.110.2150-193 (also tried 192)
- Rust toolchain version: 1.39.0
- IDE name and version: Clion 2019.3, also tested 2019.2.5
- Operating system: Windows 10 Version 1909, also tested MacOS 10.14.6
Problem description
This problem is possibly very similar to #4627 but with tokio
instead of async_std
…something to do with macro resolution probably.
The main reason I’m posting this is because I’ve found a (rather obvious) very fragile unsafe workaround to mitigate the pain of
not having proper code analysis (in CLion) temporarily.
The issue is described best by some code:
use tokio::net::TcpStream; //
// ^^^^^^ Lack of color here, can't Cmd/Ctrl-B here.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let tcp = TcpStream::connect("420.4.2.0:4204").await?;
// ^^^^^^^^^^^^^^^^^^ Unresolved reference: `TcpStream`
Steps to reproduce
In Cargo.toml
, add:
[dependencies.tokio]
version = "0.2.2"
features = [ "full" ]
(I added “full” to enable all possible features, just to make sure the issue isn’t caused by a feature not being enabled)
Steps to hack around
What we do here is basically trade a real eye for 2 fake ones:
From tokio-0.2.2/src/net/mod.rs
, note lines 28-32:
cfg_tcp! {
pub mod tcp;
pub use tcp::listener::TcpListener;
pub use tcp::stream::TcpStream;
}
Well, cfg_tcp!
causes the issue…so I deemed it necessary to hardcode:
// cfg_tcp! {
pub mod tcp;
pub use tcp::listener::TcpListener;
pub use tcp::stream::TcpStream;
// }
Maybe the plugin could do something like this behind the scenes as a temporary hack to get things working; just throwing out ideas because I’ve heard that this issue has been around for quite awhile.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 16 (5 by maintainers)
@shibang did you enable new macro expansion engine (see #3628)?
0.2.113.2150-193 still an issue 😦
clion 2019.3.1 with rust plugin 0.2.112.2148-193 has this problem too
@YenForYang Thanks for the hack… IMHO - Learning Tokio without IDE support for beginners like me is quite hard 😃 … i was able to hack util & io too with your tip… Cheers 👍
Just chiming in to say I arrived here from Google having the same issue and the new macro expansion engine also fixed mine, excellent work guys! Thank you so much for making such a fantastic IDE constantly better
I install nightly plugin and it works well now, thanks for your job.
Arseniy Pendryak notifications@github.com 于2020年2月8日周六 下午2:57写道:
It’s fixed in #4914 and will be landed in the next release (I hope). I close this issue as a duplicate of #4627 because they have the same reason