diff options
Diffstat (limited to 'src/libfmt_macros/lib.rs')
| -rw-r--r-- | src/libfmt_macros/lib.rs | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 2ecbe770729..fa0021a7c73 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -4,24 +4,25 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. -#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/", - test(attr(deny(warnings))))] - +#![doc( + html_root_url = "https://doc.rust-lang.org/nightly/", + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))) +)] #![feature(nll)] #![feature(rustc_private)] #![feature(unicode_internals)] #![feature(bool_to_option)] -pub use Piece::*; -pub use Position::*; pub use Alignment::*; -pub use Flag::*; pub use Count::*; +pub use Flag::*; +pub use Piece::*; +pub use Position::*; +use std::iter; use std::str; use std::string; -use std::iter; use syntax_pos::{InnerSpan, Symbol}; @@ -219,9 +220,7 @@ impl<'a> Iterator for Parser<'a> { None } } - '\n' => { - Some(String(self.string(pos))) - } + '\n' => Some(String(self.string(pos))), _ => Some(String(self.string(pos))), } } else { @@ -272,7 +271,11 @@ impl<'a> Parser<'a> { /// Notifies of an error. The message doesn't actually need to be of type /// String, but I think it does when this eventually uses conditions so it /// might as well start using it now. - fn err_with_note<S1: Into<string::String>, S2: Into<string::String>, S3: Into<string::String>>( + fn err_with_note< + S1: Into<string::String>, + S2: Into<string::String>, + S3: Into<string::String>, + >( &mut self, description: S1, label: S2, @@ -340,10 +343,13 @@ impl<'a> Parser<'a> { let description = format!("expected `'}}'`, found `{:?}`", maybe); let label = "expected `}`".to_owned(); let (note, secondary_label) = if c == '}' { - (Some("if you intended to print `{`, you can escape it using `{{`".to_owned()), - self.last_opening_brace.map(|sp| { - ("because of this opening brace".to_owned(), sp) - })) + ( + Some( + "if you intended to print `{`, you can escape it using `{{`".to_owned(), + ), + self.last_opening_brace + .map(|sp| ("because of this opening brace".to_owned(), sp)), + ) } else { (None, None) }; @@ -364,10 +370,13 @@ impl<'a> Parser<'a> { if c == '}' { let label = format!("expected `{:?}`", c); let (note, secondary_label) = if c == '}' { - (Some("if you intended to print `{`, you can escape it using `{{`".to_owned()), - self.last_opening_brace.map(|sp| { - ("because of this opening brace".to_owned(), sp) - })) + ( + Some( + "if you intended to print `{`, you can escape it using `{{`".to_owned(), + ), + self.last_opening_brace + .map(|sp| ("because of this opening brace".to_owned(), sp)), + ) } else { (None, None) }; @@ -428,10 +437,7 @@ impl<'a> Parser<'a> { } }; - Argument { - position: pos, - format, - } + Argument { position: pos, format } } /// Parses a positional argument for a format. This could either be an @@ -517,11 +523,7 @@ impl<'a> Parser<'a> { } } if !havewidth { - let width_span_start = if let Some((pos, _)) = self.cur.peek() { - *pos - } else { - 0 - }; + let width_span_start = if let Some((pos, _)) = self.cur.peek() { *pos } else { 0 }; let (w, sp) = self.count(width_span_start); spec.width = w; spec.width_span = sp; |
