]> git.lizzy.rs Git - rust.git/blobdiff - src/libfmt_macros/lib.rs
Auto merge of #67689 - mark-i-m:update-guide, r=JohnTitor
[rust.git] / src / libfmt_macros / lib.rs
index 2ecbe770729b5b278f21213df8902e31104ef224..9ca7eee999fe0493b3f4f44421123ae32b797a6d 100644 (file)
@@ -4,26 +4,27 @@
 //! 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};
+use rustc_span::{InnerSpan, Symbol};
 
 #[derive(Copy, Clone)]
 struct InnerOffset(usize);
@@ -219,9 +220,7 @@ fn next(&mut self) -> Option<Piece<'a>> {
                         None
                     }
                 }
-                '\n' => {
-                    Some(String(self.string(pos)))
-                }
+                '\n' => Some(String(self.string(pos))),
                 _ => Some(String(self.string(pos))),
             }
         } else {
@@ -272,7 +271,11 @@ fn err<S1: Into<string::String>, S2: Into<string::String>>(
     /// 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 @@ fn must_consume(&mut self, c: char) -> Option<usize> {
                 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 @@ fn must_consume(&mut self, c: char) -> Option<usize> {
             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 @@ fn argument(&mut self) -> Argument<'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 @@ fn format(&mut self) -> FormatSpec<'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;