@@ -47,10 +47,9 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
47
47
/// | ^^^^^^^^^^^^^^^^^^^^^^^
48
48
/// ```
49
49
pub fn span_lint < T : LintContext > ( cx : & T , lint : & ' static Lint , sp : impl Into < MultiSpan > , msg : & str ) {
50
- cx. struct_span_lint ( lint, sp, |diag| {
51
- let mut diag = diag. build ( msg) ;
52
- docs_link ( & mut diag, lint) ;
53
- diag. emit ( ) ;
50
+ cx. struct_span_lint ( lint, sp, msg, |diag| {
51
+ docs_link ( diag, lint) ;
52
+ diag
54
53
} ) ;
55
54
}
56
55
@@ -82,15 +81,14 @@ pub fn span_lint_and_help<'a, T: LintContext>(
82
81
help_span : Option < Span > ,
83
82
help : & str ,
84
83
) {
85
- cx. struct_span_lint ( lint, span, |diag| {
86
- let mut diag = diag. build ( msg) ;
84
+ cx. struct_span_lint ( lint, span, msg, |diag| {
87
85
if let Some ( help_span) = help_span {
88
86
diag. span_help ( help_span, help) ;
89
87
} else {
90
88
diag. help ( help) ;
91
89
}
92
- docs_link ( & mut diag, lint) ;
93
- diag. emit ( ) ;
90
+ docs_link ( diag, lint) ;
91
+ diag
94
92
} ) ;
95
93
}
96
94
@@ -125,15 +123,14 @@ pub fn span_lint_and_note<'a, T: LintContext>(
125
123
note_span : Option < Span > ,
126
124
note : & str ,
127
125
) {
128
- cx. struct_span_lint ( lint, span, |diag| {
129
- let mut diag = diag. build ( msg) ;
126
+ cx. struct_span_lint ( lint, span, msg, |diag| {
130
127
if let Some ( note_span) = note_span {
131
128
diag. span_note ( note_span, note) ;
132
129
} else {
133
130
diag. note ( note) ;
134
131
}
135
- docs_link ( & mut diag, lint) ;
136
- diag. emit ( ) ;
132
+ docs_link ( diag, lint) ;
133
+ diag
137
134
} ) ;
138
135
}
139
136
@@ -147,19 +144,17 @@ where
147
144
S : Into < MultiSpan > ,
148
145
F : FnOnce ( & mut Diagnostic ) ,
149
146
{
150
- cx. struct_span_lint ( lint, sp, |diag| {
151
- let mut diag = diag. build ( msg) ;
152
- f ( & mut diag) ;
153
- docs_link ( & mut diag, lint) ;
154
- diag. emit ( ) ;
147
+ cx. struct_span_lint ( lint, sp, msg, |diag| {
148
+ f ( diag) ;
149
+ docs_link ( diag, lint) ;
150
+ diag
155
151
} ) ;
156
152
}
157
153
158
154
pub fn span_lint_hir ( cx : & LateContext < ' _ > , lint : & ' static Lint , hir_id : HirId , sp : Span , msg : & str ) {
159
- cx. tcx . struct_span_lint_hir ( lint, hir_id, sp, |diag| {
160
- let mut diag = diag. build ( msg) ;
161
- docs_link ( & mut diag, lint) ;
162
- diag. emit ( ) ;
155
+ cx. tcx . struct_span_lint_hir ( lint, hir_id, sp, msg, |diag| {
156
+ docs_link ( diag, lint) ;
157
+ diag
163
158
} ) ;
164
159
}
165
160
@@ -171,11 +166,10 @@ pub fn span_lint_hir_and_then(
171
166
msg : & str ,
172
167
f : impl FnOnce ( & mut Diagnostic ) ,
173
168
) {
174
- cx. tcx . struct_span_lint_hir ( lint, hir_id, sp, |diag| {
175
- let mut diag = diag. build ( msg) ;
176
- f ( & mut diag) ;
177
- docs_link ( & mut diag, lint) ;
178
- diag. emit ( ) ;
169
+ cx. tcx . struct_span_lint_hir ( lint, hir_id, sp, msg, |diag| {
170
+ f ( diag) ;
171
+ docs_link ( diag, lint) ;
172
+ diag
179
173
} ) ;
180
174
}
181
175
0 commit comments