diff options
| author | Nick Lamb <git@tree.tlrmx.org> | 2023-02-05 23:37:47 +0000 |
|---|---|---|
| committer | Nick Lamb <git@tree.tlrmx.org> | 2023-02-06 21:48:10 +0000 |
| commit | 747cdc0dfd784c280d50ad50661a1f00a2677842 (patch) | |
| tree | 8559d22e38ab030ef1bc5f9498b4be8cfdddfec1 /compiler | |
| parent | 319b88c463fe6f51bb6badbbd3bb97252a60f3a5 (diff) | |
| download | rust-747cdc0dfd784c280d50ad50661a1f00a2677842.tar.gz rust-747cdc0dfd784c280d50ad50661a1f00a2677842.zip | |
Fix problem noticed in PR106859 with char -> u8 suggestion
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index b5c2d14e8d1..86f3174b7b2 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1922,7 +1922,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { (ty::Uint(ty::UintTy::U8), ty::Char) => { if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) && let Some(code) = code.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')) - && code.chars().next().map_or(false, |c| c.is_ascii()) + && !code.starts_with("\\u") // forbid all Unicode escapes + && code.chars().next().map_or(false, |c| c.is_ascii()) // forbids literal Unicode characters beyond ASCII { err.span_suggestion( span, |
