Skip to content

Lookahead for closing curly quote when encountering opening curly quote #58436

Closed
@estebank

Description

@estebank

When encountering curly quotes, the compiler now points at the opening one suggesting changing it for a regular straight quote. It should also look ahead looking for a closing curly quote char and suggest changing that one too, because when fixing only the first one, the parser will interpret this as an unclosed string.

fn main() {
    println!(“”);
}
error: unknown start of token: \u{201c}
 --> src/main.rs:2:14
  |
2 |     println!(“”);
  |              ^
help: Unicode character '“' (Left Double Quotation Mark) looks like '"' (Quotation Mark), but it is not
  |
2 |     println!("”);
  |              ^

After applying suggestion:

error: unterminated double quote string
 --> src/main.rs:2:14
  |
2 |       println!("”);
  |  ______________^
3 | | }
  | |_^

Ideally

error: unknown start of token: \u{201c}
 --> src/main.rs:2:14
  |
2 |     println!(“”);
  |              ^-
help: Unicode character '“' (Left Double Quotation Mark) and '”' (Right Double Quotation Mark) look like '"' (Quotation Mark), but it are not
  |
2 |     println!("");
  |              ^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions