Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obk · model-checking/verify-rust-std@895175a (original) (raw)
7 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1796,18 +1796,18 @@ fn test_ord_absence() { | ||
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | fn map_debug<K: Debug>(mut map: BTreeMap<K, ()>) { |
1799 | -format!("{map:?}"); | |
1800 | -format!("{:?}", map.iter()); | |
1801 | -format!("{:?}", map.iter_mut()); | |
1802 | -format!("{:?}", map.keys()); | |
1803 | -format!("{:?}", map.values()); | |
1804 | -format!("{:?}", map.values_mut()); | |
1799 | +let _ = format!("{map:?}"); | |
1800 | +let _ = format!("{:?}", map.iter()); | |
1801 | +let _ = format!("{:?}", map.iter_mut()); | |
1802 | +let _ = format!("{:?}", map.keys()); | |
1803 | +let _ = format!("{:?}", map.values()); | |
1804 | +let _ = format!("{:?}", map.values_mut()); | |
1805 | 1805 | if true { |
1806 | -format!("{:?}", map.into_iter()); | |
1806 | +let _ = format!("{:?}", map.into_iter()); | |
1807 | 1807 | } else if true { |
1808 | -format!("{:?}", map.into_keys()); | |
1808 | +let _ = format!("{:?}", map.into_keys()); | |
1809 | 1809 | } else { |
1810 | -format!("{:?}", map.into_values()); | |
1810 | +let _ = format!("{:?}", map.into_values()); | |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -705,9 +705,9 @@ fn test_ord_absence() { | ||
705 | 705 | } |
706 | 706 | |
707 | 707 | fn set_debug<K: Debug>(set: BTreeSet<K>) { |
708 | -format!("{set:?}"); | |
709 | -format!("{:?}", set.iter()); | |
710 | -format!("{:?}", set.into_iter()); | |
708 | +let _ = format!("{set:?}"); | |
709 | +let _ = format!("{:?}", set.iter()); | |
710 | +let _ = format!("{:?}", set.into_iter()); | |
711 | 711 | } |
712 | 712 | |
713 | 713 | fn set_clone<K: Clone>(mut set: BTreeSet<K>) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,6 +12,7 @@ | ||
12 | 12 | //! Some examples of the [`format!`] extension are: |
13 | 13 | //! |
14 | 14 | //! ``` |
15 | +//! # #![allow(unused_must_use)] | |
15 | 16 | //! format!("Hello"); // => "Hello" |
16 | 17 | //! format!("Hello, {}!", "world"); // => "Hello, world!" |
17 | 18 | //! format!("The number is {}", 1); // => "The number is 1" |
@@ -50,6 +51,7 @@ | ||
50 | 51 | //! the iterator advances. This leads to behavior like this: |
51 | 52 | //! |
52 | 53 | //! ``` |
54 | +//! # #![allow(unused_must_use)] | |
53 | 55 | //! format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2" |
54 | 56 | //! ``` |
55 | 57 | //! |
@@ -77,6 +79,7 @@ | ||
77 | 79 | //! For example, the following [`format!`] expressions all use named arguments: |
78 | 80 | //! |
79 | 81 | //! ``` |
82 | +//! # #![allow(unused_must_use)] | |
80 | 83 | //! format!("{argument}", argument = "test"); // => "test" |
81 | 84 | //! format!("{name} {}", 1, name = 2); // => "2 1" |
82 | 85 | //! format!("{a} {c} {b}", a="a", b='b', c=3); // => "a 3 b" |
@@ -86,6 +89,7 @@ | ||
86 | 89 | //! reference a variable with that name in the current scope. |
87 | 90 | //! |
88 | 91 | //! ``` |
92 | +//! # #![allow(unused_must_use)] | |
89 | 93 | //! let argument = 2 + 2; |
90 | 94 | //! format!("{argument}"); // => "4" |
91 | 95 | //! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -257,6 +257,7 @@ pub mod vec; | ||
257 | 257 | #[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")] |
258 | 258 | pub mod __export { |
259 | 259 | pub use core::format_args; |
260 | +pub use core::hint::must_use; | |
260 | 261 | } |
261 | 262 | |
262 | 263 | #[cfg(test)] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -111,6 +111,7 @@ macro_rules! vec { | ||
111 | 111 | /// # Examples |
112 | 112 | /// |
113 | 113 | /// ``` |
114 | +/// # #![allow(unused_must_use)] | |
114 | 115 | /// format!("test"); // => "test" |
115 | 116 | /// format!("hello {}", "world!"); // => "hello world!" |
116 | 117 | /// format!("x = {}, y = {val}", 10, val = 30); // => "x = 10, y = 30" |
@@ -119,10 +120,13 @@ macro_rules! vec { | ||
119 | 120 | /// ``` |
120 | 121 | #[macro_export] |
121 | 122 | #[stable(feature = "rust1", since = "1.0.0")] |
123 | +#[allow_internal_unstable(hint_must_use, liballoc_internals)] | |
122 | 124 | #[cfg_attr(not(test), rustc_diagnostic_item = "format_macro")] |
123 | 125 | macro_rules! format { |
124 | -($($arg:tt)*) => {{ | |
125 | -let res = crate::fmt::format(crate::fmt::format(crate::fmt::format(crate::__export::format_args!($($arg)*)); | |
126 | - res | |
127 | -}} | |
126 | +($($arg:tt)*) => { | |
127 | + $crate::__export::must_use({ | |
128 | +let res = crate::fmt::format(crate::fmt::format(crate::fmt::format(crate::__export::format_args!($($arg)*)); | |
129 | + res | |
130 | +}) | |
131 | +} | |
128 | 132 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -217,19 +217,19 @@ fn test_format_macro_interface() { | ||
217 | 217 | |
218 | 218 | // make sure that format! doesn't move out of local variables |
219 | 219 | let a = Box::new(3); |
220 | -format!("{a}"); | |
221 | -format!("{a}"); | |
220 | +let _ = format!("{a}"); | |
221 | +let _ = format!("{a}"); | |
222 | 222 | |
223 | 223 | // make sure that format! doesn't cause spurious unused-unsafe warnings when |
224 | 224 | // it's inside of an outer unsafe block |
225 | 225 | unsafe { |
226 | 226 | let a: isize = ::std::mem::transmute(3_usize); |
227 | -format!("{a}"); | |
227 | +let _ = format!("{a}"); | |
228 | 228 | } |
229 | 229 | |
230 | 230 | // test that trailing commas are acceptable |
231 | -format!("{}", "test",); | |
232 | -format!("{foo}", foo = "test",); | |
231 | +let _ = format!("{}", "test",); | |
232 | +let _ = format!("{foo}", foo = "test",); | |
233 | 233 | } |
234 | 234 | |
235 | 235 | // Basic test to make sure that we can invoke the `write!` macro with an |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -441,7 +441,7 @@ mod debug_map { | ||
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | -format!("{Foo:?}"); | |
444 | +let _ = format!("{Foo:?}"); | |
445 | 445 | } |
446 | 446 | |
447 | 447 | #[test] |
@@ -455,7 +455,7 @@ mod debug_map { | ||
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
458 | -format!("{Foo:?}"); | |
458 | +let _ = format!("{Foo:?}"); | |
459 | 459 | } |
460 | 460 | |
461 | 461 | #[test] |
@@ -469,7 +469,7 @@ mod debug_map { | ||
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | -format!("{Foo:?}"); | |
472 | +let _ = format!("{Foo:?}"); | |
473 | 473 | } |
474 | 474 | } |
475 | 475 |