Skip to content
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

Replace ASCII control chars with Unicode Control Pictures #127528

Merged
merged 4 commits into from
Jul 25, 2024

Commits on Jul 18, 2024

  1. Replace ASCII control chars with Unicode Control Pictures

    ```
    error: bare CR not allowed in doc-comment
      --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32
       |
    LL | /// doc comment with bare CR: '␍'
       |                                ^
    ```
    estebank committed Jul 18, 2024
    Configuration menu
    Copy the full SHA
    89f273f View commit details
    Browse the repository at this point in the history
  2. Be more accurate about calculating display_col from a BytePos

    No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter.
    
    This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2):
    
    ```
    error: this file contains an unclosed delimiter
      --> $DIR/issue-68629.rs:5:17
       |
    LL | ␜␟ts␀![{i
       |       -- unclosed delimiter
       |       |
       |       unclosed delimiter
    LL | ␀␀  fn rݻoa>rݻm
       |                ^
    ```
    estebank committed Jul 18, 2024
    Configuration menu
    Copy the full SHA
    2d7795d View commit details
    Browse the repository at this point in the history
  3. Make unicode text flow control chars visible as �

    We already point these out quite aggressively, telling people not to use them, but would normally be rendered as nothing. Having them visible will make it easier for people to actually deal with them.
    
    ```
    error: unicode codepoint changing visible direction of text present in literal
      --> $DIR/unicode-control-codepoints.rs:26:22
       |
    LL |     println!("{:?}", '�');
       |                      ^-^
       |                      ||
       |                      |'\u{202e}'
       |                      this literal contains an invisible unicode text flow control codepoint
       |
       = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
       = help: if their presence wasn't intentional, you can remove them
    help: if you want to keep them but make them visible in your source code, you can escape them
       |
    LL |     println!("{:?}", '\u{202e}');
       |                       ~~~~~~~~
    ```
    
    vs the previous
    
    ```
    error: unicode codepoint changing visible direction of text present in literal
      --> $DIR/unicode-control-codepoints.rs:26:22
       |
    LL |     println!("{:?}", '');
       |                      ^-
       |                      ||
       |                      |'\u{202e}'
       |                      this literal contains an invisible unicode text flow control codepoint
       |
       = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
       = help: if their presence wasn't intentional, you can remove them
    help: if you want to keep them but make them visible in your source code, you can escape them
       |
    LL |     println!("{:?}", '\u{202e}');
       |                       ~~~~~~~~
    ```
    estebank committed Jul 18, 2024
    Configuration menu
    Copy the full SHA
    9dffe95 View commit details
    Browse the repository at this point in the history

Commits on Jul 24, 2024

  1. Fix ddltool-failed test

    estebank committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    9bd7680 View commit details
    Browse the repository at this point in the history