Skip to content

Error messages for ? are not great #37671

@brson

Description

@brson
fn main() {
    Ok("lol")?;
}
$ rustc test.rs
error[E0277]: the trait bound `(): std::ops::Carrier` is not satisfied
 --> test.rs:2:5
  |
2 |     Ok("lol")?;
  |     ^^^^^^^^^^ the trait `std::ops::Carrier` is not implemented for `()`
  |
  = note: required by `std::ops::Carrier::from_error`

error: aborting due to previous error

@eddyb says this can be improved by adding #[rustc_on_unimplemented = "the type{Self}cannot be used with?"] to something (maybe the Carrier trait.

crib off of fmt

cc @jonathandturner @nikomatsakis @nrc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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