Expand description
Lints, aka compiler warnings.
A βlintβ check is a kind of miscellaneous constraint that a user might want to enforce, but might reasonably want to permit as well, on a module-by-module basis. They contrast with static constraints enforced by other phases of the compiler, which are generally required to hold in order to compile the program at all.
Most lints can be written as LintPass instances. These run after
all other analyses. The LintPasses built into rustc are defined
within rustc_lint_defs::builtin,
which has further comments on how to add such a lint.
rustc can also load external lint plugins, as is done for Clippy.
See https://rustc-dev-guide.rust-lang.org/diagnostics.html for an overview of how lints are implemented.
Β§Note
This API is completely unstable and subject to change.
Re-exportsΒ§
pub(crate) use async_closures::AsyncClosureUsage;πpub(crate) use async_fn_in_trait::AsyncFnInTrait;πpub(crate) use default_could_be_derived::DefaultCouldBeDerived;πpub(crate) use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums;πpub(crate) use if_let_rescope::IfLetRescope;πpub(crate) use impl_trait_overcaptures::ImplTraitOvercaptures;πpub(crate) use implicit_provenance_casts::ImplicitProvenanceCasts;πpub(crate) use non_fmt_panic::NonPanicFmt;πpub(crate) use shadowed_into_iter::ShadowedIntoIter;πpub use shadowed_into_iter::ARRAY_INTO_ITER;pub use shadowed_into_iter::BOXED_SLICE_INTO_ITER;pub(crate) use transmute::CheckTransmutes;πpub(crate) use unmarked_unchecked_type_aliases::UnmarkedUncheckedTypeAliases;πpub use builtin::MissingDoc;pub use context::CheckLintNameResult;pub use context::EarlyContext;pub use context::LateContext;pub use context::LintContext;pub use context::LintStore;pub use early::diagnostics::DiagAndSess;pub use early::EarlyCheckNode;pub use early::check_ast_node;pub use late::check_crate;pub use late::late_lint_mod;pub use late::unerased_lint_store;pub use levels::LintLevelsBuilder;pub use passes::EarlyLintPass;pub use passes::LateLintPass;pub use utils::std_or_core;pub(crate) use improper_ctypes::ImproperCTypesLint;πpub(crate) use rustc_data_structures::unord::UnordSet;πpub(crate) use rustc_hir::def_id::LocalModId;πpub(crate) use rustc_middle::query::Providers;πpub(crate) use rustc_middle::ty::TyCtxt;πpub(crate) use builtin::*;πpub(crate) use lifetime_syntax::*;πpub(crate) use unused::must_use::*;πpub(crate) use unused::*;πpub use rustc_lint_defs::Level::*;
ModulesΒ§
- async_
closures π - async_
fn_ πin_ trait - autorefs π
- builtin
- Lints in the Rust compiler.
- c_
void_ πreturns - context π
- Basic types for managing and implementing lints.
- dangling π
- default_
could_ πbe_ derived - deref_
into_ πdyn_ supertrait - diagnostics π
- disallowed_
pass_ πby_ ref - drop_
forget_ πuseless - early π
- Implementation of the early lint pass.
- enum_
intrinsics_ πnon_ enums - expect π
- for_
loops_ πover_ fallibles - foreign_
modules π - function_
cast_ πas_ integer - gpukernel_
abi π - if_
let_ πrescope - impl_
trait_ πovercaptures - implicit_
provenance_ πcasts - improper_
ctypes π - interior_
mutable_ πconsts - internal π
- Some lints that are only useful in the compiler or crates that use compiler internals, such as Clippy.
- invalid_
from_ πutf8 - late π
- Implementation of the late lint pass.
- let_
underscore π - levels π
- lifetime_
syntax - literal π
- macro_
expr_ πfragment_ specifier_ 2024_ migration - Migration code for the
expr_fragment_specifier_2024rule. - map_
unit_ πfn - multiple_
supertrait_ πupcastable - non_
ascii_ πidents - non_
fmt_ πpanic - non_
local_ πdef - nonstandard_
style π - noop_
method_ πcall - opaque_
hidden_ πinferred_ bound - passes π
- precedence π
- ptr_
nulls π - raw_
borrows_ πvia_ references - redundant_
semicolon π - reference_
casting π - runtime_
symbols π - shadowed_
into_ πiter - static_
mut_ πrefs - traits π
- transmute π
- types π
- unit_
bindings π - unmarked_
unchecked_ πtype_ aliases - unqualified_
local_ πimports - unused
- utils π
MacrosΒ§
- declare_
combined_ early_ lint_ pass - Combines multiple lints passes into a single lint pass, at compile time,
for maximum speed. Each
check_foomethod in$methodswithin this pass simply callscheck_fooonce per$pass. Compare withRuntimeCombinedEarlyLintPass, which is similar, but combines lint passes at runtime. - declare_
combined_ late_ lint_ pass - Combines multiple lints passes into a single lint pass, at compile time,
for maximum speed. Each
check_foomethod in$methodswithin this pass simply callscheck_fooonce per$pass. Compare withRuntimeCombinedLateLintPass, which is similar, but combines lint passes at runtime. - declare_
lint - Declares a static item of type
&'static Lint. - declare_
lint_ pass - Declares a type named
$namewhich implementsLintPass. To the right of=>a comma separated list ofLintstatics is given. - declare_
tool_ lint - early_
lint_ methods - expand_
combined_ early_ lint_ pass_ method - expand_
combined_ early_ lint_ pass_ methods - expand_
combined_ late_ lint_ pass_ method - expand_
combined_ late_ lint_ pass_ methods - impl_
lint_ pass - Implements
LintPass for $tywith the given list ofLintstatics. - late_
lint_ methods
StructsΒ§
- AddBound π
- BadOpt
Access π - BadUse
OfFind πAttr - Buffered
Early Lint - Lints that are buffered up early on in the
Sessionbefore theLintLevelsis calculated. - Builtin
Combined Early Lint Pass - Builtin
Combined πLate Lint ModPass - Builtin
Combined PreExpansion Lint Pass - CVoid
Returns π - Check
GpuKernel πTypes - Check for valid and invalid types.
- Dangling
Pointer πLocal Context - Dangling
Pointer πReturn Searcher - Dangling
Pointer πSearcher - This produces a dangling pointer:
- Dangling
Pointers π - FIXME: false negatives (i.e. the lint is not emitted when it should be)
- Default
Hash πTypes - Deref
Into πDynSupertrait - Disallowed
Pass πByRef - Drop
Forget πUseless - Drop
Trait πConstraints - Lint for bounds of the form
T: Drop, which usually indicate an attempt to emulatestd::mem::needs_drop. - Expr2024 π
- ForLoops
Over πFallibles - Function
Casts πAsInteger - Lint for casts of functions into integers.
- Future
Incompatible Info - Extra information for a future incompatibility lint.
- Implicit
Autorefs π - Implicit
Sysroot πCrate Import - Improper
GpuKernel πLint - Interior
Mutable πConsts - Internal
Combined πEarly Lint Pass - Internal
Combined πLate Lint ModPass - Invalid
Atomic πOrdering - Invalid
From πUtf8 - Invalid
Reference πCasting - LetUnderscore π
- Lint
- Specification of a single lint.
- LintId
- Identifies a lint known to the compiler.
- Lint
Pass πImpl - MapUnit
Fn π - Missing
Generic πType Visitable Derive - Multiple
Supertrait πUpcastable - Negation
Info π - NonAscii
Idents π - NonCamel
Case πTypes - NonLocal
Definitions π - NonSnake
Case π - NonUpper
Case πGlobal Generator - NonUpper
Case πGlobals - Noop
Method πCall - Opaque
Hidden πInferred Bound - Opaque
Hidden πInferred Bound Lint - Path
Collector π - Simple hir::Path collector
- Precedence π
- PtrNull
Checks π - Query
Stability π - RawBorrows
ViaReferences π - Redundant
Semicolons π - Runtime
Symbols π - Rustc
Must πMatch Exhaustively - Static
MutInfo π - Static
MutRefs π - Symbol
Intern πString Literal - TyTy
Kind π - TypeIr π
- Type
Limits π - Unit
Bindings π - Unqualified
Local πImports - Variant
Size πDifferences
EnumsΒ§
- Applicability
- Indicates the confidence in the correctness of a suggestion.
- Comparison
Op π - Level
- Setting for how to handle a lint.
- Pattern
Kind π
ConstantsΒ§
- SYNC_
GUARD_ πSYMBOLS
StaticsΒ§
- AMBIGUOUS_
NEGATIVE_ πLITERALS - The
ambiguous_negative_literalslint checks for cases that are confusing between a negative literal and a negation thatβs not part of the literal. - AMBIGUOUS_
WIDE_ πPOINTER_ COMPARISONS - The
ambiguous_wide_pointer_comparisonslint checks comparison of*const/*mut ?Sizedas the operands. - BAD_
OPT_ πACCESS - The
bad_opt_accesslint detects accessing options by field instead of the wrapper function. - BAD_
USE_ πOF_ FIND_ ATTR - CONFUSABLE_
IDENTS π - The
confusable_identslint detects visually confusable pairs between identifiers. - CONST_
ITEM_ πINTERIOR_ MUTATIONS - The
const_item_interior_mutationslint checks for calls which mutates an interior mutable const-item. - C_
VOID_ πRETURNS - The
c_void_returnslint detects the use ofcore::ffi::c_voidas a return type. - DANGEROUS_
IMPLICIT_ πAUTOREFS - The
dangerous_implicit_autorefslint checks for implicitly taken references to dereferences of raw pointers. - DANGLING_
POINTERS_ πFROM_ LOCALS - The
dangling_pointers_from_localslint 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_temporarieslint detects getting a pointer to data of a temporary that will immediately get dropped. - DEFAULT_
HASH_ πTYPES - The
default_hash_typelint detects use ofstd::collections::HashMapandstd::collections::HashSet, suggesting the use ofFxHashMap/FxHashSet. - DEREF_
INTO_ πDYN_ SUPERTRAIT - The
deref_into_dyn_supertraitlint is emitted whenever there is aDerefimplementation fordyn SubTraitwith adyn SuperTraittype as theOutputtype. - DIRECT_
USE_ πOF_ RUSTC_ TYPE_ IR - The
direct_use_of_rustc_type_irlint detects usage ofrustc_type_ir. - DISALLOWED_
PASS_ πBY_ REF - The
disallowed_pass_by_reflint detects if types marked with#[rustc_pass_by_value]are passed by reference. Types with this marker are usually thin wrappers around references, so there is no benefit to an extra layer of indirection. (Example:Tywhich is a reference to anInterned<TyKind>) - DROPPING_
COPY_ πTYPES - The
dropping_copy_typeslint checks for calls tostd::mem::dropandstd::ptr::drop_in_placewhere the dropped value implements theCopytrait. - DROPPING_
REFERENCES π - The
dropping_referenceslint checks for calls tostd::mem::dropandstd::ptr::drop_in_placewhere the dropped type is a reference instead of an owned value. - DROP_
BOUNDS π - The
drop_boundslint checks for generics withstd::ops::Dropas bounds. - DYN_
DROP π - The
dyn_droplint checks for trait objects withstd::ops::Drop. - EDITION_
2024_ πEXPR_ FRAGMENT_ SPECIFIER - The
edition_2024_expr_fragment_specifierlint detects the use ofexprfragments in macros during migration to the 2024 edition. - FORGETTING_
COPY_ πTYPES - The
forgetting_copy_typeslint checks for calls tostd::mem::forgetwith a value that derives the Copy trait. - FORGETTING_
REFERENCES π - The
forgetting_referenceslint checks for calls tostd::mem::forgetwith a reference instead of an owned value. - FOR_
LOOPS_ πOVER_ FALLIBLES - The
for_loops_over_fallibleslint checks forforloops overOptionorResultvalues. - FUNCTION_
CASTS_ πAS_ INTEGER - The
function_casts_as_integerlint detects cases where a function item is cast to an integer. - IMPLICIT_
SYSROOT_ πCRATE_ IMPORT - The
implicit_sysroot_crate_importdetects use ofextern crateto import non-sysroot crates (e.g. crates.io deps) from the sysroot, which is dangerous because these crates are not guaranteed to exist exactly once, and so may be missing entirely or appear multiple times resulting in ambiguity. - IMPROPER_
GPU_ πKERNEL_ ARG - The
improper_gpu_kernel_arglint detects incorrect use of types ingpu-kernelarguments. - INVALID_
ATOMIC_ πORDERING - The
invalid_atomic_orderinglint detects passing anOrderingto an atomic operation that does not support that ordering. - INVALID_
FROM_ πUTF8 - The
invalid_from_utf8lint checks for calls tostd::str::from_utf8andstd::str::from_utf8_mutwith a known invalid UTF-8 value. - INVALID_
FROM_ πUTF8_ UNCHECKED - The
invalid_from_utf8_uncheckedlint checks for calls tostd::str::from_utf8_uncheckedandstd::str::from_utf8_unchecked_mutwith a known invalid UTF-8 value. - INVALID_
NAN_ πCOMPARISONS - The
invalid_nan_comparisonslint checks comparisons with theNANconstants off16,f32,f64, andf128. - INVALID_
NULL_ πARGUMENTS - The
invalid_null_argumentslint checks for invalid usage of null pointers in arguments. - INVALID_
REFERENCE_ πCASTING - The
invalid_reference_castinglint checks for casts of&Tto&mut Twithout using interior mutability. - INVALID_
RUNTIME_ πSYMBOL_ DEFINITIONS - The
invalid_runtime_symbol_definitionslint checks the signature of items whose symbol name is a runtime symbol expected bycoreorstddiffers significantly from the expected signature (like mismatch ABI, mismatch C variadics, mismatch argument count, missing return type, β¦). - LET_
UNDERSCORE_ πDROP - The
let_underscore_droplint checks for statements which donβt bind an expression which has a non-trivial Drop implementation to anything, causing the expression to be dropped immediately instead of at end of scope. - LET_
UNDERSCORE_ πDROP_ GUARD - The
let_underscore_drop_guardlint checks for statements which donβt bind aDropGuardto anything, causing its closure to run immediately instead of at end of scope, which is typically incorrect. - LET_
UNDERSCORE_ πLOCK - The
let_underscore_locklint checks for statements which donβt bind a mutex to anything, causing the lock to be released immediately instead of at end of scope, which is typically incorrect. - LINT_
PASS_ πIMPL_ WITHOUT_ MACRO - The
lint_pass_impl_without_macrodetects manual implementations of a lint pass, without usingdeclare_lint_passor [impl_lint_pass]. - MAP_
UNIT_ πFN - The
map_unit_fnlint checks forIterator::mapreceive a callable that returns(). - MISSING_
GENERIC_ πTYPE_ VISITABLE_ DERIVE - The
missing_generic_type_visitable_derivelint detects types implementingTypeVisitablebut not derivingGenericTypeVisitable. - MISSING_
GPU_ πKERNEL_ EXPORT_ NAME - The
missing_gpu_kernel_export_namelint detectsgpu-kernelfunctions that have a mangled name. - MIXED_
SCRIPT_ πCONFUSABLES - The
mixed_script_confusableslint detects visually confusable characters in identifiers between different scripts. - MULTIPLE_
SUPERTRAIT_ πUPCASTABLE - The
multiple_supertrait_upcastablelint detects when a dyn-compatible trait has multiple supertraits. - NON_
ASCII_ πIDENTS - The
non_ascii_identslint detects non-ASCII identifiers. - NON_
CAMEL_ πCASE_ TYPES - The
non_camel_case_typeslint detects types, variants, traits and type parameters that donβt have camel case names. - NON_
GLOB_ πIMPORT_ OF_ TYPE_ IR_ INHERENT - The
non_glob_import_of_type_ir_inherent_itemlint detects non-glob imports of modulerustc_type_ir::inherent. - NON_
LOCAL_ πDEFINITIONS - The
non_local_definitionslint checks forimplblocks and#[macro_export]macro inside bodies (functions, enum discriminant, β¦). - NON_
SNAKE_ πCASE - The
non_snake_caselint detects variables, methods, functions, lifetime parameters, named fields and modules that donβt have snake case names. - NON_
UPPER_ πCASE_ GLOBALS - The
non_upper_case_globalslint detects static items that donβt have uppercase identifiers. - NOOP_
METHOD_ πCALL - The
noop_method_calllint detects specific calls to noop methods such as a calling<&T as Clone>::clonewhereT: !Clone. - OPAQUE_
HIDDEN_ πINFERRED_ BOUND - The
opaque_hidden_inferred_boundlint detects cases in which nestedimpl Traitin associated type bounds are not written generally enough to satisfy the bounds of the associated type. - OVERFLOWING_
LITERALS π - The
overflowing_literalslint detects literals out of range for their type. - POTENTIAL_
QUERY_ πINSTABILITY - The
potential_query_instabilitylint detects use of methods which can lead to potential query instability, such as iterating over aHashMap. - RAW_
BORROWS_ πVIA_ REFERENCES - The
raw_borrows_via_referenceslint checks for references that decay immediately into raw borrows. - REDUNDANT_
SEMICOLONS π - The
redundant_semicolonslint detects unnecessary trailing semicolons. - RUSTC_
MUST_ πMATCH_ EXHAUSTIVELY - STATIC_
MUT_ πREFS - The
static_mut_refslint checks for shared or mutable references of mutable static insideunsafeblocks andunsafefunctions. - SUSPICIOUS_
DOUBLE_ πREF_ OP - The
suspicious_double_ref_oplint checks for usage of.clone()/.borrow()/.deref()on an&&TwhenT: !Deref/Borrow/Clone, which means the call will return the inner&T, instead of performing the operation on the underlyingTand can be confusing. - SUSPICIOUS_
RUNTIME_ πSYMBOL_ DEFINITIONS - The
suspicious_runtime_symbol_definitionslint checks the signature of items whose symbol name is a runtime symbol expected bycoreorstd. - SYMBOL_
INTERN_ πSTRING_ LITERAL - The
symbol_intern_string_literallint detectsSymbol::internorIdent::from_str_and_spanbeing called on a string literal - UNCOMMON_
CODEPOINTS π - The
uncommon_codepointslint detects uncommon Unicode codepoints in identifiers. - UNDROPPED_
MANUALLY_ πDROPS - The
undropped_manually_dropslint check for calls tostd::mem::dropandstd::ptr::drop_in_placewhere the dropped value isstd::mem::ManuallyDropwhich doesnβt drop. - UNIT_
BINDINGS π - The
unit_bindingslint detects cases where bindings are useless because they have the unit type()as their inferred type. The lint is suppressed if the user explicitly annotates the let binding with the unit type(), or if the let binding uses an underscore wildcard pattern, i.e.let _ = expr, or if the binding is produced from macro expansions. - UNPREDICTABLE_
FUNCTION_ πPOINTER_ COMPARISONS - The
unpredictable_function_pointer_comparisonslint checks comparison of function pointer as the operands. - UNQUALIFIED_
LOCAL_ πIMPORTS - The
unqualified_local_importslint checks foruseitems that import a local item using a path that does not start withself::,super::, orcrate::. - UNTRACKED_
QUERY_ πINFORMATION - The
untracked_query_informationlint detects use of methods which leak information not tracked by the query system, such as whether aSteal<T>value has already been stolen. In order not to break incremental compilation, such methods must be used very carefully or not at all. - UNUSED_
COMPARISONS π - The
unused_comparisonslint detects comparisons made useless by limits of the types involved. - USAGE_
OF_ πQUALIFIED_ TY - The
usage_of_qualified_tylint detects usages ofty::TyKind, whereTyshould be used instead. - USAGE_
OF_ πTYPE_ IR_ INHERENT - The
usage_of_type_ir_inherentlint detects usage ofrustc_type_ir::inherent. - USAGE_
OF_ πTYPE_ IR_ TRAITS - The
usage_of_type_ir_traitslint detects usage ofrustc_type_ir::Interner, orrustc_infer::InferCtxtLike. - USAGE_
OF_ πTY_ TYKIND - The
usage_of_ty_tykindlint detects usages ofty::TyKind::<kind>, wherety::<kind>would suffice. - USELESS_
PTR_ πNULL_ CHECKS - The
useless_ptr_null_checkslint checks for useless null checks against pointers obtained from non-null types. - VARIANT_
SIZE_ πDIFFERENCES - The
variant_size_differenceslint detects enums with widely varying variant sizes.
TraitsΒ§
FunctionsΒ§
- borrow_
or_ πassign - changes_
when_ πtitlecased - FIXME: we should add a more efficient version in the stdlib for this
- char_
has_ πcase - Some unicode characters have case, are considered upper, title, or lower case, but they canβt be title cased or lower cased. For the purposes of the lint suggestion, we care about being able to change the charβs case.
- check π
- check_
decl π - check_
fn π - check_
static π - did_
has_ πlocal_ parent - Given a def id this checks if the parent def id (modulo modules) correspond to the def id of the parent impl definition (the direct one and the outermost one).
- emit_
static_ πmut_ refs - extend_
trailing_ πspace - extract_
for_ πloop - extract_
iterator_ πnext_ call - find_
word π - gen_
args π - gen_
args π - get_
callee_ πspan_ generic_ args_ and_ args - Checks whether an expression is a function or method call and, if so, returns its
DefId,Span,GenericArgs, and arguments. This is a slight augmentation of a similarly named Clippy function,get_callee_generic_args_and_args. - get_
nullable_ πtype - Given a non-null scalar (or transparent) type
ty, return the nullable version of that type. If the type passed in was not scalar, returns None. - get_
nullable_ πtype_ from_ pat - has_
implicit_ πborrow - Test if some adjustment has some implicit borrow.
- has_
unstable_ πinto_ iter_ predicate - interior_
mutability_ πsuggestion - is_
cast_ πto_ bigger_ memory_ layout - is_
ident_ πchar - is_
impl_ πslice - is_
invalid_ πcast_ from_ ref_ to_ mut_ ptr - is_
lint_ pass_ required - Is a pass (which contains
lints) required to run? Maybe not, e.g. for dependencies built with--cap-lints=allow. - is_
niche_ πoptimization_ candidate - A type is niche-optimization candidate iff:
- is_
null_ πptr - Checks if the given expression is a null pointer (modulo casting)
- is_
rustc_ πmust_ match_ exhaustively - is_
single_ πcall_ in_ arm - is_
temporary_ πrvalue - is_
ty_ πfully_ unsafe_ celled - Checks that a
Tyfully covered by one or moreUnsafeCell. - is_
ty_ πor_ ty_ ctxt - is_
upper_ πcamel_ case - lint_
addr_ πof_ local - Look for
&<path_to_local_in_same_body>pattern and emit lint for it - lint_
expr π - lint_
fn_ πpointer - lint_
mod π - lint_
nan π - lint_
ty_ πkind_ usage - lint_
wide_ πpointer - maybe_
lint_ πredundant_ semis - new_
lint_ store - nonnull_
optimization_ πguaranteed - not_
camel_ πcase - owns_
allocation π - pat_
is_ πnot_ exhaustive_ heuristic - pat_
ty_ πis_ known_ nonnull - path_
for_ πrustc_ pass_ by_ value - path_
has_ πlocal_ parent - Given a path, this checks if the if the parent resolution def id corresponds to the def id of the parent impl definition (the direct one and the outermost one).
- path_
is_ πstatic_ mut - path_
name_ πto_ string - Return a βerror message-ableβ ident for the last segment of the
Path - path_
span_ πwithout_ args - Return for a given
Paththe span until the last args - peel_
derefs_ πadjustments - Peel derefs adjustments until the last last element.
- peel_
parent_ πwhile - Given a
DefIdchecks if it satisfiesfif it does check with itβs parent and continue until it doesnβt satisfiesfand return the lastDefIdchecked. - peel_
place_ πmappers - Peels expressions from
exprthat can map a place. - provide
- register_
builtins π - Tell the
LintStoreabout all the built-in lints (the ones defined in this crate and the ones defined inrustc_lint_defs::builtin). - register_
internals π - repr_
nullable_ πptr - Check if this enum can be safely exported based on the βnullable pointer optimizationβ. If it
can, return the type that
tycan be safely converted to, otherwise returnNone. Currently restricted to function pointers, boxes, references,core::num::NonZero,core::ptr::NonNull, and#[repr(transparent)]newtypes. - static_
mutability_ πspan - suggest_
question_ πmark - to_
upper_ πcamel_ case - transparent_
newtype_ πfield repr(transparent)structs can have a single non-1-ZST field, this function returns that field.- ty_
is_ πknown_ nonnull - Is type known to be non-null?
- 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.