From 0ad1c0e36901424d96c26b86ed27d03fe6c2895f Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Mon, 17 Sep 2018 02:50:00 +0300 Subject: Change diagnostic_builder's forward! macro to enforce trailing argument comma --- src/librustc_errors/diagnostic_builder.rs | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index d1b6865e59b..ce5845dc038 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -39,7 +39,7 @@ pub struct DiagnosticBuilder<'a> { /// it easy to declare such methods on the builder. macro_rules! forward { // Forward pattern for &self -> &Self - (pub fn $n:ident(&self, $($name:ident: $ty:ty),*) -> &Self) => { + (pub fn $n:ident(&self, $($name:ident: $ty:ty,)*) -> &Self) => { pub fn $n(&self, $($name: $ty),*) -> &Self { #[allow(deprecated)] self.diagnostic.$n($($name),*); @@ -48,7 +48,7 @@ macro_rules! forward { }; // Forward pattern for &mut self -> &mut Self - (pub fn $n:ident(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => { + (pub fn $n:ident(&mut self, $($name:ident: $ty:ty,)*) -> &mut Self) => { pub fn $n(&mut self, $($name: $ty),*) -> &mut Self { #[allow(deprecated)] self.diagnostic.$n($($name),*); @@ -58,8 +58,8 @@ macro_rules! forward { // Forward pattern for &mut self -> &mut Self, with S: Into // type parameter. No obvious way to make this more generic. - (pub fn $n:ident>(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => { - pub fn $n>(&mut self, $($name: $ty),*) -> &mut Self { + (pub fn $n:ident>(&mut self, $($name:ident: $ty:ty,)*) -> &mut Self) => { + pub fn $n>(&mut self, $($name: $ty,)*) -> &mut Self { #[allow(deprecated)] self.diagnostic.$n($($name),*); self @@ -147,64 +147,64 @@ impl<'a> DiagnosticBuilder<'a> { forward!(pub fn note_expected_found(&mut self, label: &dyn fmt::Display, expected: DiagnosticStyledString, - found: DiagnosticStyledString) - -> &mut Self); + found: DiagnosticStyledString, + ) -> &mut Self); forward!(pub fn note_expected_found_extra(&mut self, label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, expected_extra: &dyn fmt::Display, - found_extra: &dyn fmt::Display) - -> &mut Self); + found_extra: &dyn fmt::Display, + ) -> &mut Self); - forward!(pub fn note(&mut self, msg: &str) -> &mut Self); + forward!(pub fn note(&mut self, msg: &str,) -> &mut Self); forward!(pub fn span_note>(&mut self, sp: S, - msg: &str) - -> &mut Self); - forward!(pub fn warn(&mut self, msg: &str) -> &mut Self); - forward!(pub fn span_warn>(&mut self, sp: S, msg: &str) -> &mut Self); - forward!(pub fn help(&mut self , msg: &str) -> &mut Self); + msg: &str, + ) -> &mut Self); + forward!(pub fn warn(&mut self, msg: &str,) -> &mut Self); + forward!(pub fn span_warn>(&mut self, sp: S, msg: &str,) -> &mut Self); + forward!(pub fn help(&mut self , msg: &str,) -> &mut Self); forward!(pub fn span_help>(&mut self, sp: S, - msg: &str) - -> &mut Self); + msg: &str, + ) -> &mut Self); #[deprecated(note = "Use `span_suggestion_short_with_applicability`")] forward!(pub fn span_suggestion_short( &mut self, sp: Span, msg: &str, - suggestion: String) - -> &mut Self); + suggestion: String, + ) -> &mut Self); #[deprecated(note = "Use `multipart_suggestion_with_applicability`")] forward!(pub fn multipart_suggestion( &mut self, msg: &str, - suggestion: Vec<(Span, String)> + suggestion: Vec<(Span, String)>, ) -> &mut Self); #[deprecated(note = "Use `span_suggestion_with_applicability`")] forward!(pub fn span_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) - -> &mut Self); + suggestion: String, + ) -> &mut Self); #[deprecated(note = "Use `span_suggestions_with_applicability`")] forward!(pub fn span_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec) - -> &mut Self); + suggestions: Vec, + ) -> &mut Self); pub fn multipart_suggestion_with_applicability(&mut self, msg: &str, suggestion: Vec<(Span, String)>, - applicability: Applicability) - -> &mut Self { + applicability: Applicability, + ) -> &mut Self { if !self.allow_suggestions { return self } @@ -269,8 +269,8 @@ impl<'a> DiagnosticBuilder<'a> { ); self } - forward!(pub fn set_span>(&mut self, sp: S) -> &mut Self); - forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self); + forward!(pub fn set_span>(&mut self, sp: S,) -> &mut Self); + forward!(pub fn code(&mut self, s: DiagnosticId,) -> &mut Self); pub fn allow_suggestions(&mut self, allow: bool) -> &mut Self { self.allow_suggestions = allow; -- cgit 1.4.1-3-g733a5