Skip to content

Commit 2829f51

Browse files
committed
lint: port path statement diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent 1999a4c commit 2829f51

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,8 @@ lint-unused-generator =
273273
.note = generators are lazy and do nothing unless resumed
274274
275275
lint-unused-def = unused {$pre}`{$def}`{$post} that must be used
276+
277+
lint-path-statement-drop = path statement drops value
278+
.suggestion = use `drop` to clarify the intent
279+
280+
lint-path-statement-no-effect = path statement with no effect

compiler/rustc_lint/src/unused.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,20 +360,20 @@ impl<'tcx> LateLintPass<'tcx> for PathStatements {
360360
cx.struct_span_lint(PATH_STATEMENTS, s.span, |lint| {
361361
let ty = cx.typeck_results().expr_ty(expr);
362362
if ty.needs_drop(cx.tcx, cx.param_env) {
363-
let mut lint = lint.build("path statement drops value");
363+
let mut lint = lint.build(fluent::lint::path_statement_drop);
364364
if let Ok(snippet) = cx.sess().source_map().span_to_snippet(expr.span) {
365365
lint.span_suggestion(
366366
s.span,
367-
"use `drop` to clarify the intent",
367+
fluent::lint::suggestion,
368368
format!("drop({});", snippet),
369369
Applicability::MachineApplicable,
370370
);
371371
} else {
372-
lint.span_help(s.span, "use `drop` to clarify the intent");
372+
lint.span_help(s.span, fluent::lint::suggestion);
373373
}
374374
lint.emit();
375375
} else {
376-
lint.build("path statement with no effect").emit();
376+
lint.build(fluent::lint::path_statement_no_effect).emit();
377377
}
378378
});
379379
}

0 commit comments

Comments
 (0)