Skip to content

Commit 4f7b10f

Browse files
committed
lint: port unused allocation diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent e248338 commit 4f7b10f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,6 @@ lint-unused-delim = unnecessary {$delim} around {$item}
283283
.suggestion = remove these {$delim}
284284
285285
lint-unused-import-braces = braces around {$node} is unnecessary
286+
287+
lint-unused-allocation = unnecessary allocation, use `&` instead
288+
lint-unused-allocation-mut = unnecessary allocation, use `&mut` instead

compiler/rustc_lint/src/unused.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1169,15 +1169,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
11691169
for adj in cx.typeck_results().expr_adjustments(e) {
11701170
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind {
11711171
cx.struct_span_lint(UNUSED_ALLOCATION, e.span, |lint| {
1172-
let msg = match m {
1173-
adjustment::AutoBorrowMutability::Not => {
1174-
"unnecessary allocation, use `&` instead"
1175-
}
1172+
lint.build(match m {
1173+
adjustment::AutoBorrowMutability::Not => fluent::lint::unused_allocation,
11761174
adjustment::AutoBorrowMutability::Mut { .. } => {
1177-
"unnecessary allocation, use `&mut` instead"
1175+
fluent::lint::unused_allocation_mut
11781176
}
1179-
};
1180-
lint.build(msg).emit();
1177+
})
1178+
.emit();
11811179
});
11821180
}
11831181
}

0 commit comments

Comments
 (0)