rust-lang / vscode-rust

Rust extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Other
1.39k stars 167 forks source link

Incomplete error message #645

Open bbugh opened 5 years ago

bbugh commented 5 years ago

Hi 👋 I'm new to Rust, and ran into an issue that I got confused about that I reported in the main language repo, but it turned out to be this extension.

The error message highlighted in the editor hover (see screenshot) truncated important error details from the terminal output:

image

but running cargo test in the terminal correctly reported the full message:

error[E0599]: no method named `try_into` found for type `u32` in the current scope
 --> src/lib.rs:2:37
  |
2 |   let mut sieve = vec![true; number.try_into().unwrap()];
  |                                     ^^^^^^^^
  |
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
1 | use std::convert::TryInto;
  |

In case it's not clear comparing the screenshot, part that was truncated contained the setup to try to fix it:

# this was missing
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
1 | use std::convert::TryInto;
  |
remidebette commented 4 years ago

Hi,

Indeed this is really relevant to beginners. The rust compiler provides very good recommendations but in this case the programmer does not get the (very easy and relevant) fix to his issue.

To get this insight, in this specific case, he would need to compile his code himself instead of getting the hint directly from the IDE while coding, or read some obscure stackoverflow and github threads (such as the linked https://github.com/rust-lang/rust/issues/47168#issuecomment-520623989)

This would help a lot the beginners.