Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing note in compiler error when expanding macro #33774

Closed
lukaszwawrzyk opened this issue May 21, 2016 · 3 comments
Closed

missing note in compiler error when expanding macro #33774

lukaszwawrzyk opened this issue May 21, 2016 · 3 comments

Comments

@lukaszwawrzyk
Copy link

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
@durka
Copy link
Contributor

durka commented May 21, 2016

Hopefully fixed by #33749.

@jseyfried
Copy link
Contributor

This was fixed in #33730 (landed two days ago).
@lukaszwawrzyk you should get a better error on the most recent nighties.

@lukaszwawrzyk
Copy link
Author

Yes, I updated and I get expected result now, thank you!

<std macros>:5:8: 6:45 error: mismatched types [E0308]
<std macros>:5 return $ crate :: result :: Result :: Err (
                      ^
src/main.rs:24:5: 24:25 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<_, _>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants