This repository was archived by the owner on Aug 23, 2022. It is now read-only.
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
Thunder code stealing error messages from compiler #28
Open
Description
Hi, check this code out:
use thunder::thunderclap;
struct MyApp;
#[thunderclap]
impl MyApp {
fn hello(name: &str) -> Result<&str,()> {
println!("Hello {}", name);
}
}
fn main() {
MyApp::hello("kat");
}
Compilation errors:
$ cargo check
Checking test-thunder v0.1.0 (/home/xxx/tmp/test-thunder)
error[E0308]: mismatched types
--> src/main.rs:5:1
|
5 | #[thunderclap]
| ^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
|
= note: expected type `std::result::Result<&str, ()>`
found type `()`
error[E0308]: match arms have incompatible types
--> src/main.rs:5:1
|
5 | #[thunderclap]
| ^^^^^^^^^^^^^^
| |
| expected enum `std::result::Result`, found ()
| match arm with an incompatible type
|
= note: expected type `std::result::Result<&str, ()>`
found type `()`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
error: Could not compile `test-thunder`.
I see two issues here:
thunderclap
is "stealing" the error positioning, which is unfortunate because on large codebases it could make hard to understand where exactly is the error- There are two errors reported instead of one
Correct error expected:
$ cargo_check
Checking test-thunder v0.1.0 (/home/xxx/tmp/test-thunder)
error[E0308]: mismatched types
--> src/main.rs:7:45
|
7 | fn hello(name: &str) -> Result<&str,()> {
| _____________________________________________^
8 | | println!("Hello {}", name);
9 | | }
| |_____^ expected enum `std::result::Result`, found ()
|
= note: expected type `std::result::Result<&str, ()>`
found type `()`
Running on edition = "2018"
:
$ rustc --version
rustc 1.33.0-nightly (adbfec229 2018-12-17)
Opinions?