Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `cargo build` not show all errors in my code?

Tags:

rust

This code doesn't compile:

extern crate iron;
#[marco_use] //misspelled here
extern crate mime;

use iron::prelude::*;
use iron::status;

fn main() {
    let mut response = Response::new();
    response.set_mut(mime!(Text/Html; Charset=Utf8));
}

it shows:

error: cannot find macro `mime!` in this scope
  --> src/main.rs:10:22
   |
10 |     response.set_mut(mime!(Text/Html; Charset=Utf8));
   |                      ^^^^

If I add extern crate hyper; use hyper::mime::*;, then it shows:

error: The attribute `marco_use` is currently unknown to the compiler and 
may have meaning added to it in the future (see issue #29642)
 --> src\main.rs:2:1
  |
2 | #[marco_use] extern crate mime;
  | ^^^^^^^^^^^^

If I could've seen this earlier, it would've helped me to fix the mistake...

I guess Cargo only shows one error? I could not find anything about this behaviour online. How can I see all errors?

like image 543
yassin Avatar asked Jan 29 '23 19:01

yassin


1 Answers

The compilation process is divided into several stages and if during one of them an error breaks the build, the following stages are not processed further. This is not specific to Cargo, but rustc as well (example: When are numeric literals assigned to default types?).

I haven't seen it officially documented, but the high-level process has been described by japaric:

enter image description here

like image 85
ljedrz Avatar answered Feb 03 '23 13:02

ljedrz