Skip to content

Hint on unknown escape of Unicode quotation marks in string literal #137067

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

LFS6502
Copy link
Contributor

@LFS6502 LFS6502 commented Feb 15, 2025

Fixes #128858
Continuation of #128906

Fixes rust-lang#128858

I opted not to produce a suggestion, since it's not obvious what the user meant to do.
@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 15, 2025
@rust-log-analyzer

This comment has been minimized.

@LFS6502
Copy link
Contributor Author

LFS6502 commented Feb 15, 2025

closes #128906

@LFS6502 LFS6502 marked this pull request as ready for review February 17, 2025 20:47
@LFS6502
Copy link
Contributor Author

LFS6502 commented Feb 17, 2025

@jieyouxu @compiler-errors @Dylan-DPC If you've got some spare time, I'd love some input from you too.

I will squash at the end.

@LFS6502
Copy link
Contributor Author

LFS6502 commented Feb 17, 2025

error: unknown character escape: `\u{201c}`
 --> src/main.rs:2:26
  |
2 |     dbg!("since when is \“THIS\” not allowed in a string literal");
  |                          ^ unknown character escape
  |
  = help: \u{201c} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
  |
2 -     dbg!("since when is \“THIS\” not allowed in a string literal");
2 +     dbg!("since when is \u{201c}THIS\” not allowed in a string literal");
  |

error: unknown character escape: `\u{201d}`
 --> src/main.rs:2:32
  |
2 |     dbg!("since when is \“THIS\” not allowed in a string literal");
  |                                ^ unknown character escape
  |
  = help: \u{201d} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
  |
2 -     dbg!("since when is \“THIS\” not allowed in a string literal");
2 +     dbg!("since when is \“THIS\u{201d} not allowed in a string literal");
  |

error: could not compile `diag` (bin "diag") due to 2 previous errors

In image form:

image

@LFS6502 LFS6502 added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Mar 1, 2025
@apiraino
Copy link
Contributor

Assigning review to Michael because of this comment in the previous version of a patch.

r? @compiler-errors

@compiler-errors
Copy link
Member

kinda busy so re-rolling

r? compiler

@rustbot rustbot assigned Noratrieb and unassigned compiler-errors Mar 21, 2025
Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this looks good overall, some small suggestions, then you can squash it and we can merge it.

I'm not entirely convinced the suggestion is worth it, since it seems really unlikely someone would write this on purpose intending anything other than what the issue author intended. But it's fine to have if you think it's good

err_span,
"if you meant to use a unicode quote; \
consider using its escaped form for clarity",
// lit.replace(c, &ec[1..]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was left over from development

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be addressed.

@Noratrieb Noratrieb added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2025
Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com>
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#19 exporting to docker image format
#19 sending tarball 19.5s done
#19 DONE 25.0s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Number of decisions:   4447
  longest path:          1159 (code:    152)
  longest backtrack:       66 (code:    428)
Shared 86733 out of 152951 states by creating 14756 new states, saving 71977
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc: In function ‘rtx_def* extract_bit_field_1(rtx, poly_uint64, poly_uint64, int, rtx, machine_mode, machine_mode, bool, bool, rtx_def**)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1864:45: warning: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized]
 1864 |       rtx sub = extract_bit_field_as_subreg (mode1, op0, imode,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 1865 |                                              bitsize, bitnum);
      |                                              ~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1824:19: note: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here
 1824 |   scalar_int_mode imode;
      |                   ^~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc: In member function ‘void range_def_chain::dump(FILE*, basic_block, const char*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc:319:19: warning: format not a string literal and no format arguments [-Wformat-security]
  319 |           fprintf (f, prefix);
      |           ~~~~~~~~^~~~~~~~~~~
---
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:7930:9: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 7930 |   write (fd, "\n\n", 2);
      |   ~~~~~~^~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc: In member function ‘void driver::final_actions() const’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:9307:13: warning: ignoring return value of ‘int truncate(const char*, __off_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 9307 |     truncate(totruncate_file, 0);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gengtype-lex.l: In function ‘int yylex(const char**)’:
gengtype-lex.cc:357:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
  357 | #define YY_DO_BEFORE_ACTION \
      |  ~~~~~~~~~~~~~^~~~~~~
---
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc: In function ‘void lto_resolution_read(splay_tree, FILE*, lto_file*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2091:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2091 |   fscanf (resolution, " ");   /* Read white space.  */
      |   ~~~~~~~^~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2093:9: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2093 |   fread (obj_name, sizeof (char), name_len, resolution);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2113:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2113 |   fscanf (resolution, "%u", &num_symbols);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/jit/jit-recording.cc:32:
---
Applying io_quotes_use            to linux/blkzoned.h
Applying io_quotes_use            to linux/ipmi.h
Applying io_quotes_use            to linux/psp-dbc.h
Applying io_quotes_use            to linux/bt-bmc.h
Applying io_quotes_use            to linux/tps6594_pfsm.h
Applying io_quotes_use            to linux/cxl_mem.h
Applying io_quotes_use            to linux/wmi.h
Applying io_quotes_use            to linux/auto_fs.h
Applying io_quotes_use            to linux/mmtimer.h
Applying io_quotes_use            to linux/f2fs.h
Applying io_quotes_use            to linux/vhost.h
---
Applying machine_name             to x86_64-linux-gnu/bits/unistd_ext.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/mtrr.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/amd_hsmp.h
Applying machine_name             to openssl/e_os2.h
Applying io_quotes_use            to drm/xe_drm.h
Applying io_quotes_use            to drm/radeon_drm.h
Applying io_quotes_use            to drm/panfrost_drm.h
Applying io_quotes_use            to drm/etnaviv_drm.h
Applying io_quotes_use            to drm/lima_drm.h
Applying io_quotes_use            to drm/qaic_accel.h
Applying io_quotes_use            to drm/vc4_drm.h
Applying io_quotes_use            to drm/i915_drm.h
Applying io_quotes_use            to drm/omap_drm.h
Applying io_quotes_use            to drm/pvr_drm.h
Applying io_quotes_use            to drm/amdgpu_drm.h
Applying io_quotes_use            to drm/vgem_drm.h
Applying io_quotes_use            to drm/msm_drm.h
Applying io_quotes_use            to drm/v3d_drm.h
Applying io_quotes_use            to drm/exynos_drm.h
Applying io_quotes_use            to drm/nouveau_drm.h
Applying io_quotes_use            to drm/drm.h
Applying io_quotes_use            to drm/habanalabs_accel.h
Applying io_quotes_use            to drm/tegra_drm.h
Applying io_quotes_use            to rdma/rdma_user_ioctl.h
cc1: note: self-tests are not enabled in this build
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc: In function ‘void server(bool, int, module_resolver*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc:620:10: warning: ignoring return value of ‘int pipe(int*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
---
---- [ui] tests/ui/unicode-quote.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unicode-quote/unicode-quote.stderr"
diff of stderr:

4 LL |     dbg!("\″"); //U+2033
5    |            ^ unknown character escape
6    |
-    = help: \u{2033} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{2033} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
8 help: if you meant to use a unicode quote; consider using its escaped form for clarity
9    |
10 LL -     dbg!("\″"); //U+2033

17 LL |     dbg!("\ʺ"); //U+02BA
18    |            ^ unknown character escape
19    |
-    = help: \u{2ba} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{2ba} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
21 help: if you meant to use a unicode quote; consider using its escaped form for clarity
22    |
23 LL -     dbg!("\ʺ"); //U+02BA

30 LL |     dbg!("\˝"); //U+02DD
31    |            ^ unknown character escape
32    |
-    = help: \u{2dd} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{2dd} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
34 help: if you meant to use a unicode quote; consider using its escaped form for clarity
35    |
36 LL -     dbg!("\˝"); //U+02DD

41   --> $DIR/unicode-quote.rs:10:12
42    |
43 LL |     dbg!("\̋"); //U+030B
-    |            ^ unknown character escape
+    |            ^unknown character escape
45    |
-    = help: \u{30b} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{30b} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
47 help: if you meant to use a unicode quote; consider using its escaped form for clarity
48    |
49 LL -     dbg!("\̋"); //U+030B

54   --> $DIR/unicode-quote.rs:12:12
55    |
56 LL |     dbg!("\̎"); //U+030E
-    |            ^ unknown character escape
+    |            ^unknown character escape
58    |
-    = help: \u{30e} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{30e} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
60 help: if you meant to use a unicode quote; consider using its escaped form for clarity
61    |
62 LL -     dbg!("\̎"); //U+030E

69 LL |     dbg!("\״"); //U+05F4
70    |            ^ unknown character escape
71    |
-    = help: \u{5f4} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{5f4} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
73 help: if you meant to use a unicode quote; consider using its escaped form for clarity
74    |
75 LL -     dbg!("\״"); //U+05F4

82 LL |     dbg!("\“"); //U+201C
83    |            ^ unknown character escape
84    |
-    = help: \u{201c} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{201c} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
86 help: if you meant to use a unicode quote; consider using its escaped form for clarity
87    |
88 LL -     dbg!("\“"); //U+201C

95 LL |     dbg!("\”"); //U+201D
96    |            ^ unknown character escape
97    |
-    = help: \u{201d} is not an ascii quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
+    = help: \u{201d} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
99 help: if you meant to use a unicode quote; consider using its escaped form for clarity
100    |
101 LL -     dbg!("\”"); //U+201D


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args unicode-quote.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/unicode-quote.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unicode-quote" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: unknown character escape: `\u{2033}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:4:12
   |
LL |     dbg!("\″"); //U+2033
   |            ^ unknown character escape
   |
   = help: \u{2033} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\″"); //U+2033
LL +     dbg!("\u{2033}"); //U+2033
   |

error: unknown character escape: `\u{2ba}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:6:12
   |
LL |     dbg!("\ʺ"); //U+02BA
   |            ^ unknown character escape
   |
   = help: \u{2ba} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\ʺ"); //U+02BA
LL +     dbg!("\u{2ba}"); //U+02BA
   |

error: unknown character escape: `\u{2dd}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:8:12
   |
LL |     dbg!("\˝"); //U+02DD
   |            ^ unknown character escape
   |
   = help: \u{2dd} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\˝"); //U+02DD
LL +     dbg!("\u{2dd}"); //U+02DD
   |

error: unknown character escape: `\u{30b}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:10:12
   |
LL |     dbg!("\̋"); //U+030B
   |            ^unknown character escape
   |
   = help: \u{30b} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\̋"); //U+030B
LL +     dbg!("\u{30b}"); //U+030B
   |

error: unknown character escape: `\u{30e}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:12:12
   |
LL |     dbg!("\̎"); //U+030E
   |            ^unknown character escape
   |
   = help: \u{30e} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\̎"); //U+030E
LL +     dbg!("\u{30e}"); //U+030E
   |

error: unknown character escape: `\u{5f4}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:14:12
   |
LL |     dbg!("\״"); //U+05F4
   |            ^ unknown character escape
   |
   = help: \u{5f4} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\״"); //U+05F4
LL +     dbg!("\u{5f4}"); //U+05F4
   |

error: unknown character escape: `\u{201c}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:16:12
   |
LL |     dbg!("\“"); //U+201C
   |            ^ unknown character escape
   |
   = help: \u{201c} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\“"); //U+201C
LL +     dbg!("\u{201c}"); //U+201C
   |

error: unknown character escape: `\u{201d}`
##[error]  --> /checkout/tests/ui/unicode-quote.rs:18:12
   |
LL |     dbg!("\”"); //U+201D
   |            ^ unknown character escape
   |
   = help: \u{201d} is not an ASCII quote, but may look like one in some fonts; consider writing it in its escaped form for clarity.
help: if you meant to use a unicode quote; consider using its escaped form for clarity
   |
LL -     dbg!("\”"); //U+201D
LL +     dbg!("\u{201d}"); //U+201D
   |

error: aborting due to 8 previous errors
------------------------------------------

err_span,
"if you meant to use a unicode quote; \
consider using its escaped form for clarity",
// lit.replace(c, &ec[1..]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be addressed.


diag.help(format!(
"{ec} is not an ASCII quote, but may look like one in some fonts; \
consider writing it in its escaped form for clarity."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
consider writing it in its escaped form for clarity."
consider writing it in its escaped form for clarity"

Comment on lines +162 to +174
diag.span_suggestion(
err_span,
"if you meant to use a unicode quote; \
consider using its escaped form for clarity",
// lit.replace(c, &ec[1..]),
&ec,
Applicability::MaybeIncorrect,
);

diag.help(format!(
"{ec} is not an ASCII quote, but may look like one in some fonts; \
consider writing it in its escaped form for clarity."
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of emitting both a help and a suggestion, use the message from the help in a span_suggestion_verbose. The text is effectively saying the same thing twice, the help message can have the explanation, that's preferable.

Comment on lines +315 to +319
// list of homoglyphs generated using the following wikidata query:
// SELECT ?u WHERE {
// wd:Q87495536 wdt:P2444+ ?c.
// ?c wdt:P4213 ?u.
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, I recall that the unicode tables have a "similarity" field that I've looked at in the past.

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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hint on unknown escape of Unicode quotation marks in string literal
9 participants