migrate: pass_by_value.rs
This commit is contained in:
parent
c3a6801f8e
commit
6fb3a38f9b
@ -6,6 +6,14 @@ use rustc_span::{Span, Symbol};
|
||||
|
||||
use crate::LateContext;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_pass_by_value)]
|
||||
pub struct PassByValueDiag {
|
||||
pub ty: String,
|
||||
#[suggestion(code = "{ty}", applicability = "maybe-incorrect")]
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_redundant_semicolons)]
|
||||
pub struct RedundantSemicolonsDiag {
|
||||
|
@ -1,5 +1,7 @@
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
use crate::lints::PassByValueDiag;
|
||||
use crate::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_errors::{fluent, Applicability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::{GenericArg, PathSegment, QPath, TyKind};
|
||||
@ -29,20 +31,11 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
|
||||
}
|
||||
}
|
||||
if let Some(t) = path_for_pass_by_value(cx, &inner_ty) {
|
||||
cx.struct_span_lint(
|
||||
cx.emit_spanned_lint(
|
||||
PASS_BY_VALUE,
|
||||
ty.span,
|
||||
fluent::lint_pass_by_value,
|
||||
|lint| {
|
||||
lint.set_arg("ty", t.clone()).span_suggestion(
|
||||
ty.span,
|
||||
fluent::suggestion,
|
||||
t,
|
||||
// Changing type of function argument
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
},
|
||||
)
|
||||
PassByValueDiag { ty: t.clone(), suggestion: ty.span },
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user