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