Skip to content

Strange formatting for 'more than one codepoint in char' error message #38434

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

Closed
frewsxcv opened this issue Dec 17, 2016 · 5 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@frewsxcv
Copy link
Member

Code (playpen)

fn main() {
    let heart = '❤️';
}

Error:

error: character literal may only contain one codepoint: '❤
 --> <anon>:2:17
  |
2 |     let heart = '❤️';
  |                 ^^

error: aborting due to previous error

Why do we only show one quotation mark ('❤) in the first line of the error? Seems like we should either display both or none

@frewsxcv frewsxcv added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 17, 2016
@frewsxcv
Copy link
Member Author

If this gets addressed, make sure to update the error message in this section:

https://doc.rust-lang.org/std/primitive.char.html#representation

@frewsxcv
Copy link
Member Author

Actually, it's a little more obvious to me what's going on here now that I see how GitHub formats the hearts. It's displaying <quotation mark><first code point>.

I think this is a duplicate, but am not sure.

Similar to #36998 (which I want to address), but this is more about the error message

@frewsxcv
Copy link
Member Author

frewsxcv commented Dec 17, 2016

Interestingly, in this case, we show the entire contents of the character literal with both quotes in the error:

Code:

fn main() {
    let meow = 'hello';
} 

Error (playpen):

error: character literal may only contain one codepoint: 'hello'
 --> <anon>:2:16
  |
2 |     let meow = 'hello';
  |                ^^^^^^^

error: aborting due to previous error

@tbu-
Copy link
Contributor

tbu- commented Dec 19, 2016

U+0066  f       [Ll] LATIN SMALL LETTER F
U+006E  n       [Ll] LATIN SMALL LETTER N
U+0020          [Zs] SPACE
U+006D  m       [Ll] LATIN SMALL LETTER M
U+0061  a       [Ll] LATIN SMALL LETTER A
U+0069  i       [Ll] LATIN SMALL LETTER I
U+006E  n       [Ll] LATIN SMALL LETTER N
U+0028  (       [Ps] LEFT PARENTHESIS
U+0029  )       [Pe] RIGHT PARENTHESIS
U+0020          [Zs] SPACE
U+007B  {       [Ps] LEFT CURLY BRACKET
U+000A  \n      [Cc] <unknown>
U+0020          [Zs] SPACE
U+0020          [Zs] SPACE
U+0020          [Zs] SPACE
U+0020          [Zs] SPACE
U+006C  l       [Ll] LATIN SMALL LETTER L
U+0065  e       [Ll] LATIN SMALL LETTER E
U+0074  t       [Ll] LATIN SMALL LETTER T
U+0020          [Zs] SPACE
U+0068  h       [Ll] LATIN SMALL LETTER H
U+0065  e       [Ll] LATIN SMALL LETTER E
U+0061  a       [Ll] LATIN SMALL LETTER A
U+0072  r       [Ll] LATIN SMALL LETTER R
U+0074  t       [Ll] LATIN SMALL LETTER T
U+0020          [Zs] SPACE
U+003D  =       [Sm] EQUALS SIGN
U+0020          [Zs] SPACE
U+0027  '       [Po] APOSTROPHE
U+2764  ❤       [So] HEAVY BLACK HEART
U+FE0F  ️       [Mn] VARIATION SELECTOR-16
U+0027  '       [Po] APOSTROPHE
U+003B  ;       [Po] SEMICOLON
U+000A  \n      [Cc] <unknown>
U+007D  }       [Pe] RIGHT CURLY BRACKET
U+0020          [Zs] SPACE
U+000A  \n      [Cc] <unknown>

It looks like rustc can't deal with the combining character VARIATION SELECTOR-16.

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@estebank
Copy link
Contributor

No longer valid in current beta.

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants