about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-01-15 01:01:36 +0100
committerGitHub <noreply@github.com>2023-01-15 01:01:36 +0100
commit980bf1979e28b4acc4e189b4266afd5f58b68d6d (patch)
tree9f5ba0bbb63b7ca679e098636a1e0ffff6e4b82b /tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff
parentd7fcd01f6778a01a133a4947f6a693593e89d8b3 (diff)
parent130d02b62e65c5f2a434eaec63c4249e9d508487 (diff)
downloadrust-980bf1979e28b4acc4e189b4266afd5f58b68d6d.tar.gz
rust-980bf1979e28b4acc4e189b4266afd5f58b68d6d.zip
Rollup merge of #106859 - tialaramex:master, r=Nilstrieb
Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal

Today Rust just points out that we have a char and we need a u8, but if I wrote 'A' then I could fix this by just writing b'A' instead. This code should detect the case where we're about to report a type mismatch of this kind, and the programmer wrote a char literal, and the char they wrote is ASCII, so therefore just prefixing b to make a byte literal will do what they meant.

I have definitely written this mistake more than once, it's not difficult to figure out what to do, but the compiler might as well tell us anyway.

I provided a test with two simple examples where the suggestion is appropriate, and one where it is not because the char literal is not ASCII, showing that the suggestion is only triggered in the former cases.

I have contributed only a small typo doc fix before, so this is my first substantive rustc change.
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff')
0 files changed, 0 insertions, 0 deletions