-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Confusing error message with panic!()
and impl trait
#66523
Comments
(Sidenote: "cannot resolve" trips me up every time since it feels like it talking about name resolution, not type checking) |
Account for common `impl Trait`/`dyn Trait` return type errors - When all return paths have the same type, suggest `impl Trait`. - When all return paths implement the expected `trait`, suggest `Box<dyn Trait>` and mention using an `enum`. - When multiple different types are returned and `impl Trait` is expected, extend the explanation. - When return type is `impl Trait` and the return paths do not implement `Trait`, point at the returned values. - Split `src/librustc/traits/error_reporting.rs` into multiple files to keep size under control. Fix rust-lang#68110, cc rust-lang#66523.
Current output is a slight regression introduced by #68195:
|
Would "cannot fulfill |
@estebank Maybe "cannot satisfy |
Same issue I think but with a different diagnostic:
gives
I expected it would do the same with |
"cannot resolve" → "cannot satisfy" CC rust-lang#66523 r? @Centril
I just recently hit this, and I don't believe that it is related to the struct MarkerHolder<T> {
_marker: std::marker::PhantomData<*const T>
}
fn make_marker() -> MarkerHolder<impl std::fmt::Display> {
MarkerHolder {
_marker: std::marker::PhantomData,
}
} fails with:
EDIT: On second thought, I can totally see why it errors, the compiler has no way to know what type to assign to the opaque type. I still think that saying it is a recursive type is misleading though. |
Fix rust-lang#70968, partially address rust-lang#66523.
…komatsakis Expand "recursive opaque type" diagnostic Fix rust-lang#70968, partially address rust-lang#66523.
…komatsakis Expand "recursive opaque type" diagnostic Fix rust-lang#70968, partially address rust-lang#66523.
…komatsakis Expand "recursive opaque type" diagnostic Fix rust-lang#70968, partially address rust-lang#66523.
…komatsakis Expand "recursive opaque type" diagnostic Fix rust-lang#70968, partially address rust-lang#66523.
…komatsakis Expand "recursive opaque type" diagnostic Fix rust-lang#70968, partially address rust-lang#66523.
Current output:
|
Triage: the current output is
Which seems pretty good to me - should this be closed as a duplicate of #69882 ? |
The only thing I'd change it so change "item's body" with " |
The following code:
Currently gives the following error:
This message has a weird span, and doesn't give any clue that the problem lies with the call to
panic!
The text was updated successfully, but these errors were encountered: