Skip to content

Errors are too verbose since 1.72.0 #115382

Closed
@bytefall

Description

@bytefall

Code

// cargo new testx
// cd testx
// cargo add tokio -F full
#[tokio::main]
async fn main() -> Result<(), impl std::error::Error> {
    tokio::spawn(run()).await
}

async fn run() {
    let i: u8 = ""; // E0308 is here
}

Current output

Checking testx v0.1.0 (/tmp/testx)
error[E0308]: mismatched types
 --> src/main.rs:7:17
  |
7 |     let i: u8 = "";
  |            --   ^^ expected `u8`, found `&str`
  |            |
  |            expected due to this

error: cannot check whether the hidden type of opaque type satisfies auto traits
   --> src/main.rs:3:18
    |
3   |     tokio::spawn(run()).await
    |     ------------ ^^^^^
    |     |
    |     required by a bound introduced by this call
    |
note: opaque type is declared here
   --> src/main.rs:6:16
    |
6   | async fn run() {
    |                ^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
   --> src/main.rs:2:10
    |
2   | async fn main() -> Result<(), impl std::error::Error> {
    |          ^^^^
note: required by a bound in `tokio::spawn`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/task/spawn.rs:166:21
    |
164 |     pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
    |            ----- required by a bound in this function
165 |     where
166 |         T: Future + Send + 'static,
    |                     ^^^^ required by this bound in `spawn`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `testx` (bin "testx") due to 2 previous errors

Desired output

Checking testx v0.1.0 (/tmp/2/testx)
error[E0308]: mismatched types
 --> src/main.rs:7:17
  |
7 |     let i: u8 = "";
  |            --   ^^ expected `u8`, found `&str`
  |            |
  |            expected due to this

For more information about this error, try `rustc --explain E0308`.
error: could not compile `testx` (bin "testx") due to previous error

Rationale and extra context

Something has changed in rustc 1.72.0. Error diagnostics become too verbose.

Provided example contains E0308 which is hard to locate due to verbose trait bounds description. With more async code it's getting even worse.

Previous version 1.71.0 shows only the place where an actual error is (see "desired output").

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions