Skip to main content

Module ptr_nulls

Module ptr_nulls 

Source

Re-exportsยง

use rustc_ast::LitKind; ๐Ÿ”’
use rustc_attr_ir::find_attr; ๐Ÿ”’
use rustc_hir::BinOpKind; ๐Ÿ”’
use rustc_hir::Expr; ๐Ÿ”’
use rustc_hir::ExprKind; ๐Ÿ”’
use rustc_hir::TyKind; ๐Ÿ”’
use rustc_lint_defs::declare_lint; ๐Ÿ”’
use rustc_lint_defs::declare_lint_pass; ๐Ÿ”’
use rustc_middle::ty::RawPtr; ๐Ÿ”’
use rustc_span::Span; ๐Ÿ”’
use rustc_span::sym; ๐Ÿ”’
use crate::diagnostics::InvalidNullArgumentsDiag; ๐Ÿ”’
use crate::diagnostics::UselessPtrNullChecksDiag; ๐Ÿ”’
use crate::utils::peel_casts; ๐Ÿ”’
use crate::LateContext; ๐Ÿ”’
use crate::LateLintPass; ๐Ÿ”’
use crate::LintContext; ๐Ÿ”’

Structsยง

PtrNullChecks

Staticsยง

INVALID_NULL_ARGUMENTS ๐Ÿ”’
The invalid_null_arguments lint checks for invalid usage of null pointers in arguments.
USELESS_PTR_NULL_CHECKS ๐Ÿ”’
The useless_ptr_null_checks lint checks for useless null checks against pointers obtained from non-null types.

Functionsยง

is_null_ptr ๐Ÿ”’
Checks if the given expression is a null pointer (modulo casting)
useless_check ๐Ÿ”’
This function checks if the expression is from a series of consecutive casts, i.e. (my_fn as *const _ as *mut _).cast_mut() and whether the original expression is either a fn ptr, a reference, or a function call whose definition is annotated with #[lint::never_returns_null_ptr]. If this situation is present, the function returns the appropriate diagnostic.