Skip to content

Commit 5524ca1

Browse files
committed
lint: port deref nullptr diagnostics
Signed-off-by: David Wood <[email protected]>
1 parent 2e563a4 commit 5524ca1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/rustc_error_messages/locales/en-US/lint.ftl

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

compiler/rustc_lint/src/builtin.rs

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

0 commit comments

Comments
 (0)