This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ use rustc_span::{Span, Symbol};
6
6
7
7
use crate :: LateContext ;
8
8
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
+
9
17
#[ derive( LintDiagnostic ) ]
10
18
#[ diag( lint_redundant_semicolons) ]
11
19
pub struct RedundantSemicolonsDiag {
Original file line number Diff line number Diff line change
1
+ #![ deny( rustc:: untranslatable_diagnostic) ]
2
+ #![ deny( rustc:: diagnostic_outside_of_impl) ]
3
+ use crate :: lints:: PassByValueDiag ;
1
4
use crate :: { LateContext , LateLintPass , LintContext } ;
2
- use rustc_errors:: { fluent, Applicability } ;
3
5
use rustc_hir as hir;
4
6
use rustc_hir:: def:: Res ;
5
7
use rustc_hir:: { GenericArg , PathSegment , QPath , TyKind } ;
@@ -29,20 +31,11 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
29
31
}
30
32
}
31
33
if let Some ( t) = path_for_pass_by_value ( cx, & inner_ty) {
32
- cx. struct_span_lint (
34
+ cx. emit_spanned_lint (
33
35
PASS_BY_VALUE ,
34
36
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
+ ) ;
46
39
}
47
40
}
48
41
_ => { }
You can’t perform that action at this time.
0 commit comments