mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
lint: port unused allocation diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
e24833869f
commit
4f7b10f484
@ -283,3 +283,6 @@ lint-unused-delim = unnecessary {$delim} around {$item}
|
||||
.suggestion = remove these {$delim}
|
||||
|
||||
lint-unused-import-braces = braces around {$node} is unnecessary
|
||||
|
||||
lint-unused-allocation = unnecessary allocation, use `&` instead
|
||||
lint-unused-allocation-mut = unnecessary allocation, use `&mut` instead
|
||||
|
@ -1169,15 +1169,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
|
||||
for adj in cx.typeck_results().expr_adjustments(e) {
|
||||
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind {
|
||||
cx.struct_span_lint(UNUSED_ALLOCATION, e.span, |lint| {
|
||||
let msg = match m {
|
||||
adjustment::AutoBorrowMutability::Not => {
|
||||
"unnecessary allocation, use `&` instead"
|
||||
}
|
||||
lint.build(match m {
|
||||
adjustment::AutoBorrowMutability::Not => fluent::lint::unused_allocation,
|
||||
adjustment::AutoBorrowMutability::Mut { .. } => {
|
||||
"unnecessary allocation, use `&mut` instead"
|
||||
fluent::lint::unused_allocation_mut
|
||||
}
|
||||
};
|
||||
lint.build(msg).emit();
|
||||
})
|
||||
.emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user