@@ -43,25 +43,31 @@ pub struct DiagnosticBuilder<'a> {
43
43
/// it easy to declare such methods on the builder.
44
44
macro_rules! forward {
45
45
// Forward pattern for &self -> &Self
46
- ( pub fn $n: ident( & self , $( $name: ident: $ty: ty) ,* ) -> & Self ) => {
46
+ ( pub fn $n: ident( & self , $( $name: ident: $ty: ty) ,* $ ( , ) * ) -> & Self ) => {
47
47
pub fn $n( & self , $( $name: $ty) ,* ) -> & Self {
48
+ #[ allow( deprecated) ]
48
49
self . diagnostic. $n( $( $name) ,* ) ;
49
50
self
50
51
}
51
52
} ;
52
53
53
54
// Forward pattern for &mut self -> &mut Self
54
- ( pub fn $n: ident( & mut self , $( $name: ident: $ty: ty) ,* ) -> & mut Self ) => {
55
+ ( pub fn $n: ident( & mut self , $( $name: ident: $ty: ty) ,* $ ( , ) * ) -> & mut Self ) => {
55
56
pub fn $n( & mut self , $( $name: $ty) ,* ) -> & mut Self {
57
+ #[ allow( deprecated) ]
56
58
self . diagnostic. $n( $( $name) ,* ) ;
57
59
self
58
60
}
59
61
} ;
60
62
61
63
// Forward pattern for &mut self -> &mut Self, with S: Into<MultiSpan>
62
64
// type parameter. No obvious way to make this more generic.
63
- ( pub fn $n: ident<S : Into <MultiSpan >>( & mut self , $( $name: ident: $ty: ty) ,* ) -> & mut Self ) => {
65
+ ( pub fn $n: ident<S : Into <MultiSpan >>(
66
+ & mut self ,
67
+ $( $name: ident: $ty: ty) ,*
68
+ $( , ) * ) -> & mut Self ) => {
64
69
pub fn $n<S : Into <MultiSpan >>( & mut self , $( $name: $ty) ,* ) -> & mut Self {
70
+ #[ allow( deprecated) ]
65
71
self . diagnostic. $n( $( $name) ,* ) ;
66
72
self
67
73
}
@@ -157,49 +163,75 @@ impl<'a> DiagnosticBuilder<'a> {
157
163
forward ! ( pub fn note_expected_found( & mut self ,
158
164
label: & dyn fmt:: Display ,
159
165
expected: DiagnosticStyledString ,
160
- found: DiagnosticStyledString )
161
- -> & mut Self ) ;
166
+ found: DiagnosticStyledString ,
167
+ ) -> & mut Self ) ;
162
168
163
169
forward ! ( pub fn note_expected_found_extra( & mut self ,
164
170
label: & dyn fmt:: Display ,
165
171
expected: DiagnosticStyledString ,
166
172
found: DiagnosticStyledString ,
167
173
expected_extra: & dyn fmt:: Display ,
168
- found_extra: & dyn fmt:: Display )
169
- -> & mut Self ) ;
174
+ found_extra: & dyn fmt:: Display ,
175
+ ) -> & mut Self ) ;
170
176
171
177
forward ! ( pub fn note( & mut self , msg: & str ) -> & mut Self ) ;
172
178
forward ! ( pub fn span_note<S : Into <MultiSpan >>( & mut self ,
173
179
sp: S ,
174
- msg: & str )
175
- -> & mut Self ) ;
180
+ msg: & str ,
181
+ ) -> & mut Self ) ;
176
182
forward ! ( pub fn warn( & mut self , msg: & str ) -> & mut Self ) ;
177
183
forward ! ( pub fn span_warn<S : Into <MultiSpan >>( & mut self , sp: S , msg: & str ) -> & mut Self ) ;
178
184
forward ! ( pub fn help( & mut self , msg: & str ) -> & mut Self ) ;
179
185
forward ! ( pub fn span_help<S : Into <MultiSpan >>( & mut self ,
180
186
sp: S ,
181
- msg: & str )
182
- -> & mut Self ) ;
183
- forward ! ( pub fn span_suggestion_short( & mut self ,
184
- sp: Span ,
185
- msg: & str ,
186
- suggestion: String )
187
- -> & mut Self ) ;
187
+ msg: & str ,
188
+ ) -> & mut Self ) ;
189
+
190
+ #[ deprecated( note = "Use `span_suggestion_short_with_applicability`" ) ]
191
+ forward ! ( pub fn span_suggestion_short(
192
+ & mut self ,
193
+ sp: Span ,
194
+ msg: & str ,
195
+ suggestion: String ,
196
+ ) -> & mut Self ) ;
197
+
198
+ #[ deprecated( note = "Use `multipart_suggestion_with_applicability`" ) ]
188
199
forward ! ( pub fn multipart_suggestion(
189
200
& mut self ,
190
201
msg: & str ,
191
- suggestion: Vec <( Span , String ) >
202
+ suggestion: Vec <( Span , String ) >,
192
203
) -> & mut Self ) ;
204
+
205
+ #[ deprecated( note = "Use `span_suggestion_with_applicability`" ) ]
193
206
forward ! ( pub fn span_suggestion( & mut self ,
194
207
sp: Span ,
195
208
msg: & str ,
196
- suggestion: String )
197
- -> & mut Self ) ;
209
+ suggestion: String ,
210
+ ) -> & mut Self ) ;
211
+
212
+ #[ deprecated( note = "Use `span_suggestions_with_applicability`" ) ]
198
213
forward ! ( pub fn span_suggestions( & mut self ,
199
214
sp: Span ,
200
215
msg: & str ,
201
- suggestions: Vec <String >)
202
- -> & mut Self ) ;
216
+ suggestions: Vec <String >,
217
+ ) -> & mut Self ) ;
218
+
219
+ pub fn multipart_suggestion_with_applicability ( & mut self ,
220
+ msg : & str ,
221
+ suggestion : Vec < ( Span , String ) > ,
222
+ applicability : Applicability ,
223
+ ) -> & mut Self {
224
+ if !self . allow_suggestions {
225
+ return self
226
+ }
227
+ self . diagnostic . multipart_suggestion_with_applicability (
228
+ msg,
229
+ suggestion,
230
+ applicability,
231
+ ) ;
232
+ self
233
+ }
234
+
203
235
pub fn span_suggestion_with_applicability ( & mut self ,
204
236
sp : Span ,
205
237
msg : & str ,
0 commit comments