Skip to content

Commit ffabd00

Browse files
authored
Rollup merge of #107180 - nvzqz:rm-fmt-ref, r=joshtriplett
Remove unnecessary `&format!` These were likely from before the `PartialEq<str>` impl for `&String`.
2 parents 6b853e1 + cf64c48 commit ffabd00

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

core/src/fmt/mod.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -1355,11 +1355,11 @@ impl<'a> Formatter<'a> {
13551355
/// }
13561356
/// }
13571357
///
1358-
/// assert_eq!(&format!("{}", Foo::new(2)), "2");
1359-
/// assert_eq!(&format!("{}", Foo::new(-1)), "-1");
1360-
/// assert_eq!(&format!("{}", Foo::new(0)), "0");
1361-
/// assert_eq!(&format!("{:#}", Foo::new(-1)), "-Foo 1");
1362-
/// assert_eq!(&format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
1358+
/// assert_eq!(format!("{}", Foo::new(2)), "2");
1359+
/// assert_eq!(format!("{}", Foo::new(-1)), "-1");
1360+
/// assert_eq!(format!("{}", Foo::new(0)), "0");
1361+
/// assert_eq!(format!("{:#}", Foo::new(-1)), "-Foo 1");
1362+
/// assert_eq!(format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
13631363
/// ```
13641364
#[stable(feature = "rust1", since = "1.0.0")]
13651365
pub fn pad_integral(&mut self, is_nonnegative: bool, prefix: &str, buf: &str) -> Result {
@@ -1452,8 +1452,8 @@ impl<'a> Formatter<'a> {
14521452
/// }
14531453
/// }
14541454
///
1455-
/// assert_eq!(&format!("{Foo:<4}"), "Foo ");
1456-
/// assert_eq!(&format!("{Foo:0>4}"), "0Foo");
1455+
/// assert_eq!(format!("{Foo:<4}"), "Foo ");
1456+
/// assert_eq!(format!("{Foo:0>4}"), "0Foo");
14571457
/// ```
14581458
#[stable(feature = "rust1", since = "1.0.0")]
14591459
pub fn pad(&mut self, s: &str) -> Result {
@@ -1636,8 +1636,8 @@ impl<'a> Formatter<'a> {
16361636
/// }
16371637
/// }
16381638
///
1639-
/// assert_eq!(&format!("{Foo}"), "Foo");
1640-
/// assert_eq!(&format!("{Foo:0>8}"), "Foo");
1639+
/// assert_eq!(format!("{Foo}"), "Foo");
1640+
/// assert_eq!(format!("{Foo:0>8}"), "Foo");
16411641
/// ```
16421642
#[stable(feature = "rust1", since = "1.0.0")]
16431643
pub fn write_str(&mut self, data: &str) -> Result {
@@ -1659,8 +1659,8 @@ impl<'a> Formatter<'a> {
16591659
/// }
16601660
/// }
16611661
///
1662-
/// assert_eq!(&format!("{}", Foo(-1)), "Foo -1");
1663-
/// assert_eq!(&format!("{:0>8}", Foo(2)), "Foo 2");
1662+
/// assert_eq!(format!("{}", Foo(-1)), "Foo -1");
1663+
/// assert_eq!(format!("{:0>8}", Foo(2)), "Foo 2");
16641664
/// ```
16651665
#[stable(feature = "rust1", since = "1.0.0")]
16661666
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result {
@@ -1703,8 +1703,8 @@ impl<'a> Formatter<'a> {
17031703
/// }
17041704
///
17051705
/// // We set alignment to the right with ">".
1706-
/// assert_eq!(&format!("{Foo:G>3}"), "GGG");
1707-
/// assert_eq!(&format!("{Foo:t>6}"), "tttttt");
1706+
/// assert_eq!(format!("{Foo:G>3}"), "GGG");
1707+
/// assert_eq!(format!("{Foo:t>6}"), "tttttt");
17081708
/// ```
17091709
#[must_use]
17101710
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1738,10 +1738,10 @@ impl<'a> Formatter<'a> {
17381738
/// }
17391739
/// }
17401740
///
1741-
/// assert_eq!(&format!("{Foo:<}"), "left");
1742-
/// assert_eq!(&format!("{Foo:>}"), "right");
1743-
/// assert_eq!(&format!("{Foo:^}"), "center");
1744-
/// assert_eq!(&format!("{Foo}"), "into the void");
1741+
/// assert_eq!(format!("{Foo:<}"), "left");
1742+
/// assert_eq!(format!("{Foo:>}"), "right");
1743+
/// assert_eq!(format!("{Foo:^}"), "center");
1744+
/// assert_eq!(format!("{Foo}"), "into the void");
17451745
/// ```
17461746
#[must_use]
17471747
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
@@ -1767,16 +1767,16 @@ impl<'a> Formatter<'a> {
17671767
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
17681768
/// if let Some(width) = formatter.width() {
17691769
/// // If we received a width, we use it
1770-
/// write!(formatter, "{:width$}", &format!("Foo({})", self.0), width = width)
1770+
/// write!(formatter, "{:width$}", format!("Foo({})", self.0), width = width)
17711771
/// } else {
17721772
/// // Otherwise we do nothing special
17731773
/// write!(formatter, "Foo({})", self.0)
17741774
/// }
17751775
/// }
17761776
/// }
17771777
///
1778-
/// assert_eq!(&format!("{:10}", Foo(23)), "Foo(23) ");
1779-
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1778+
/// assert_eq!(format!("{:10}", Foo(23)), "Foo(23) ");
1779+
/// assert_eq!(format!("{}", Foo(23)), "Foo(23)");
17801780
/// ```
17811781
#[must_use]
17821782
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1806,8 +1806,8 @@ impl<'a> Formatter<'a> {
18061806
/// }
18071807
/// }
18081808
///
1809-
/// assert_eq!(&format!("{:.4}", Foo(23.2)), "Foo(23.2000)");
1810-
/// assert_eq!(&format!("{}", Foo(23.2)), "Foo(23.20)");
1809+
/// assert_eq!(format!("{:.4}", Foo(23.2)), "Foo(23.2000)");
1810+
/// assert_eq!(format!("{}", Foo(23.2)), "Foo(23.20)");
18111811
/// ```
18121812
#[must_use]
18131813
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1837,9 +1837,9 @@ impl<'a> Formatter<'a> {
18371837
/// }
18381838
/// }
18391839
///
1840-
/// assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)");
1841-
/// assert_eq!(&format!("{:+}", Foo(-23)), "Foo(-23)");
1842-
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1840+
/// assert_eq!(format!("{:+}", Foo(23)), "Foo(+23)");
1841+
/// assert_eq!(format!("{:+}", Foo(-23)), "Foo(-23)");
1842+
/// assert_eq!(format!("{}", Foo(23)), "Foo(23)");
18431843
/// ```
18441844
#[must_use]
18451845
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1867,8 +1867,8 @@ impl<'a> Formatter<'a> {
18671867
/// }
18681868
/// }
18691869
///
1870-
/// assert_eq!(&format!("{:-}", Foo(23)), "-Foo(23)");
1871-
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1870+
/// assert_eq!(format!("{:-}", Foo(23)), "-Foo(23)");
1871+
/// assert_eq!(format!("{}", Foo(23)), "Foo(23)");
18721872
/// ```
18731873
#[must_use]
18741874
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1895,8 +1895,8 @@ impl<'a> Formatter<'a> {
18951895
/// }
18961896
/// }
18971897
///
1898-
/// assert_eq!(&format!("{:#}", Foo(23)), "Foo(23)");
1899-
/// assert_eq!(&format!("{}", Foo(23)), "23");
1898+
/// assert_eq!(format!("{:#}", Foo(23)), "Foo(23)");
1899+
/// assert_eq!(format!("{}", Foo(23)), "23");
19001900
/// ```
19011901
#[must_use]
19021902
#[stable(feature = "fmt_flags", since = "1.5.0")]
@@ -1922,7 +1922,7 @@ impl<'a> Formatter<'a> {
19221922
/// }
19231923
/// }
19241924
///
1925-
/// assert_eq!(&format!("{:04}", Foo(23)), "23");
1925+
/// assert_eq!(format!("{:04}", Foo(23)), "23");
19261926
/// ```
19271927
#[must_use]
19281928
#[stable(feature = "fmt_flags", since = "1.5.0")]

core/tests/num/dec2flt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ macro_rules! test_literal {
1515
for input in inputs {
1616
assert_eq!(input.parse(), Ok(x64));
1717
assert_eq!(input.parse(), Ok(x32));
18-
let neg_input = &format!("-{input}");
18+
let neg_input = format!("-{input}");
1919
assert_eq!(neg_input.parse(), Ok(-x64));
2020
assert_eq!(neg_input.parse(), Ok(-x32));
2121
}

portable-simd/crates/core_simd/examples/spectral_norm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn dot(x: &[f64], y: &[f64]) -> f64 {
6969
#[cfg(test)]
7070
#[test]
7171
fn test() {
72-
assert_eq!(&format!("{:.9}", spectral_norm(100)), "1.274219991");
72+
assert_eq!(format!("{:.9}", spectral_norm(100)), "1.274219991");
7373
}
7474

7575
fn main() {

std/src/io/error/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,5 @@ fn test_std_io_error_downcast() {
190190
let io_error = io_error.downcast::<E>().unwrap_err();
191191

192192
assert_eq!(SIMPLE_MESSAGE.kind, io_error.kind());
193-
assert_eq!(SIMPLE_MESSAGE.message, &*format!("{io_error}"));
193+
assert_eq!(SIMPLE_MESSAGE.message, format!("{io_error}"));
194194
}

std/src/net/ip_addr/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ fn ipv4_addr_to_string() {
125125
assert_eq!(Ipv4Addr::new(127, 127, 127, 127).to_string(), "127.127.127.127");
126126

127127
// Test padding
128-
assert_eq!(&format!("{:16}", Ipv4Addr::new(1, 1, 1, 1)), "1.1.1.1 ");
129-
assert_eq!(&format!("{:>16}", Ipv4Addr::new(1, 1, 1, 1)), " 1.1.1.1");
128+
assert_eq!(format!("{:16}", Ipv4Addr::new(1, 1, 1, 1)), "1.1.1.1 ");
129+
assert_eq!(format!("{:>16}", Ipv4Addr::new(1, 1, 1, 1)), " 1.1.1.1");
130130
}
131131

132132
#[test]
@@ -148,8 +148,8 @@ fn ipv6_addr_to_string() {
148148
"1111:2222:3333:4444:5555:6666:7777:8888"
149149
);
150150
// padding
151-
assert_eq!(&format!("{:20}", Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8)), "1:2:3:4:5:6:7:8 ");
152-
assert_eq!(&format!("{:>20}", Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8)), " 1:2:3:4:5:6:7:8");
151+
assert_eq!(format!("{:20}", Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8)), "1:2:3:4:5:6:7:8 ");
152+
assert_eq!(format!("{:>20}", Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8)), " 1:2:3:4:5:6:7:8");
153153

154154
// reduce a single run of zeros
155155
assert_eq!(

std/src/net/socket_addr/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ fn ipv4_socket_addr_to_string() {
6464

6565
// Test padding.
6666
assert_eq!(
67-
&format!("{:16}", SocketAddrV4::new(Ipv4Addr::new(1, 1, 1, 1), 53)),
67+
format!("{:16}", SocketAddrV4::new(Ipv4Addr::new(1, 1, 1, 1), 53)),
6868
"1.1.1.1:53 "
6969
);
7070
assert_eq!(
71-
&format!("{:>16}", SocketAddrV4::new(Ipv4Addr::new(1, 1, 1, 1), 53)),
71+
format!("{:>16}", SocketAddrV4::new(Ipv4Addr::new(1, 1, 1, 1), 53)),
7272
" 1.1.1.1:53"
7373
);
7474
}
@@ -111,11 +111,11 @@ fn ipv6_socket_addr_to_string() {
111111

112112
// Test padding.
113113
assert_eq!(
114-
&format!("{:22}", SocketAddrV6::new(Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8), 9, 0, 0)),
114+
format!("{:22}", SocketAddrV6::new(Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8), 9, 0, 0)),
115115
"[1:2:3:4:5:6:7:8]:9 "
116116
);
117117
assert_eq!(
118-
&format!("{:>22}", SocketAddrV6::new(Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8), 9, 0, 0)),
118+
format!("{:>22}", SocketAddrV6::new(Ipv6Addr::new(1, 2, 3, 4, 5, 6, 7, 8), 9, 0, 0)),
119119
" [1:2:3:4:5:6:7:8]:9"
120120
);
121121
}

0 commit comments

Comments
 (0)