Rust IDE doesn't detect Result from error_chain, thinks I am using std :: result :: Result

I have a file errors.rs

with error_chain! {}

that exports Result

, ResultExt

, Error

and ErrorKind

.

If I am use self::errors::*

, IntelliJ thinks I'm using the default Result

( std::result::Result

I guess). However, if I explicitly import the types with use self::errors::{Result, ...}

, everything works hunky dory.

I can tell because the standard result has two types of params, but error_chain

only has one.

It still compiles anyway.

I am using the standard Rust IntelliJ plugin, version 0.1.0.1991

.

Help! Does anyone know how to get the plugin to understand what the macro is doing?

+3


source to share


1 answer


IntelliJ-Rust plugin uses its own code analyzer. It allows you to use all the features of the IntelliJ platform (for example, code navigation, formatting, refactoring, validations, quick documentation, markers, and many others), but requires the implementation of all language features, which is not an easy task for Rust (you can find a more detailed discussion of the parser the Rust compiler versus the IDE parser in this reddit post ).

Macro expansion is probably the biggest feature of the language that is not supported by the plugin parser at the moment. That is, the plugin sees this call error_chain!

, can resolve it for its definition, but does not extend it to the actual code, and therefore does not know about the new structure Result

that shadows one of the stdlibs. Unfortunately, in some cases this leads to such false positive error messages.



I converted this error annotation into a validation, so in the next version of the plugin you will be able to disable it completely or for a specific block of code. Work on expanding macros is also ongoing.

+4


source







All Articles