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

Compiler provides incorrect error location for macros instantiations #24058

Closed
Djuffin opened this issue Apr 4, 2015 · 3 comments
Closed

Compiler provides incorrect error location for macros instantiations #24058

Djuffin opened this issue Apr 4, 2015 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@Djuffin
Copy link

Djuffin commented Apr 4, 2015

When trying to compile this code:

pub fn write_to_log(line: String) {
    use std::fs::{File, OpenOptions};
    let resFile = OpenOptions::new().read(true).write(true)
            .append(true).open("log.log");
    let mut file = match resFile {
        Ok(f) => f,
        Err(e) => panic!("file error: {}", e),
    };
    let _ = writeln!(&mut file, "{}", line);
}

fn main() {
    write_to_log("Hello".to_string());
}

compiler prints this message:

<std macros>:2:20: 2:66 error: type `&mut std::fs::File` does not implement any method in scope named `write_fmt`
<std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:2:66: 2:66 help: methods from traits can only be called if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
<std macros>:2:66: 2:66 help: candidate #1: use `std::io::Write`
error: aborting due to previous error

I would expect it to point me to the fine and line where writeln! is used. Right now it very hard to find error location.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 4, 2015
@rprichard
Copy link
Contributor

Duplicate of #23459. I have a PR open (#24003) that adds a macro expansion backtrace.

@jseyfried
Copy link
Contributor

This is fixed -- we've had backtraces now for a while.

@nagisa
Copy link
Member

nagisa commented May 29, 2016

I think this can be closed since it is fixed and duplicate?

@nagisa nagisa closed this as completed May 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

5 participants