about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorT-O-R-U-S <bageliq@protonmail.com>2022-02-12 23:16:17 +0400
committerMark Rousskov <mark.simulacrum@gmail.com>2022-03-10 10:23:40 -0500
commit72a25d05bf1a4b155d74139ef700ff93af6d8e22 (patch)
tree3f143b29a3a51b68e9b29d93e47fb0b0968ad3df /src/librustdoc
parentba14a836c7038da21f5e102aacc7e6d5964f79a6 (diff)
downloadrust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.tar.gz
rust-72a25d05bf1a4b155d74139ef700ff93af6d8e22.zip
Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The
documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.

A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/clean/mod.rs2
-rw-r--r--src/librustdoc/doctest.rs39
-rw-r--r--src/librustdoc/html/markdown.rs2
-rw-r--r--src/librustdoc/markdown.rs2
4 files changed, 22 insertions, 23 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 29c11c7b28a..fa0030a9360 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -829,7 +829,7 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
                             .values
                             .insert(a as _, Argument { name, type_: *ty, is_const: true });
                     } else {
-                        panic!("unexpected non const in position {}", pos);
+                        panic!("unexpected non const in position {pos}");
                     }
                 }
                 _ => panic!("invalid arg index"),
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 63a8e85f7c5..e9efeba0299 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -197,7 +197,7 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
                 .to_string();
             let uext = UnusedExterns { lint_level, unused_extern_names };
             let unused_extern_json = serde_json::to_string(&uext).unwrap();
-            eprintln!("{}", unused_extern_json);
+            eprintln!("{unused_extern_json}");
         }
     }
 
@@ -430,7 +430,7 @@ fn run_test(
                 // We used to check if the output contained "error[{}]: " but since we added the
                 // colored output, we can't anymore because of the color escape characters before
                 // the ":".
-                lang_string.error_codes.retain(|err| !out.contains(&format!("error[{}]", err)));
+                lang_string.error_codes.retain(|err| !out.contains(&format!("error[{err}]")));
 
                 if !lang_string.error_codes.is_empty() {
                     return Err(TestFailure::MissingErrorCodes(lang_string.error_codes));
@@ -510,7 +510,7 @@ crate fn make_test(
 
     // Next, any attributes that came from the crate root via #![doc(test(attr(...)))].
     for attr in &opts.attrs {
-        prog.push_str(&format!("#![{}]\n", attr));
+        prog.push_str(&format!("#![{attr}]\n"));
         line_offset += 1;
     }
 
@@ -647,7 +647,7 @@ crate fn make_test(
             // parse the source, but only has false positives, not false
             // negatives.
             if s.contains(crate_name) {
-                prog.push_str(&format!("extern crate r#{};\n", crate_name));
+                prog.push_str(&format!("extern crate r#{crate_name};\n"));
                 line_offset += 1;
             }
         }
@@ -661,7 +661,7 @@ crate fn make_test(
         // Give each doctest main function a unique name.
         // This is for example needed for the tooling around `-C instrument-coverage`.
         let inner_fn_name = if let Some(test_id) = test_id {
-            format!("_doctest_main_{}", test_id)
+            format!("_doctest_main_{test_id}")
         } else {
             "_inner".into()
         };
@@ -669,15 +669,14 @@ crate fn make_test(
         let (main_pre, main_post) = if returns_result {
             (
                 format!(
-                    "fn main() {{ {}fn {}() -> Result<(), impl core::fmt::Debug> {{\n",
-                    inner_attr, inner_fn_name
+                    "fn main() {{ {inner_attr}fn {inner_fn_name}() -> Result<(), impl core::fmt::Debug> {{\n",
                 ),
-                format!("\n}} {}().unwrap() }}", inner_fn_name),
+                format!("\n}} {inner_fn_name}().unwrap() }}"),
             )
         } else if test_id.is_some() {
             (
-                format!("fn main() {{ {}fn {}() {{\n", inner_attr, inner_fn_name),
-                format!("\n}} {}() }}", inner_fn_name),
+                format!("fn main() {{ {inner_attr}fn {inner_fn_name}() {{\n",),
+                format!("\n}} {inner_fn_name}() }}"),
             )
         } else {
             ("fn main() {\n".into(), "\n}".into())
@@ -695,7 +694,7 @@ crate fn make_test(
         prog.extend([&main_pre, everything_else, &main_post].iter().cloned());
     }
 
-    debug!("final doctest:\n{}", prog);
+    debug!("final doctest:\n{prog}");
 
     (prog, line_offset, supports_color)
 }
@@ -763,9 +762,9 @@ fn partition_source(s: &str) -> (String, String, String) {
         }
     }
 
-    debug!("before:\n{}", before);
-    debug!("crates:\n{}", crates);
-    debug!("after:\n{}", after);
+    debug!("before:\n{before}");
+    debug!("crates:\n{crates}");
+    debug!("after:\n{after}");
 
     (before, after, crates)
 }
@@ -940,7 +939,7 @@ impl Tester for Collector {
             )
         };
 
-        debug!("creating test {}: {}", name, test);
+        debug!("creating test {name}: {test}");
         self.tests.push(test::TestDescAndFn {
             desc: test::TestDesc {
                 name: test::DynTestName(name),
@@ -994,19 +993,19 @@ impl Tester for Collector {
                             eprint!("Some expected error codes were not found: {:?}", codes);
                         }
                         TestFailure::ExecutionError(err) => {
-                            eprint!("Couldn't run the test: {}", err);
+                            eprint!("Couldn't run the test: {err}");
                             if err.kind() == io::ErrorKind::PermissionDenied {
                                 eprint!(" - maybe your tempdir is mounted with noexec?");
                             }
                         }
                         TestFailure::ExecutionFailure(out) => {
                             let reason = if let Some(code) = out.status.code() {
-                                format!("exit code {}", code)
+                                format!("exit code {code}")
                             } else {
                                 String::from("terminated by signal")
                             };
 
-                            eprintln!("Test executable failed ({}).", reason);
+                            eprintln!("Test executable failed ({reason}).");
 
                             // FIXME(#12309): An unfortunate side-effect of capturing the test
                             // executable's output is that the relative ordering between the test's
@@ -1024,11 +1023,11 @@ impl Tester for Collector {
                                 eprintln!();
 
                                 if !stdout.is_empty() {
-                                    eprintln!("stdout:\n{}", stdout);
+                                    eprintln!("stdout:\n{stdout}");
                                 }
 
                                 if !stderr.is_empty() {
-                                    eprintln!("stderr:\n{}", stderr);
+                                    eprintln!("stderr:\n{stderr}");
                                 }
                             }
                         }
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 7061a9674e4..98dc625b36d 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -1314,7 +1314,7 @@ crate fn markdown_links(md: &str) -> Vec<MarkdownLink> {
 
     for ev in iter {
         if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 {
-            debug!("found link: {}", dest);
+            debug!("found link: {dest}");
             let span = span_for_link(&dest, ev.1);
             links.borrow_mut().push(MarkdownLink { kind, link: dest.into_string(), range: span });
         }
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs
index 906b8f8a245..a1f92afad46 100644
--- a/src/librustdoc/markdown.rs
+++ b/src/librustdoc/markdown.rs
@@ -51,7 +51,7 @@ crate fn render<P: AsRef<Path>>(
 
     let mut css = String::new();
     for name in &options.markdown_css {
-        let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n", name);
+        let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{name}\">\n");
         css.push_str(&s)
     }