Add #[rustc_never_returns_null_ptr]
And look for it in the useless_ptr_null_checks lint
This commit is contained in:
parent
e173a8e663
commit
8cfa4fe6b2
4 changed files with 9 additions and 1 deletions
|
@ -49,7 +49,7 @@ fn ptr_cast_chain<'a>(cx: &'a LateContext<'_>, mut e: &'a Expr<'a>) -> Option<&'
|
|||
} else if let ExprKind::Call(path, [arg]) = e.kind
|
||||
&& let ExprKind::Path(ref qpath) = path.kind
|
||||
&& let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id()
|
||||
&& matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::ptr_from_ref | sym::ptr_from_mut)) {
|
||||
&& cx.tcx.has_attr(def_id, sym::rustc_never_returns_null_ptr) {
|
||||
had_at_least_one_cast = true;
|
||||
arg
|
||||
} else if had_at_least_one_cast {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue