简体   繁体   English

为什么`cargo build`没有在我的代码中显示所有错误?

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

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::*; 如果我添加extern crate hyper; use hyper::mime::*; 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? 我猜Cargo只显示一个错误? I could not find anything about this behaviour online. 我在网上找不到任何有关此行为的信息。 How can I see all errors? 我怎么能看到所有错误?

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? ). 这不是特定于Cargo,而是特定于rustc (例如: 何时将数字文字分配给默认类型? )。

I haven't seen it officially documented, but the high-level process has been described by japaric : 我还没有看到它正式记录,但日本人已经描述了高级过程:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM