lint: port deref nullptr diagnostics

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-06-28 15:12:35 +01:00
parent 2e563a4a3e
commit 5524ca1a1d
2 changed files with 5 additions and 2 deletions

View file

@ -393,3 +393,6 @@ lint-builtin-clashing-extern-same-name = `{$this_fi}` redeclared with a differen
lint-builtin-clashing-extern-diff-name = `{$this_fi}` redeclares `{$orig}` with a different signature
.previous-decl-label = `{$orig}` previously declared here
.mismatch-label = this signature doesn't match the previous declaration
lint-builtin-deref-nullptr = dereferencing a null pointer
.label = this code causes undefined behavior when executed

View file

@ -3068,8 +3068,8 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
if let rustc_hir::ExprKind::Unary(rustc_hir::UnOp::Deref, expr_deref) = expr.kind {
if is_null_ptr(cx, expr_deref) {
cx.struct_span_lint(DEREF_NULLPTR, expr.span, |lint| {
let mut err = lint.build("dereferencing a null pointer");
err.span_label(expr.span, "this code causes undefined behavior when executed");
let mut err = lint.build(fluent::lint::builtin_deref_nullptr);
err.span_label(expr.span, fluent::lint::label);
err.emit();
});
}