Skip to content

Commit

Permalink
Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obk
Browse files Browse the repository at this point in the history
Mark format! with must_use hint

Uses unstable feature rust-lang/rust#94745

Part of #126475

First contribution to rust, please let me know if the blessing of tests is correct
Thanks `@bjorn3` for the help
  • Loading branch information
matthiaskrgr authored Jul 8, 2024
2 parents 27c53bd + 83fae11 commit 9504311
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/pass/intptrcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn cast_dangling() {
fn format() {
// Pointer string formatting! We can't check the output as it changes when libstd changes,
// but we can make sure Miri does not error.
format!("{:?}", &mut 13 as *mut _);
let _ = format!("{:?}", &mut 13 as *mut _);
}

fn transmute() {
Expand All @@ -52,7 +52,7 @@ fn ptr_bitops1() {
let one = bytes.as_ptr().wrapping_offset(1);
let three = bytes.as_ptr().wrapping_offset(3);
let res = (one as usize) | (three as usize);
format!("{}", res);
let _ = format!("{}", res);
}

fn ptr_bitops2() {
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/packed_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn test_derive() {
assert_eq!(x.partial_cmp(&y).unwrap(), x.cmp(&y));
x.hash(&mut DefaultHasher::new());
P::default();
format!("{:?}", x);
let _ = format!("{:?}", x);
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions tests/pass/shims/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn test_errors() {
// Opening a non-existing file should fail with a "not found" error.
assert_eq!(ErrorKind::NotFound, File::open(&path).unwrap_err().kind());
// Make sure we can also format this.
format!("{0}: {0:?}", File::open(&path).unwrap_err());
let _ = format!("{0}: {0:?}", File::open(&path).unwrap_err());
// Removing a non-existing file should fail with a "not found" error.
assert_eq!(ErrorKind::NotFound, remove_file(&path).unwrap_err().kind());
// Reading the metadata of a non-existing file should fail with a "not found" error.
Expand Down Expand Up @@ -301,5 +301,5 @@ fn test_from_raw_os_error() {
let error = Error::from_raw_os_error(code);
assert!(matches!(error.kind(), ErrorKind::Uncategorized));
// Make sure we can also format this.
format!("{error:?}");
let _ = format!("{error:?}");
}
2 changes: 1 addition & 1 deletion tests/pass/shims/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn main() {
panic!("unsupported OS")
};
let err = io::Error::from_raw_os_error(raw_os_error);
format!("{err}: {err:?}");
let _ = format!("{err}: {err:?}");
}
4 changes: 2 additions & 2 deletions tests/pass/vecdeque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn main() {
}

// Regression test for Debug impl's
format!("{:?} {:?}", dst, dst.iter());
format!("{:?}", VecDeque::<u32>::new().iter());
let _ = format!("{:?} {:?}", dst, dst.iter());
let _ = format!("{:?}", VecDeque::<u32>::new().iter());

for a in dst {
assert_eq!(*a, 2);
Expand Down

0 comments on commit 9504311

Please sign in to comment.