簡體   English   中英

為什么`cargo build`沒有在我的代碼中顯示所有錯誤?

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

此代碼無法編譯:

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));
}

表明:

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

如果我添加extern crate hyper; use hyper::mime::*; extern crate hyper; use hyper::mime::*; ,然后它顯示:

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;
  | ^^^^^^^^^^^^

如果我早些時候能看到這個,它會幫助我解決這個錯誤......

我猜Cargo只顯示一個錯誤? 我在網上找不到任何有關此行為的信息。 我怎么能看到所有錯誤?

編譯過程分為幾個階段,如果在其中一個階段出現錯誤而導致構建,則不會進一步處理以下階段。 這不是特定於Cargo,而是特定於rustc (例如: 何時將數字文字分配給默認類型? )。

我還沒有看到它正式記錄,但日本人已經描述了高級過程:

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM