@@ -43,25 +43,31 @@ pub struct DiagnosticBuilder<'a> {
4343/// it easy to declare such methods on the builder.
4444macro_rules! forward {
4545 // 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 ) => {
4747 pub fn $n( & self , $( $name: $ty) ,* ) -> & Self {
48+ #[ allow( deprecated) ]
4849 self . diagnostic. $n( $( $name) ,* ) ;
4950 self
5051 }
5152 } ;
5253
5354 // 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 ) => {
5556 pub fn $n( & mut self , $( $name: $ty) ,* ) -> & mut Self {
57+ #[ allow( deprecated) ]
5658 self . diagnostic. $n( $( $name) ,* ) ;
5759 self
5860 }
5961 } ;
6062
6163 // Forward pattern for &mut self -> &mut Self, with S: Into<MultiSpan>
6264 // 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 ) => {
6469 pub fn $n<S : Into <MultiSpan >>( & mut self , $( $name: $ty) ,* ) -> & mut Self {
70+ #[ allow( deprecated) ]
6571 self . diagnostic. $n( $( $name) ,* ) ;
6672 self
6773 }
@@ -157,49 +163,75 @@ impl<'a> DiagnosticBuilder<'a> {
157163 forward ! ( pub fn note_expected_found( & mut self ,
158164 label: & dyn fmt:: Display ,
159165 expected: DiagnosticStyledString ,
160- found: DiagnosticStyledString )
161- -> & mut Self ) ;
166+ found: DiagnosticStyledString ,
167+ ) -> & mut Self ) ;
162168
163169 forward ! ( pub fn note_expected_found_extra( & mut self ,
164170 label: & dyn fmt:: Display ,
165171 expected: DiagnosticStyledString ,
166172 found: DiagnosticStyledString ,
167173 expected_extra: & dyn fmt:: Display ,
168- found_extra: & dyn fmt:: Display )
169- -> & mut Self ) ;
174+ found_extra: & dyn fmt:: Display ,
175+ ) -> & mut Self ) ;
170176
171177 forward ! ( pub fn note( & mut self , msg: & str ) -> & mut Self ) ;
172178 forward ! ( pub fn span_note<S : Into <MultiSpan >>( & mut self ,
173179 sp: S ,
174- msg: & str )
175- -> & mut Self ) ;
180+ msg: & str ,
181+ ) -> & mut Self ) ;
176182 forward ! ( pub fn warn( & mut self , msg: & str ) -> & mut Self ) ;
177183 forward ! ( pub fn span_warn<S : Into <MultiSpan >>( & mut self , sp: S , msg: & str ) -> & mut Self ) ;
178184 forward ! ( pub fn help( & mut self , msg: & str ) -> & mut Self ) ;
179185 forward ! ( pub fn span_help<S : Into <MultiSpan >>( & mut self ,
180186 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`" ) ]
188199 forward ! ( pub fn multipart_suggestion(
189200 & mut self ,
190201 msg: & str ,
191- suggestion: Vec <( Span , String ) >
202+ suggestion: Vec <( Span , String ) >,
192203 ) -> & mut Self ) ;
204+
205+ #[ deprecated( note = "Use `span_suggestion_with_applicability`" ) ]
193206 forward ! ( pub fn span_suggestion( & mut self ,
194207 sp: Span ,
195208 msg: & str ,
196- suggestion: String )
197- -> & mut Self ) ;
209+ suggestion: String ,
210+ ) -> & mut Self ) ;
211+
212+ #[ deprecated( note = "Use `span_suggestions_with_applicability`" ) ]
198213 forward ! ( pub fn span_suggestions( & mut self ,
199214 sp: Span ,
200215 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+
203235 pub fn span_suggestion_with_applicability ( & mut self ,
204236 sp : Span ,
205237 msg : & str ,
0 commit comments