rust-lang / rust-lang/fls

8-bit \x escapes

Open
#604 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
reStructuredText
Stars
497
Forks
41
Avg merge
3h 52m
Merged PRs (30d)
4

Description

Problem 1

The definition of ByteEscape in §2.4.1 (fls_2ifjqwnw03ms) includes \x OctalDigit HexadecimalDigit.

ByteEscape is then used in the definition of byte literals (also in §2.4.1) and simple byte string literals (in §2.4.2.1, fls_msbaxfc09vkk).

But byte literals and simple byte string literals can also include 8-bit \x escapes (that is, escapes in which the first character after the \x is a HexadecimalDigit which isn't an OctalDigit).

So the FLS is mistakenly saying that, for example, b'\xff' isn't accepted as a byte literal and b"\xff" isn't accepted as a simple byte string literal.

Similarly the definition of SimpleCStringLiteral is based on AsciiEscape, which again includes \x OctalDigit HexadecimalDigit, but 8-bit \x escapes are allowed in simple c string literals.

Problem 2

§2.4.2.1:2 (fls_moe3zfx39ox2) reads:

A simple byte string literal is a byte string literal that consists of multiple AsciiCharacters.

while AsciiCharacter is defined in §2.1:16 (fls_PIDKEm8GiLNL) as follows:

An AsciiCharacter is any Unicode character in the range 0x00 - 0x7F, both inclusive.

But (because of the 8-bit \x escapes described above) a simple byte string literal can contain arbitrary bytes.

So I think §2.4.2.1:2 should say that a simple byte string literal is made up of bytes (compare §2.4.1:2 (fls_q0qwr83frszx) "A byte literal is a literal that denotes a fixed byte value.")

Also, where §2.4.2.1:3 (fls_vffxb6arj9jf) says

The type of a simple byte string literal of size N is &'static [u8; N].

I think it would be good to be more explicit than "size".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the definitions and clauses identified in §2.4.1 and §2.4.2.1, including the listed FLS anchors for ByteEscape, AsciiEscape, SimpleCStringLiteral, and AsciiCharacter. Check the literal rules against the reported 8-bit escapes, then revise the escape grammar and the simple byte string description and size wording. Done means the specification consistently permits and describes these literals.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.