Skip to content

extend multi-line errors to "method * has incompatible type for trait" #21332

Closed
@mdinger

Description

@mdinger

The multi-line errors should be extended to include this testcase. #19870 missed this because the msg: &str didn't go through Session::span_err. I tried Session::err but that didn't work either. If someone can point me to to where to catch it, I can probably fix this too.

cc @nick29581

Code:

struct S;

impl Iterator for S {
    type Item = i32;
    fn next(&mut self) -> Result<i32, i32> { Ok(7) }
}

fn main() {}

Error:

<anon>:5:5: 5:53 error: method `next` has an incompatible type for trait: expected enum `core::option::Option`, found enum `core::result::Result` [E0053]
<anon>:5     fn next(&mut self) -> Result<i32, i32> { Ok(7) }
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101

Change to:

<anon>:5:5: 5:53 error: method `next` has an incompatible type for trait:
 expected enum `core::option::Option`,
    found enum `core::result::Result` [E0053]
<anon>:5     fn next(&mut self) -> Result<i32, i32> { Ok(7) }
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions