flycheck / flycheck-rust

Better Rust/Cargo support for Flycheck
GNU General Public License v3.0
121 stars 19 forks source link

How to get better error message #71

Closed shpazk closed 5 years ago

shpazk commented 5 years ago

Hi

flycheck-rust on my Emacs 25.2.2 doesn't provide rich description of the error.

It always reports the first token of the code as the point of failure (with highlights), and error message always looks like this.

For more information about this error, try `rustc --explain E0599`.

How can I get more precise know where the error is happening, and get more helpful error message?

My configuration looks like:

(use-package flycheck-rust
  :config
  (with-eval-after-load 'rust-mode
    (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))

Thanks!

shpazk commented 5 years ago

While cargo check seems to output correct error message, flycheck-rust.el at master branch doesn't show the correct error messages!

fmdkdd commented 5 years ago

Can you get a screenshot of what the error looks like? Or provide a minimal example of code with which I can reproduce?

Also, please state your rustc and cargo versions.

shpazk commented 5 years ago

Thank you for your early response!

I tried rustc 1.32.0-nightly and cargo 1.33.0-nightly.

This is how the error looks like. Here is a screenshot of wrong error message. screenshot from 2018-12-15 11-37-59

Thanks!

fmdkdd commented 5 years ago

Can you show the output of cargo check for your project? Please also report your flycheck version and flycheck-rust version.

shpazk commented 5 years ago

Here's the error message that cargo check provides:

hello λ cargo check
    Checking hello v0.1.0 (/home/shpark/src/rust/hello)
error[E0425]: cannot find value `error` in this scope
 --> src/main.rs:3:5
  |
3 |     error
  |     ^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `hello`.

To learn more, run the command again with --verbose.

And the version of flycheck is 31 and the version of flycheck-rust is 20180904.1117.

Found on M-x package-list-packages.

Thanks!

fmdkdd commented 5 years ago

@shpazk Can you report the output of flycheck-verify-setup in that buffer?

I cannot reproduce your issue with the latest flycheck/flycheck-rust versions from MELPA.

shpazk commented 5 years ago

@fmdkdd This is the result of flycheck-verify-setup from the buffer. Thanks for paying attention to the issue!

Syntax checkers for buffer main.rs in rust-mode:                                                                              

  rust-cargo                                                                                                                  
    - may enable:  yes                                                                                                        
    - predicate:   t                                                                                                          
    - executable:  Found at /home/shpark/.cargo/bin/cargo                                                                     
    - Cargo.toml:  Found                                                                                                      
    - Crate type:  bin                                                                                                        
    - Binary name: hello-world                                                                                                

  rust                                                                                                                        
    - may enable: yes                                                                                                         
    - predicate:  t                                                                                                           
    - executable: Found at /home/shpark/.cargo/bin/rustc                                                                      

Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.                                                        

--------------------                                                                                                          

Flycheck version: 31                                                                                                          
Emacs version:    25.2.2                                                                                                      
System:           x86_64-pc-linux-gnu                                                                                         
Window system:    nil                                                                                                         
fmdkdd commented 5 years ago

Ooooh. You are using the stable Flycheck version from MELPA stable. I'm pretty sure current versions of Rust are incompatible with that one.

We are overdue for a release, but there are still some new features that needs tuning before we land that. I suggest you use the latest Flycheck version, not the stable one. We are very careful about not pushing breaking updates to master, don't worry.

shpazk commented 5 years ago

Whoa. It seems to work with the flycheck version from MELPA. (without stable)

Thanks!

fmdkdd commented 5 years ago

Happy hacking!