Skip to content

Regression in macro error spans #33884

Closed
Closed
@sophiajt

Description

@sophiajt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions