Skip to main content

Module transmute

Module transmute 

Source

Re-exportsยง

use rustc_ast::LitKind; ๐Ÿ”’
use rustc_errors::Applicability; ๐Ÿ”’
use rustc_hir as hir; ๐Ÿ”’
use rustc_hir::def::DefKind; ๐Ÿ”’
use rustc_hir::def::Res; ๐Ÿ”’
use rustc_hir::def_id::LocalDefId; ๐Ÿ”’
use rustc_lint_defs::declare_lint; ๐Ÿ”’
use rustc_lint_defs::impl_lint_pass; ๐Ÿ”’
use rustc_macros::Diagnostic; ๐Ÿ”’
use rustc_middle::ty; ๐Ÿ”’
use rustc_middle::ty::Ty; ๐Ÿ”’
use rustc_span::sym; ๐Ÿ”’
use crate::diagnostics::IntegerToPtrTransmutes; ๐Ÿ”’
use crate::diagnostics::IntegerToPtrTransmutesSuggestion; ๐Ÿ”’
use crate::diagnostics::IntegerToPtrWithoutProvHelp; ๐Ÿ”’
use crate::utils::std_or_core; ๐Ÿ”’
use crate::LateContext; ๐Ÿ”’
use crate::LateLintPass; ๐Ÿ”’

Structsยง

CheckTransmutes ๐Ÿ”’
UndefinedTransmuteLint ๐Ÿ”’

Staticsยง

INTEGER_TO_PTR_TRANSMUTES
The integer_to_ptr_transmutes lint detects integer to pointer transmutes where the resulting pointers are undefined behavior to dereference.
PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS
The ptr_to_integer_transmute_in_consts lint detects pointer to integer transmute in const functions and associated constants.
UNNECESSARY_TRANSMUTES
The unnecessary_transmutes lint detects transmutations that have safer alternatives.

Functionsยง

check_int_to_ptr_transmute ๐Ÿ”’
Check for transmutes from integer to pointers (*const/*mut and &/&mut).
check_ptr_transmute_in_const ๐Ÿ”’
Check for transmutes that exhibit undefined behavior. For example, transmuting pointers to integers in a const context.
check_unnecessary_transmute ๐Ÿ”’
Check for transmutes that overlap with stdlib methods. For example, transmuting [u8; 4] to u32.