]> git.lizzy.rs Git - rust.git/commitdiff
miri validation: clarify valid values of 'char'
authorRalf Jung <post@ralfj.de>
Sat, 30 May 2020 07:33:05 +0000 (09:33 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 30 May 2020 07:33:05 +0000 (09:33 +0200)
src/librustc_mir/interpret/validity.rs
src/test/ui/consts/const-eval/ub-enum.stderr

index c83555d65faf06a525e83b9219c789a18959021b..f2ce46e9740f9b157c14df21087739347fe12d8e 100644 (file)
@@ -485,7 +485,7 @@ fn try_visit_primitive(
                 try_validation!(
                     value.to_char(),
                     self.path,
-                    err_ub!(InvalidChar(..)) => { "{}", value } expected { "a valid unicode codepoint" },
+                    err_ub!(InvalidChar(..)) => { "{}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" },
                 );
                 Ok(true)
             }
index d8dafac3e70a116414e7de525525654356e5ce15..e49fd3e0b970bd4ed7d2b5a92a57c3b0ceb44bf2 100644 (file)
@@ -82,7 +82,7 @@ error[E0080]: it is undefined behavior to use this value
   --> $DIR/ub-enum.rs:87:1
    |
 LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0xffffffff at .<enum-variant(Some)>.0.1, but expected a valid unicode codepoint
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0xffffffff at .<enum-variant(Some)>.0.1, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.