1
Fork 0

Rollup merge of #121179 - RalfJung:zst-mutable-refs, r=oli-obk

allow mutable references in const values when they point to no memory

Fixes https://github.com/rust-lang/rust/issues/120450

The second commit is just some drive-by test suite cleanup.

r? `@oli-obk`
This commit is contained in:
Guillaume Gomez 2024-02-16 17:08:13 +01:00 committed by GitHub
commit 0c92146034
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 209 additions and 387 deletions

View file

@ -12,6 +12,7 @@ use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace;
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
use rustc_target::abi::{call, Align, Size, VariantIdx, WrappingRange};
use rustc_type_ir::Mutability;
use std::borrow::Cow;
use std::{any::Any, backtrace::Backtrace, fmt};
@ -367,7 +368,7 @@ pub enum UndefinedBehaviorInfo<'tcx> {
#[derive(Debug, Clone, Copy)]
pub enum PointerKind {
Ref,
Ref(Mutability),
Box,
}
@ -375,7 +376,7 @@ impl IntoDiagnosticArg for PointerKind {
fn into_diagnostic_arg(self) -> DiagnosticArgValue {
DiagnosticArgValue::Str(
match self {
Self::Ref => "ref",
Self::Ref(_) => "ref",
Self::Box => "box",
}
.into(),
@ -408,7 +409,7 @@ impl From<PointerKind> for ExpectedKind {
fn from(x: PointerKind) -> ExpectedKind {
match x {
PointerKind::Box => ExpectedKind::Box,
PointerKind::Ref => ExpectedKind::Reference,
PointerKind::Ref(_) => ExpectedKind::Reference,
}
}
}
@ -419,7 +420,7 @@ pub enum ValidationErrorKind<'tcx> {
PartialPointer,
PtrToUninhabited { ptr_kind: PointerKind, ty: Ty<'tcx> },
PtrToStatic { ptr_kind: PointerKind },
MutableRefInConst,
MutableRefInConstOrStatic,
ConstRefToMutable,
ConstRefToExtern,
MutableRefToImmutable,