Skip to content

Commit 0ad1c0e

Browse files
committed
Change diagnostic_builder's forward! macro to enforce trailing argument comma
1 parent 6ebb916 commit 0ad1c0e

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/librustc_errors/diagnostic_builder.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct DiagnosticBuilder<'a> {
3939
/// it easy to declare such methods on the builder.
4040
macro_rules! forward {
4141
// Forward pattern for &self -> &Self
42-
(pub fn $n:ident(&self, $($name:ident: $ty:ty),*) -> &Self) => {
42+
(pub fn $n:ident(&self, $($name:ident: $ty:ty,)*) -> &Self) => {
4343
pub fn $n(&self, $($name: $ty),*) -> &Self {
4444
#[allow(deprecated)]
4545
self.diagnostic.$n($($name),*);
@@ -48,7 +48,7 @@ macro_rules! forward {
4848
};
4949

5050
// Forward pattern for &mut self -> &mut Self
51-
(pub fn $n:ident(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => {
51+
(pub fn $n:ident(&mut self, $($name:ident: $ty:ty,)*) -> &mut Self) => {
5252
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
5353
#[allow(deprecated)]
5454
self.diagnostic.$n($($name),*);
@@ -58,8 +58,8 @@ macro_rules! forward {
5858

5959
// Forward pattern for &mut self -> &mut Self, with S: Into<MultiSpan>
6060
// type parameter. No obvious way to make this more generic.
61-
(pub fn $n:ident<S: Into<MultiSpan>>(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => {
62-
pub fn $n<S: Into<MultiSpan>>(&mut self, $($name: $ty),*) -> &mut Self {
61+
(pub fn $n:ident<S: Into<MultiSpan>>(&mut self, $($name:ident: $ty:ty,)*) -> &mut Self) => {
62+
pub fn $n<S: Into<MultiSpan>>(&mut self, $($name: $ty,)*) -> &mut Self {
6363
#[allow(deprecated)]
6464
self.diagnostic.$n($($name),*);
6565
self
@@ -147,64 +147,64 @@ impl<'a> DiagnosticBuilder<'a> {
147147
forward!(pub fn note_expected_found(&mut self,
148148
label: &dyn fmt::Display,
149149
expected: DiagnosticStyledString,
150-
found: DiagnosticStyledString)
151-
-> &mut Self);
150+
found: DiagnosticStyledString,
151+
) -> &mut Self);
152152

153153
forward!(pub fn note_expected_found_extra(&mut self,
154154
label: &dyn fmt::Display,
155155
expected: DiagnosticStyledString,
156156
found: DiagnosticStyledString,
157157
expected_extra: &dyn fmt::Display,
158-
found_extra: &dyn fmt::Display)
159-
-> &mut Self);
158+
found_extra: &dyn fmt::Display,
159+
) -> &mut Self);
160160

161-
forward!(pub fn note(&mut self, msg: &str) -> &mut Self);
161+
forward!(pub fn note(&mut self, msg: &str,) -> &mut Self);
162162
forward!(pub fn span_note<S: Into<MultiSpan>>(&mut self,
163163
sp: S,
164-
msg: &str)
165-
-> &mut Self);
166-
forward!(pub fn warn(&mut self, msg: &str) -> &mut Self);
167-
forward!(pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self);
168-
forward!(pub fn help(&mut self , msg: &str) -> &mut Self);
164+
msg: &str,
165+
) -> &mut Self);
166+
forward!(pub fn warn(&mut self, msg: &str,) -> &mut Self);
167+
forward!(pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str,) -> &mut Self);
168+
forward!(pub fn help(&mut self , msg: &str,) -> &mut Self);
169169
forward!(pub fn span_help<S: Into<MultiSpan>>(&mut self,
170170
sp: S,
171-
msg: &str)
172-
-> &mut Self);
171+
msg: &str,
172+
) -> &mut Self);
173173

174174
#[deprecated(note = "Use `span_suggestion_short_with_applicability`")]
175175
forward!(pub fn span_suggestion_short(
176176
&mut self,
177177
sp: Span,
178178
msg: &str,
179-
suggestion: String)
180-
-> &mut Self);
179+
suggestion: String,
180+
) -> &mut Self);
181181

182182
#[deprecated(note = "Use `multipart_suggestion_with_applicability`")]
183183
forward!(pub fn multipart_suggestion(
184184
&mut self,
185185
msg: &str,
186-
suggestion: Vec<(Span, String)>
186+
suggestion: Vec<(Span, String)>,
187187
) -> &mut Self);
188188

189189
#[deprecated(note = "Use `span_suggestion_with_applicability`")]
190190
forward!(pub fn span_suggestion(&mut self,
191191
sp: Span,
192192
msg: &str,
193-
suggestion: String)
194-
-> &mut Self);
193+
suggestion: String,
194+
) -> &mut Self);
195195

196196
#[deprecated(note = "Use `span_suggestions_with_applicability`")]
197197
forward!(pub fn span_suggestions(&mut self,
198198
sp: Span,
199199
msg: &str,
200-
suggestions: Vec<String>)
201-
-> &mut Self);
200+
suggestions: Vec<String>,
201+
) -> &mut Self);
202202

203203
pub fn multipart_suggestion_with_applicability(&mut self,
204204
msg: &str,
205205
suggestion: Vec<(Span, String)>,
206-
applicability: Applicability)
207-
-> &mut Self {
206+
applicability: Applicability,
207+
) -> &mut Self {
208208
if !self.allow_suggestions {
209209
return self
210210
}
@@ -269,8 +269,8 @@ impl<'a> DiagnosticBuilder<'a> {
269269
);
270270
self
271271
}
272-
forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self);
273-
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
272+
forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S,) -> &mut Self);
273+
forward!(pub fn code(&mut self, s: DiagnosticId,) -> &mut Self);
274274

275275
pub fn allow_suggestions(&mut self, allow: bool) -> &mut Self {
276276
self.allow_suggestions = allow;

0 commit comments

Comments
 (0)