Skip to content

Raw string literal escape depth is technically limited #50111

Closed
@varkor

Description

@varkor

This is not entirely serious, because I can't imagine this plausibly happening in real-world code (generated or otherwise), but in Nightly (Stable has a higher threshold):

fn main() {
    r#[... repeat 2^16 times ...]#""#[... repeat 2^16 times ...]#;
}

fails to parse with:

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `#`
 --> src/main.rs:3:65544
  |
3 |     r######...
  | 

This limit is not mentioned in the reference.

I think we should document the maximum number of #s. We could also reduce the number permitted: 255 should be enough for anyone (#49993 (comment)).

Alternatively, we could ignore it as being a non-problem. Feel free just to close the issue 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions