Rename incorrect_fn_null_checks to useless_ptr_null_checks
This commit is contained in:
parent
743ae5a2eb
commit
d2b7c8028f
6 changed files with 47 additions and 47 deletions
|
@ -213,12 +213,6 @@ lint_expectation = this lint expectation is unfulfilled
|
||||||
.note = the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
|
.note = the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
|
||||||
.rationale = {$rationale}
|
.rationale = {$rationale}
|
||||||
|
|
||||||
lint_fn_null_check_fn_ptr = function pointers are not nullable, so checking them for null will always return false
|
|
||||||
.help = wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
|
||||||
|
|
||||||
lint_fn_null_check_ref = references are not nullable, so checking them for null will always return false
|
|
||||||
.label = expression has type `{$orig_ty}`
|
|
||||||
|
|
||||||
lint_for_loops_over_fallibles =
|
lint_for_loops_over_fallibles =
|
||||||
for loop over {$article} `{$ty}`. This is more readably written as an `if let` statement
|
for loop over {$article} `{$ty}`. This is more readably written as an `if let` statement
|
||||||
.suggestion = consider using `if let` to clear intent
|
.suggestion = consider using `if let` to clear intent
|
||||||
|
@ -453,6 +447,12 @@ lint_path_statement_drop = path statement drops value
|
||||||
|
|
||||||
lint_path_statement_no_effect = path statement with no effect
|
lint_path_statement_no_effect = path statement with no effect
|
||||||
|
|
||||||
|
lint_ptr_null_checks_fn_ptr = function pointers are not nullable, so checking them for null will always return false
|
||||||
|
.help = wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
|
lint_ptr_null_checks_ref = references are not nullable, so checking them for null will always return false
|
||||||
|
.label = expression has type `{$orig_ty}`
|
||||||
|
|
||||||
lint_query_instability = using `{$query}` can result in unstable query results
|
lint_query_instability = using `{$query}` can result in unstable query results
|
||||||
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
|
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ mod early;
|
||||||
mod enum_intrinsics_non_enums;
|
mod enum_intrinsics_non_enums;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod expect;
|
mod expect;
|
||||||
mod fn_null_check;
|
|
||||||
mod for_loops_over_fallibles;
|
mod for_loops_over_fallibles;
|
||||||
pub mod hidden_unicode_codepoints;
|
pub mod hidden_unicode_codepoints;
|
||||||
mod internal;
|
mod internal;
|
||||||
|
@ -76,6 +75,7 @@ mod noop_method_call;
|
||||||
mod opaque_hidden_inferred_bound;
|
mod opaque_hidden_inferred_bound;
|
||||||
mod pass_by_value;
|
mod pass_by_value;
|
||||||
mod passes;
|
mod passes;
|
||||||
|
mod ptr_nulls;
|
||||||
mod redundant_semicolon;
|
mod redundant_semicolon;
|
||||||
mod reference_casting;
|
mod reference_casting;
|
||||||
mod traits;
|
mod traits;
|
||||||
|
@ -102,7 +102,6 @@ use builtin::*;
|
||||||
use deref_into_dyn_supertrait::*;
|
use deref_into_dyn_supertrait::*;
|
||||||
use drop_forget_useless::*;
|
use drop_forget_useless::*;
|
||||||
use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums;
|
use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums;
|
||||||
use fn_null_check::*;
|
|
||||||
use for_loops_over_fallibles::*;
|
use for_loops_over_fallibles::*;
|
||||||
use hidden_unicode_codepoints::*;
|
use hidden_unicode_codepoints::*;
|
||||||
use internal::*;
|
use internal::*;
|
||||||
|
@ -117,6 +116,7 @@ use nonstandard_style::*;
|
||||||
use noop_method_call::*;
|
use noop_method_call::*;
|
||||||
use opaque_hidden_inferred_bound::*;
|
use opaque_hidden_inferred_bound::*;
|
||||||
use pass_by_value::*;
|
use pass_by_value::*;
|
||||||
|
use ptr_nulls::*;
|
||||||
use redundant_semicolon::*;
|
use redundant_semicolon::*;
|
||||||
use reference_casting::*;
|
use reference_casting::*;
|
||||||
use traits::*;
|
use traits::*;
|
||||||
|
@ -227,7 +227,7 @@ late_lint_methods!(
|
||||||
// Depends on types used in type definitions
|
// Depends on types used in type definitions
|
||||||
MissingCopyImplementations: MissingCopyImplementations,
|
MissingCopyImplementations: MissingCopyImplementations,
|
||||||
// Depends on referenced function signatures in expressions
|
// Depends on referenced function signatures in expressions
|
||||||
IncorrectFnNullChecks: IncorrectFnNullChecks,
|
PtrNullChecks: PtrNullChecks,
|
||||||
MutableTransmutes: MutableTransmutes,
|
MutableTransmutes: MutableTransmutes,
|
||||||
TypeAliasBounds: TypeAliasBounds,
|
TypeAliasBounds: TypeAliasBounds,
|
||||||
TrivialConstraints: TrivialConstraints,
|
TrivialConstraints: TrivialConstraints,
|
||||||
|
|
|
@ -613,13 +613,13 @@ pub struct ExpectationNote {
|
||||||
pub rationale: Symbol,
|
pub rationale: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn_null_check.rs
|
// ptr_nulls.rs
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
pub enum FnNullCheckDiag<'a> {
|
pub enum PtrNullChecksDiag<'a> {
|
||||||
#[diag(lint_fn_null_check_fn_ptr)]
|
#[diag(lint_ptr_null_checks_fn_ptr)]
|
||||||
#[help(lint_help)]
|
#[help(lint_help)]
|
||||||
FnPtr,
|
FnPtr,
|
||||||
#[diag(lint_fn_null_check_ref)]
|
#[diag(lint_ptr_null_checks_ref)]
|
||||||
Ref {
|
Ref {
|
||||||
orig_ty: Ty<'a>,
|
orig_ty: Ty<'a>,
|
||||||
#[label]
|
#[label]
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::{lints::FnNullCheckDiag, LateContext, LateLintPass, LintContext};
|
use crate::{lints::PtrNullChecksDiag, LateContext, LateLintPass, LintContext};
|
||||||
use rustc_ast::LitKind;
|
use rustc_ast::LitKind;
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind};
|
use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind};
|
||||||
use rustc_session::{declare_lint, declare_lint_pass};
|
use rustc_session::{declare_lint, declare_lint_pass};
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `incorrect_fn_null_checks` lint checks for expression that checks if a
|
/// The `useless_ptr_null_checks` lint checks for useless null checks against pointers
|
||||||
/// function pointer is null.
|
/// obtained from non-null types.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
|
@ -22,16 +22,16 @@ declare_lint! {
|
||||||
///
|
///
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// Function pointers are assumed to be non-null, checking them for null will always
|
/// Function pointers and references are assumed to be non-null, checking them for null
|
||||||
/// return false.
|
/// will always return false.
|
||||||
INCORRECT_FN_NULL_CHECKS,
|
USELESS_PTR_NULL_CHECKS,
|
||||||
Warn,
|
Warn,
|
||||||
"incorrect checking of null function pointer"
|
"useless checking of non-null-typed pointer"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint_pass!(IncorrectFnNullChecks => [INCORRECT_FN_NULL_CHECKS]);
|
declare_lint_pass!(PtrNullChecks => [USELESS_PTR_NULL_CHECKS]);
|
||||||
|
|
||||||
fn incorrect_check<'a>(cx: &LateContext<'a>, expr: &Expr<'_>) -> Option<FnNullCheckDiag<'a>> {
|
fn incorrect_check<'a>(cx: &LateContext<'a>, expr: &Expr<'_>) -> Option<PtrNullChecksDiag<'a>> {
|
||||||
let mut expr = expr.peel_blocks();
|
let mut expr = expr.peel_blocks();
|
||||||
let mut had_at_least_one_cast = false;
|
let mut had_at_least_one_cast = false;
|
||||||
while let ExprKind::Cast(cast_expr, cast_ty) = expr.kind
|
while let ExprKind::Cast(cast_expr, cast_ty) = expr.kind
|
||||||
|
@ -44,16 +44,16 @@ fn incorrect_check<'a>(cx: &LateContext<'a>, expr: &Expr<'_>) -> Option<FnNullCh
|
||||||
} else {
|
} else {
|
||||||
let orig_ty = cx.typeck_results().expr_ty(expr);
|
let orig_ty = cx.typeck_results().expr_ty(expr);
|
||||||
if orig_ty.is_fn() {
|
if orig_ty.is_fn() {
|
||||||
Some(FnNullCheckDiag::FnPtr)
|
Some(PtrNullChecksDiag::FnPtr)
|
||||||
} else if orig_ty.is_ref() {
|
} else if orig_ty.is_ref() {
|
||||||
Some(FnNullCheckDiag::Ref { orig_ty, label: expr.span })
|
Some(PtrNullChecksDiag::Ref { orig_ty, label: expr.span })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for IncorrectFnNullChecks {
|
impl<'tcx> LateLintPass<'tcx> for PtrNullChecks {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
// Catching:
|
// Catching:
|
||||||
|
@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for IncorrectFnNullChecks {
|
||||||
)
|
)
|
||||||
&& let Some(diag) = incorrect_check(cx, arg) =>
|
&& let Some(diag) = incorrect_check(cx, arg) =>
|
||||||
{
|
{
|
||||||
cx.emit_spanned_lint(INCORRECT_FN_NULL_CHECKS, expr.span, diag)
|
cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catching:
|
// Catching:
|
||||||
|
@ -80,12 +80,12 @@ impl<'tcx> LateLintPass<'tcx> for IncorrectFnNullChecks {
|
||||||
)
|
)
|
||||||
&& let Some(diag) = incorrect_check(cx, receiver) =>
|
&& let Some(diag) = incorrect_check(cx, receiver) =>
|
||||||
{
|
{
|
||||||
cx.emit_spanned_lint(INCORRECT_FN_NULL_CHECKS, expr.span, diag)
|
cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq) => {
|
ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq) => {
|
||||||
let to_check: &Expr<'_>;
|
let to_check: &Expr<'_>;
|
||||||
let diag: FnNullCheckDiag<'_>;
|
let diag: PtrNullChecksDiag<'_>;
|
||||||
if let Some(ddiag) = incorrect_check(cx, left) {
|
if let Some(ddiag) = incorrect_check(cx, left) {
|
||||||
to_check = right;
|
to_check = right;
|
||||||
diag = ddiag;
|
diag = ddiag;
|
||||||
|
@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for IncorrectFnNullChecks {
|
||||||
if let ExprKind::Lit(spanned) = cast_expr.kind
|
if let ExprKind::Lit(spanned) = cast_expr.kind
|
||||||
&& let LitKind::Int(v, _) = spanned.node && v == 0 =>
|
&& let LitKind::Int(v, _) = spanned.node && v == 0 =>
|
||||||
{
|
{
|
||||||
cx.emit_spanned_lint(INCORRECT_FN_NULL_CHECKS, expr.span, diag)
|
cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||||
},
|
},
|
||||||
|
|
||||||
// Catching:
|
// Catching:
|
||||||
|
@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for IncorrectFnNullChecks {
|
||||||
&& let Some(diag_item) = cx.tcx.get_diagnostic_name(def_id)
|
&& let Some(diag_item) = cx.tcx.get_diagnostic_name(def_id)
|
||||||
&& (diag_item == sym::ptr_null || diag_item == sym::ptr_null_mut) =>
|
&& (diag_item == sym::ptr_null || diag_item == sym::ptr_null_mut) =>
|
||||||
{
|
{
|
||||||
cx.emit_spanned_lint(INCORRECT_FN_NULL_CHECKS, expr.span, diag)
|
cx.emit_spanned_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {},
|
_ => {},
|
|
@ -1,14 +1,14 @@
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:7:8
|
--> $DIR/ptr_null_checks.rs:7:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *mut ()).is_null() {}
|
LL | if (fn_ptr as *mut ()).is_null() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
= note: `#[warn(incorrect_fn_null_checks)]` on by default
|
= note: `#[warn(useless_ptr_null_checks)]` on by default
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:9:8
|
--> $DIR/ptr_null_checks.rs:9:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *const u8).is_null() {}
|
LL | if (fn_ptr as *const u8).is_null() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -16,7 +16,7 @@ LL | if (fn_ptr as *const u8).is_null() {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:11:8
|
--> $DIR/ptr_null_checks.rs:11:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
|
LL | if (fn_ptr as *const ()) == std::ptr::null() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -24,7 +24,7 @@ LL | if (fn_ptr as *const ()) == std::ptr::null() {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:13:8
|
--> $DIR/ptr_null_checks.rs:13:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
|
LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -32,7 +32,7 @@ LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:15:8
|
--> $DIR/ptr_null_checks.rs:15:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
|
LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -40,7 +40,7 @@ LL | if (fn_ptr as *const ()) == (0 as *const ()) {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:17:8
|
--> $DIR/ptr_null_checks.rs:17:8
|
||||||
|
|
|
|
||||||
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
|
LL | if <*const _>::is_null(fn_ptr as *const ()) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -48,7 +48,7 @@ LL | if <*const _>::is_null(fn_ptr as *const ()) {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:19:8
|
--> $DIR/ptr_null_checks.rs:19:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
|
LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -56,7 +56,7 @@ LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: function pointers are not nullable, so checking them for null will always return false
|
warning: function pointers are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:21:8
|
--> $DIR/ptr_null_checks.rs:21:8
|
||||||
|
|
|
|
||||||
LL | if (fn_ptr as fn() as *const ()).is_null() {}
|
LL | if (fn_ptr as fn() as *const ()).is_null() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -64,7 +64,7 @@ LL | if (fn_ptr as fn() as *const ()).is_null() {}
|
||||||
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
= help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:25:8
|
--> $DIR/ptr_null_checks.rs:25:8
|
||||||
|
|
|
|
||||||
LL | if (&mut 8 as *mut i32).is_null() {}
|
LL | if (&mut 8 as *mut i32).is_null() {}
|
||||||
| ^------^^^^^^^^^^^^^^^^^^^^^^^
|
| ^------^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -72,7 +72,7 @@ LL | if (&mut 8 as *mut i32).is_null() {}
|
||||||
| expression has type `&mut i32`
|
| expression has type `&mut i32`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:27:8
|
--> $DIR/ptr_null_checks.rs:27:8
|
||||||
|
|
|
|
||||||
LL | if (&8 as *const i32).is_null() {}
|
LL | if (&8 as *const i32).is_null() {}
|
||||||
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -80,7 +80,7 @@ LL | if (&8 as *const i32).is_null() {}
|
||||||
| expression has type `&i32`
|
| expression has type `&i32`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:29:8
|
--> $DIR/ptr_null_checks.rs:29:8
|
||||||
|
|
|
|
||||||
LL | if (&8 as *const i32) == std::ptr::null() {}
|
LL | if (&8 as *const i32) == std::ptr::null() {}
|
||||||
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -88,7 +88,7 @@ LL | if (&8 as *const i32) == std::ptr::null() {}
|
||||||
| expression has type `&i32`
|
| expression has type `&i32`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:32:8
|
--> $DIR/ptr_null_checks.rs:32:8
|
||||||
|
|
|
|
||||||
LL | if (ref_num as *const i32) == std::ptr::null() {}
|
LL | if (ref_num as *const i32) == std::ptr::null() {}
|
||||||
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -96,7 +96,7 @@ LL | if (ref_num as *const i32) == std::ptr::null() {}
|
||||||
| expression has type `&i32`
|
| expression has type `&i32`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:34:8
|
--> $DIR/ptr_null_checks.rs:34:8
|
||||||
|
|
|
|
||||||
LL | if (b"\0" as *const u8).is_null() {}
|
LL | if (b"\0" as *const u8).is_null() {}
|
||||||
| ^-----^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^-----^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -104,7 +104,7 @@ LL | if (b"\0" as *const u8).is_null() {}
|
||||||
| expression has type `&[u8; 1]`
|
| expression has type `&[u8; 1]`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:36:8
|
--> $DIR/ptr_null_checks.rs:36:8
|
||||||
|
|
|
|
||||||
LL | if ("aa" as *const str).is_null() {}
|
LL | if ("aa" as *const str).is_null() {}
|
||||||
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^----^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -112,7 +112,7 @@ LL | if ("aa" as *const str).is_null() {}
|
||||||
| expression has type `&str`
|
| expression has type `&str`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:38:8
|
--> $DIR/ptr_null_checks.rs:38:8
|
||||||
|
|
|
|
||||||
LL | if (&[1, 2] as *const i32).is_null() {}
|
LL | if (&[1, 2] as *const i32).is_null() {}
|
||||||
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^-------^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -120,7 +120,7 @@ LL | if (&[1, 2] as *const i32).is_null() {}
|
||||||
| expression has type `&[i32; 2]`
|
| expression has type `&[i32; 2]`
|
||||||
|
|
||||||
warning: references are not nullable, so checking them for null will always return false
|
warning: references are not nullable, so checking them for null will always return false
|
||||||
--> $DIR/fn_null_check.rs:40:8
|
--> $DIR/ptr_null_checks.rs:40:8
|
||||||
|
|
|
|
||||||
LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
|
LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {}
|
||||||
| ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
Loading…
Add table
Add a link
Reference in a new issue