Skip to content

error message for type mismatch in macro does not reveal location of macro expansion #19975

Closed
@oli-obk

Description

@oli-obk

Playpen: http://is.gd/izhPM3

use std::io::IoError;
use std::error::FromError;

enum MyError {
    IoError(std::io::IoError),
    OtherError
}

impl FromError<std::io::IoError> for MyError {
    fn from_error(err: std::io::IoError) -> MyError {
        MyError::IoError(err);
    }
}

fn somefun() -> Result<(), MyError>
{
    let mut w = Vec::new();
    write!(&mut w, "test")
}

fn main() {
}

yields

<std macros>:4:9: 5:6 error: mismatched types: expected `core::result::Result<(), MyError>`, found `core::result::Result<(), std::io::IoError>` (expected enum MyError, found struct std::io::IoError)
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
<std macros>:5     })

neither location nor name of the macro is shown. Also the location of the invokation is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions