X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=compiler%2Frustc_lint_defs%2Fsrc%2Fbuiltin.rs;h=9d8ad9d9ed9f6f5c7d2fa66b7e0d656ba2393581;hb=a70d03b62454f57672e14b48715ae10c01e5fd34;hp=d731c10f46e28efec1f5659cfecfc75b43b339a5;hpb=3c155dc7b6ac9368fbe6f3127b42e91b181f2708;p=rust.git diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index d731c10f46e..9d8ad9d9ed9 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1187,51 +1187,6 @@ "lints that have been renamed or removed" } -declare_lint! { - /// The `unaligned_references` lint detects unaligned references to fields - /// of [packed] structs. - /// - /// [packed]: https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers - /// - /// ### Example - /// - /// ```rust,compile_fail - /// #[repr(packed)] - /// pub struct Foo { - /// field1: u64, - /// field2: u8, - /// } - /// - /// fn main() { - /// unsafe { - /// let foo = Foo { field1: 0, field2: 0 }; - /// let _ = &foo.field1; - /// println!("{}", foo.field1); // An implicit `&` is added here, triggering the lint. - /// } - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Creating a reference to an insufficiently aligned packed field is [undefined behavior] and - /// should be disallowed. Using an `unsafe` block does not change anything about this. Instead, - /// the code should do a copy of the data in the packed field or use raw pointers and unaligned - /// accesses. See [issue #82523] for more information. - /// - /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html - /// [issue #82523]: https://github.com/rust-lang/rust/issues/82523 - pub UNALIGNED_REFERENCES, - Deny, - "detects unaligned references to fields of packed structs", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #82523 ", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, - }; - report_in_external_macro -} - declare_lint! { /// The `const_item_mutation` lint detects attempts to mutate a `const` /// item. @@ -3308,7 +3263,6 @@ PUB_USE_OF_PRIVATE_EXTERN_CRATE, INVALID_TYPE_PARAM_DEFAULT, RENAMED_AND_REMOVED_LINTS, - UNALIGNED_REFERENCES, CONST_ITEM_MUTATION, PATTERNS_IN_FNS_WITHOUT_BODY, MISSING_FRAGMENT_SPECIFIER, @@ -4119,7 +4073,8 @@ declare_lint! { /// The `byte_slice_in_packed_struct_with_derive` lint detects cases where a byte slice field - /// (`[u8]`) is used in a `packed` struct that derives one or more built-in traits. + /// (`[u8]`) or string slice field (`str`) is used in a `packed` struct that derives one or + /// more built-in traits. /// /// ### Example /// @@ -4137,11 +4092,11 @@ /// ### Explanation /// /// This was previously accepted but is being phased out, because fields in packed structs are - /// now required to implement `Copy` for `derive` to work. Byte slices are a temporary - /// exception because certain crates depended on them. + /// now required to implement `Copy` for `derive` to work. Byte slices and string slices are a + /// temporary exception because certain crates depended on them. pub BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE, Warn, - "`[u8]` slice used in a packed struct with `derive`", + "`[u8]` or `str` used in a packed struct with `derive`", @future_incompatible = FutureIncompatibleInfo { reference: "issue #107457 ", reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,