Skip to content

Errors are too verbose since 1.72.0 #115382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bytefall opened this issue Aug 30, 2023 · 2 comments
Closed

Errors are too verbose since 1.72.0 #115382

bytefall opened this issue Aug 30, 2023 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bytefall
Copy link

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

@bytefall bytefall added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 30, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 30, 2023
@Noratrieb Noratrieb added D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 30, 2023
@compiler-errors
Copy link
Member

This should be fixed by #115294. Can you see if this error continues to be triggered on nightly?

@atsuzaki
Copy link
Contributor

atsuzaki commented Aug 30, 2023

It's fixed in the latest nightly (1.74.0-nightly 2023-08-29 84a9f4c) https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=92ffa9a7006de803740f77c23168d192

We can close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants