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

Regression in macro error spans #33884

Closed
sophiajt opened this issue May 26, 2016 · 4 comments
Closed

Regression in macro error spans #33884

sophiajt opened this issue May 26, 2016 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@sophiajt
Copy link
Contributor

I'm seeing a regression in error spans for this use case:

use std::net::TcpListener;
use std::net::TcpStream;
use std::io::{self, Read, Write};

fn handle_client(stream: TcpStream) -> io::Result<()> {
    stream.write_fmt(format!("message received"))
}

fn main() {
    if let Ok(listener) = TcpListener::bind("127.0.0.1:8080") {
        for incoming in listener.incoming() {
            if let Ok(stream) = incoming {
                handle_client(stream);
            }
        }
    }
}

On 5-19-2016, the error span looks okay:

error: mismatched types [--explain E0308]
 --> macro_errors_small.rs:7:22
7 |>     stream.write_fmt(format!("message received"))
  |>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::fmt::Arguments`, found struct `std::string::String`
macro_errors_small.rs:7:22: 7:49: note: in this expansion of format! (defined in <std macros>)
note: expected type `std::fmt::Arguments<'_>`
note:    found type `std::string::String`

On 5-20-2016, the error span became less helpful:

error: mismatched types [--explain E0308]
 --> <std macros>:2:1
2 |> $ crate :: fmt :: format ( format_args ! ( $ ( $ arg ) * ) ) )
  |> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::fmt::Arguments`, found struct `std::string::String`
macro_errors_small.rs:7:22: 7:49: note: in this expansion of format! (defined in <std macros>)
note: expected type `std::fmt::Arguments<'_>`
note:    found type `std::string::String`

It's possible it's related to #33683 (cc @nikomatsakis and @sanxiyn) but I haven't done the full bisect.

@jseyfried
Copy link
Contributor

This was caused by #33712.

@sophiajt
Copy link
Contributor Author

Noticing the same issue with src/test/compile-fail/bad-format-args.rs

@bstrie bstrie added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 24, 2016
@estebank
Copy link
Contributor

Current output is back to what it was before:

error[E0308]: mismatched types
 --> <anon>:6:22
  |
6 |     stream.write_fmt(format!("message received"))
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::fmt::Arguments`, found struct `std::string::String`
  |
  = note: expected type `std::fmt::Arguments<'_>`
             found type `std::string::String`
  = note: this error originates in a macro outside of the current crate

@nikomatsakis
Copy link
Contributor

@estebank is there a regression test? if so, shall we close this issue?

estebank added a commit to estebank/rust that referenced this issue Apr 21, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 21, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 22, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 22, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 22, 2017
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