Also add label with original type for function pointers
This commit is contained in:
parent
4b3dadbe5a
commit
ee519532f6
4 changed files with 40 additions and 13 deletions
|
@ -449,6 +449,7 @@ 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
|
||||
.label = expression has type `{$orig_ty}`
|
||||
|
||||
lint_ptr_null_checks_ref = references are not nullable, so checking them for null will always return false
|
||||
.label = expression has type `{$orig_ty}`
|
||||
|
|
|
@ -618,7 +618,11 @@ pub struct ExpectationNote {
|
|||
pub enum PtrNullChecksDiag<'a> {
|
||||
#[diag(lint_ptr_null_checks_fn_ptr)]
|
||||
#[help(lint_help)]
|
||||
FnPtr,
|
||||
FnPtr {
|
||||
orig_ty: Ty<'a>,
|
||||
#[label]
|
||||
label: Span,
|
||||
},
|
||||
#[diag(lint_ptr_null_checks_ref)]
|
||||
Ref {
|
||||
orig_ty: Ty<'a>,
|
||||
|
|
|
@ -65,7 +65,7 @@ fn incorrect_check<'a>(cx: &LateContext<'a>, expr: &Expr<'_>) -> Option<PtrNullC
|
|||
|
||||
let orig_ty = cx.typeck_results().expr_ty(expr);
|
||||
if orig_ty.is_fn() {
|
||||
Some(PtrNullChecksDiag::FnPtr)
|
||||
Some(PtrNullChecksDiag::FnPtr { orig_ty, label: expr.span })
|
||||
} else if orig_ty.is_ref() {
|
||||
Some(PtrNullChecksDiag::Ref { orig_ty, label: expr.span })
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue