Auto merge of #132915 - veluca93:unsafe-fields, r=jswrenn

Implement the unsafe-fields RFC.

RFC: rust-lang/rfcs#3458

Tracking:

- https://github.com/rust-lang/rust/issues/132922

r? jswrenn
This commit is contained in:
bors
2024-11-23 07:47:52 +00:00
38 changed files with 793 additions and 85 deletions

View File

@@ -125,6 +125,16 @@ mir_build_initializing_type_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed
.note = initializing a layout restricted type's field with a value outside the valid range is undefined behavior
.label = initializing type with `rustc_layout_scalar_valid_range` attr
mir_build_initializing_type_with_unsafe_field_requires_unsafe =
initializing type with an unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = initialization of struct with unsafe field
mir_build_initializing_type_with_unsafe_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
initializing type with an unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = initialization of struct with unsafe field
mir_build_inline_assembly_requires_unsafe =
use of inline assembly is unsafe and requires unsafe block
.note = inline assembly is entirely unchecked and can cause undefined behavior
@@ -347,6 +357,16 @@ mir_build_unreachable_pattern = unreachable pattern
.unreachable_pattern_let_binding = there is a binding of the same name; if you meant to pattern match against the value of that binding, that is a feature of constants that is not available for `let` bindings
.suggestion = remove the match arm
mir_build_unsafe_field_requires_unsafe =
use of unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = use of unsafe field
mir_build_unsafe_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
use of unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = use of unsafe field
mir_build_unsafe_fn_safe_body = an unsafe function restricts its caller, but its body is safe by default
mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items
@@ -395,6 +415,11 @@ mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe =
.note = initializing a layout restricted type's field with a value outside the valid range is undefined behavior
.label = initializing type with `rustc_layout_scalar_valid_range` attr
mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_unsafe_field_requires_unsafe =
initializing type with an unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = initialization of struct with unsafe field
mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe =
use of inline assembly is unsafe and requires unsafe block
.note = inline assembly is entirely unchecked and can cause undefined behavior
@@ -415,6 +440,11 @@ mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe =
.note = the field may not be properly initialized: using uninitialized data will cause undefined behavior
.label = access to union field
mir_build_unsafe_op_in_unsafe_fn_unsafe_field_requires_unsafe =
use of unsafe field is unsafe and requires unsafe block
.note = unsafe fields may carry library invariants
.label = use of unsafe field
mir_build_unsized_pattern = cannot use unsized non-slice type `{$non_sm_ty}` in constant patterns
mir_build_unused_unsafe = unnecessary `unsafe` block