diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-01 16:41:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-01 16:41:03 +0100 |
| commit | 2fd3007cbcfd54edd82f2e4f4058afdf07ea8e60 (patch) | |
| tree | 708d75cf765925fdaff37a7e858137c68b2547c3 /compiler/rustc_mir_build/src/errors.rs | |
| parent | e08cd3cf05e5bfa3323cc21ea8f81f4a15a2f969 (diff) | |
| parent | 442b9a93872096a6e51e23f36f14f2dacf5520ce (diff) | |
| download | rust-2fd3007cbcfd54edd82f2e4f4058afdf07ea8e60.tar.gz rust-2fd3007cbcfd54edd82f2e4f4058afdf07ea8e60.zip | |
Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obk
Implement MIR lowering for unsafe binders This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are `Copy`. Later on, I'll introduce a new trait that relaxes this requirement to being "is `Copy` or `ManuallyDrop<T>`" which more closely models how we treat union fields. Namely, wrapping unsafe binders is now `Rvalue::WrapUnsafeBinder`, which acts much like an `Rvalue::Aggregate`. Unwrapping unsafe binders are implemented as a MIR projection `ProjectionElem::UnwrapUnsafeBinder`, which acts much like `ProjectionElem::Field`. Tracking: - https://github.com/rust-lang/rust/issues/130516
Diffstat (limited to 'compiler/rustc_mir_build/src/errors.rs')
| -rw-r--r-- | compiler/rustc_mir_build/src/errors.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 1f87bf0dbbb..e6aa191238a 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -161,6 +161,18 @@ pub(crate) struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe } #[derive(LintDiagnostic)] +#[diag( + mir_build_unsafe_binder_cast_requires_unsafe, + code = E0133, +)] +pub(crate) struct UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe { + #[label] + pub(crate) span: Span, + #[subdiagnostic] + pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedLintNote>, +} + +#[derive(LintDiagnostic)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe, code = E0133)] #[help] pub(crate) struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { @@ -494,6 +506,32 @@ pub(crate) struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, } +#[derive(Diagnostic)] +#[diag( + mir_build_unsafe_binder_cast_requires_unsafe, + code = E0133, +)] +pub(crate) struct UnsafeBinderCastRequiresUnsafe { + #[primary_span] + #[label] + pub(crate) span: Span, + #[subdiagnostic] + pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, +} + +#[derive(Diagnostic)] +#[diag( + mir_build_unsafe_binder_cast_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, + code = E0133, +)] +pub(crate) struct UnsafeBinderCastRequiresUnsafeUnsafeOpInUnsafeFnAllowed { + #[primary_span] + #[label] + pub(crate) span: Span, + #[subdiagnostic] + pub(crate) unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>, +} + #[derive(Subdiagnostic)] #[label(mir_build_unsafe_not_inherited)] pub(crate) struct UnsafeNotInheritedNote { |
