Skip to content

missing note in compiler error when expanding macro #33774

Closed
@lukaszwawrzyk

Description

@lukaszwawrzyk

rustc does not show where the error that happened inside a macro originates from user code.

I tried this code:

use std::path::PathBuf;

fn foo() -> PathBuf {
    try!(Err("broken"));

    unimplemented!()
}

fn main() {}

I expected to see an error that points me to a line in the file I edited, i.e. main.rs, so this is what rustc 1.8.0 would output:

<std macros>:5:8: 6:42 error: mismatched types:
 expected `std::path::PathBuf`,
    found `core::result::Result<_, _>`
(expected struct `std::path::PathBuf`,
    found enum `core::result::Result`) [E0308]
<std macros>:5 return $ crate:: result:: Result:: Err (
<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
main.rs:4:5: 4:25 note: in this expansion of try! (defined in <std macros>)
<std macros>:5:8: 6:42 help: run `rustc --explain E0308` to see a detailed explanation

The key line here is this one main.rs:4:5: 4:25 note: in this expansion of try! (defined in <std macros>) that points me to line 4.

Instead I get the message that gives me no clue about where to look

<std macros>:5:8: 6:45 error: mismatched types [E0308]
<std macros>:5 return $ crate :: result :: Result :: Err (
                      ^
<std macros>:5:8: 6:45 note: in this expansion of try! (defined in <std macros>)
<std macros>:5:8: 6:45 help: run `rustc --explain E0308` to see a detailed explanation
<std macros>:5:8: 6:45 note: expected type `std::path::PathBuf`
<std macros>:5:8: 6:45 note:    found type `std::result::Result<_, _>`

Meta

rustc 1.10.0-nightly (d91f8ab0f 2016-05-07)
binary: rustc
commit-hash: d91f8ab0f58fa123857d96b9e151fc5185f5ff08
commit-date: 2016-05-07
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions