Skip to content

Incorrect error message for byte literal with single quotes #64732

Closed
@jcdyer

Description

@jcdyer

When creating a byte literal with single quotes, like b'hello\0', The error message says:

error: character literal may only contain one codepoint
   --> src/wire_protocol/operations.rs:101:37
    |
101 |         assert_eq!(Bson::Binary(4, b'12345').byte_length().unwrap(), 10);
    |                                     ^^^^^^^
help: if you meant to write a `str` literal, use double quotes
    |
101 |         assert_eq!(Bson::Binary(4, b"12345").byte_length().unwrap(), 10);
    |                                     ^^^^^^^

But following the directions would not give us a str literal, it would give a [u8] literal.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions