A small suggestion for the error message of the Carrier trait

I have a small suggestion regarding the error message for the ? operator. Right now for a function like this

fn func1() {
     let v = func2()?;
     < code continues here>
}

The error message is:

error[E0277]: the trait bound `(): std::ops::Carrier` is not satisfied
[...]
    |                            -------------------------
    |                            |
    |                            the trait `std::ops::Carrier` is not implemented for `()`
    |                            in this macro invocation

I think is not clear for a newbie that this refers to the return type of the func1 and not func2. Maybe it would be good to clarify the error message. It would be enough to say

error[E0277]: the trait bound `(): std::ops::Carrier` is not satisfied
[...]
    |                            -------------------------
    |                            |
    |                            the trait `std::ops::Carrier` is not implemented for `() ` (func1 return type)
    |                            in this macro invocation

or something similar.

Yep, this is a thing that I’m hoping will be improved soon, here’s the issue for it. This kind of depends on how this RFC shakes out, and discussion is still ongoing. So you’re absolutely right that this is not ideal, and there’s work in progress to address it :slight_smile:

Thanks for the info. If the RFC does not converge soon, maybe is quicker and not so controversial to fix the error message before.

Yup! Exactly what I just asked, and I cited this post :slight_smile: :crossed_fingers::four_leaf_clover:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.