1
Fork 0

lint: port pass-by-value diagnostics

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-06-27 16:57:40 +01:00
parent 855f23773b
commit 37588d6d4e
2 changed files with 7 additions and 3 deletions

View file

@ -1,5 +1,5 @@
use crate::{LateContext, LateLintPass, LintContext};
use rustc_errors::Applicability;
use rustc_errors::{fluent, Applicability};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::{GenericArg, PathSegment, QPath, TyKind};
@ -30,10 +30,11 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
}
if let Some(t) = path_for_pass_by_value(cx, &inner_ty) {
cx.struct_span_lint(PASS_BY_VALUE, ty.span, |lint| {
lint.build(&format!("passing `{}` by reference", t))
lint.build(fluent::lint::pass_by_value)
.set_arg("ty", t.clone())
.span_suggestion(
ty.span,
"try passing by value",
fluent::lint::suggestion,
t,
// Changing type of function argument
Applicability::MaybeIncorrect,