Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6fb3a38

Browse files
committed
migrate: pass_by_value.rs
1 parent c3a6801 commit 6fb3a38

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

compiler/rustc_lint/src/lints.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ use rustc_span::{Span, Symbol};
66

77
use crate::LateContext;
88

9+
#[derive(LintDiagnostic)]
10+
#[diag(lint_pass_by_value)]
11+
pub struct PassByValueDiag {
12+
pub ty: String,
13+
#[suggestion(code = "{ty}", applicability = "maybe-incorrect")]
14+
pub suggestion: Span,
15+
}
16+
917
#[derive(LintDiagnostic)]
1018
#[diag(lint_redundant_semicolons)]
1119
pub struct RedundantSemicolonsDiag {

compiler/rustc_lint/src/pass_by_value.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
use crate::lints::PassByValueDiag;
14
use crate::{LateContext, LateLintPass, LintContext};
2-
use rustc_errors::{fluent, Applicability};
35
use rustc_hir as hir;
46
use rustc_hir::def::Res;
57
use rustc_hir::{GenericArg, PathSegment, QPath, TyKind};
@@ -29,20 +31,11 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
2931
}
3032
}
3133
if let Some(t) = path_for_pass_by_value(cx, &inner_ty) {
32-
cx.struct_span_lint(
34+
cx.emit_spanned_lint(
3335
PASS_BY_VALUE,
3436
ty.span,
35-
fluent::lint_pass_by_value,
36-
|lint| {
37-
lint.set_arg("ty", t.clone()).span_suggestion(
38-
ty.span,
39-
fluent::suggestion,
40-
t,
41-
// Changing type of function argument
42-
Applicability::MaybeIncorrect,
43-
)
44-
},
45-
)
37+
PassByValueDiag { ty: t.clone(), suggestion: ty.span },
38+
);
4639
}
4740
}
4841
_ => {}

0 commit comments

Comments
 (0)