Skip to content

Incorrect format string span when specifier is followed by backslash #83344

Description

@osa1

Discovered this while debugging #83340. Repro:

fn main() {
    println!("{}\
");
}

Current output:

 --> test.rs:2:15
  |
2 |       println!("{}\
  |  _______________^
3 | | ");
  | |_

I think the span for {} is wrong. With the correct span the error would look like:

error: 1 positional argument in format string, but no arguments were given
 --> test.rs:2:15
  |
2 |       println!("{}\
  |                 ^^
3 | ");

The span is correct when {} is followed by any other character:

fn main() {
    println!("{}
");
}

Output:

error: 1 positional argument in format string, but no arguments were given
 --> test.rs:2:15
  |
2 |     println!("{}
  |               ^^

error: aborting due to previous error

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions