diff options
| author | Michael Goulet <michael@errs.io> | 2025-05-25 15:05:22 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-05-25 15:57:48 +0000 |
| commit | 5370c5753f3f769d27832f81ceefd4141ba1ee0c (patch) | |
| tree | a274043429f8a7f039a6d1c512071237471cfbfb /compiler/rustc_lint_defs/src | |
| parent | a8ae2af9670635a9138429ccba1ffb76787afbb1 (diff) | |
| download | rust-5370c5753f3f769d27832f81ceefd4141ba1ee0c.tar.gz rust-5370c5753f3f769d27832f81ceefd4141ba1ee0c.zip | |
Make PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS into a HIR lint
Diffstat (limited to 'compiler/rustc_lint_defs/src')
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index b8d242bad86..2e1aaeedba1 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -79,7 +79,6 @@ declare_lint_pass! { PRIVATE_BOUNDS, PRIVATE_INTERFACES, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE, REDUNDANT_IMPORTS, REDUNDANT_LIFETIMES, @@ -4852,40 +4851,6 @@ declare_lint! { } declare_lint! { - /// The `ptr_to_integer_transmute_in_consts` lint detects pointer to integer - /// transmute in const functions and associated constants. - /// - /// ### Example - /// - /// ```rust - /// const fn foo(ptr: *const u8) -> usize { - /// unsafe { - /// std::mem::transmute::<*const u8, usize>(ptr) - /// } - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Transmuting pointers to integers in a `const` context is undefined behavior. - /// Any attempt to use the resulting integer will abort const-evaluation. - /// - /// But sometimes the compiler might not emit an error for pointer to integer transmutes - /// inside const functions and associated consts because they are evaluated only when referenced. - /// Therefore, this lint serves as an extra layer of defense to prevent any undefined behavior - /// from compiling without any warnings or errors. - /// - /// See [std::mem::transmute] in the reference for more details. - /// - /// [std::mem::transmute]: https://doc.rust-lang.org/std/mem/fn.transmute.html - pub PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS, - Warn, - "detects pointer to integer transmutes in const functions and associated constants", -} - -declare_lint! { /// The `unnecessary_transmutes` lint detects transmutations that have safer alternatives. /// /// ### Example |
