Skip to content

Commit f8d3805

Browse files
committed
miri validation: clarify valid values of 'char'
1 parent 4512721 commit f8d3805

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/librustc_mir/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
485485
try_validation!(
486486
value.to_char(),
487487
self.path,
488-
err_ub!(InvalidChar(..)) => { "{}", value } expected { "a valid unicode codepoint" },
488+
err_ub!(InvalidChar(..)) => { "{}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" },
489489
);
490490
Ok(true)
491491
}

src/test/ui/consts/const-eval/ub-enum.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ error[E0080]: it is undefined behavior to use this value
8282
--> $DIR/ub-enum.rs:87:1
8383
|
8484
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
85-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0xffffffff at .<enum-variant(Some)>.0.1, but expected a valid unicode codepoint
85+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`)
8686
|
8787
= 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.
8888

0 commit comments

Comments
 (0)