support non-null pointer niches in CTFE

This commit is contained in:
Moulins 2023-06-25 19:32:40 +02:00
parent 3c05276866
commit 76c49aead6
8 changed files with 100 additions and 65 deletions

View file

@ -333,7 +333,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
// Inequality with integers other than null can never be known for sure.
(Scalar::Int(int), ptr @ Scalar::Ptr(..))
| (ptr @ Scalar::Ptr(..), Scalar::Int(int))
if int.is_null() && !self.scalar_may_be_null(ptr)? =>
if int.is_null() && !self.ptr_scalar_range(ptr)?.contains(&0) =>
{
0
}