diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-03-10 23:12:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-10 23:12:57 +0100 |
| commit | 5a7f09d9a3e56e2370731d1cdab78cbcb3451d0f (patch) | |
| tree | 4ccb38378fa7d42b4a8a9d4ab0e47ae5078da385 /compiler | |
| parent | 5f4e0677190b82e61dc507e3e72caf89da8e5e28 (diff) | |
| parent | 72a25d05bf1a4b155d74139ef700ff93af6d8e22 (diff) | |
| download | rust-5a7f09d9a3e56e2370731d1cdab78cbcb3451d0f.tar.gz rust-5a7f09d9a3e56e2370731d1cdab78cbcb3451d0f.zip | |
Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum
Use modern formatting for format! macros
This updates the standard library's documentation to use the new format_args 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).
`eprintln!("{}", e)` becomes `eprintln!("{e}")`, but `eprintln!("{}", e.kind())` remains untouched.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/closure.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/upvar.rs | 6 |
4 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 217d3ec2c24..3641c38f9dc 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1087,12 +1087,12 @@ impl HandlerInner { let warnings = match self.deduplicated_warn_count { 0 => String::new(), 1 => "1 warning emitted".to_string(), - count => format!("{} warnings emitted", count), + count => format!("{count} warnings emitted"), }; let errors = match self.deduplicated_err_count { 0 => String::new(), 1 => "aborting due to previous error".to_string(), - count => format!("aborting due to {} previous errors", count), + count => format!("aborting due to {count} previous errors"), }; if self.treat_err_as_bug() { return; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 04a339f3c95..0f80ccaf6ad 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3399,7 +3399,7 @@ declare_lint! { /// // ^^^^^^^^ /// // This call to try_into matches both Foo:try_into and TryInto::try_into as /// // `TryInto` has been added to the Rust prelude in 2021 edition. - /// println!("{}", x); + /// println!("{x}"); /// } /// ``` /// diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index 8ba6c1f67c9..65a60dd6b9d 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -281,7 +281,7 @@ pub struct CaptureInfo { /// let mut t = (0,1); /// /// let c = || { - /// println!("{}",t); // L1 + /// println!("{t}"); // L1 /// t.1 = 4; // L2 /// }; /// ``` diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 2b5ff11501a..a2c79c69032 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -458,10 +458,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// let s: String; // hir_id_s /// let mut p: Point; // his_id_p /// let c = || { - /// println!("{}", s); // L1 + /// println!("{s}"); // L1 /// p.x += 10; // L2 - /// println!("{}" , p.y) // L3 - /// println!("{}", p) // L4 + /// println!("{}" , p.y); // L3 + /// println!("{p}"); // L4 /// drop(s); // L5 /// }; /// ``` |
