Skip to main content

Module dangling

Module dangling 

Source

Re-exportsยง

use rustc_ast::visit::visit_opt; ๐Ÿ”’
use rustc_ast::visit::walk_list; ๐Ÿ”’
use rustc_attr_ir::find_attr; ๐Ÿ”’
use rustc_attr_ir::lang_items::LangItem; ๐Ÿ”’
use rustc_hir::def::Res; ๐Ÿ”’
use rustc_hir::def_id::LocalDefId; ๐Ÿ”’
use rustc_hir::intravisit::FnKind; ๐Ÿ”’
use rustc_hir::intravisit::Visitor; ๐Ÿ”’
use rustc_hir::intravisit::walk_expr; ๐Ÿ”’
use rustc_hir::Block; ๐Ÿ”’
use rustc_hir::Body; ๐Ÿ”’
use rustc_hir::Expr; ๐Ÿ”’
use rustc_hir::ExprKind; ๐Ÿ”’
use rustc_hir::FnDecl; ๐Ÿ”’
use rustc_hir::FnRetTy; ๐Ÿ”’
use rustc_hir::TyKind; ๐Ÿ”’
use rustc_lint_defs::declare_lint; ๐Ÿ”’
use rustc_lint_defs::impl_lint_pass; ๐Ÿ”’
use rustc_middle::ty; ๐Ÿ”’
use rustc_middle::ty::Ty; ๐Ÿ”’
use rustc_middle::ty::TyCtxt; ๐Ÿ”’
use rustc_span::Span; ๐Ÿ”’
use rustc_span::sym; ๐Ÿ”’
use crate::diagnostics::DanglingPointersFromLocals; ๐Ÿ”’
use crate::diagnostics::DanglingPointersFromTemporaries; ๐Ÿ”’
use crate::LateContext; ๐Ÿ”’
use crate::LateLintPass; ๐Ÿ”’

Structsยง

DanglingPointerLocalContext ๐Ÿ”’
DanglingPointerReturnSearcher ๐Ÿ”’
DanglingPointerSearcher ๐Ÿ”’
This produces a dangling pointer:
DanglingPointers ๐Ÿ”’
FIXME: false negatives (i.e. the lint is not emitted when it should be)

Staticsยง

DANGLING_POINTERS_FROM_LOCALS
The dangling_pointers_from_locals lint detects getting a pointer to data of a local that will be dropped at the end of the function.
DANGLING_POINTERS_FROM_TEMPORARIES
The dangling_pointers_from_temporaries lint detects getting a pointer to data of a temporary that will immediately get dropped.

Functionsยง

is_temporary_rvalue ๐Ÿ”’
lint_addr_of_local ๐Ÿ”’
Look for &<path_to_local_in_same_body> pattern and emit lint for it
lint_expr ๐Ÿ”’
owns_allocation ๐Ÿ”’