Skip to content

Multiple-character char literal error should mention non-printing characters #90857

Closed
@5225225

Description

@5225225

Given the following code:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1896e58442e271fd3b78e60396ffebc1

fn main() {
    let x = vec!['<​'];
    println!("{:?}", x);
}

(which has a zero width space between the < and its ending ')

The current output is:

error: character literal may only contain one codepoint
 --> src/main.rs:2:18
  |
2 |     let x = vec!['<​'];
  |                  ^^^
  |
help: if you meant to write a `str` literal, use double quotes
  |
2 |     let x = vec!["<​"];
  |                  ~~~ 

If there are any non-printing characters, show where they are (debug unicode representation on the whole string, maybe?), and if there's only one printing character, make a suggestion to remove everything but the printing character.

Metadata

Metadata

Assignees

Labels

A-UnicodeArea: UnicodeA-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