diff options
| author | Philipp Krones <hello@philkrones.com> | 2023-08-24 21:32:12 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2023-08-24 21:32:12 +0200 |
| commit | 7137a09806171e75b54c5fb70bf629a55ff04d8b (patch) | |
| tree | dcf4ea07d714ea0b97469e3e98c0cb74f92821ce /src/tools/clippy/tests/ui/repl_uninit.rs | |
| parent | aa5dbee3ebff8703456e8be3b5fb368fc68fe0d1 (diff) | |
| parent | 080b587854a73f2a8cbaecff1884860a78e2ff37 (diff) | |
| download | rust-7137a09806171e75b54c5fb70bf629a55ff04d8b.tar.gz rust-7137a09806171e75b54c5fb70bf629a55ff04d8b.zip | |
Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyup
Diffstat (limited to 'src/tools/clippy/tests/ui/repl_uninit.rs')
| -rw-r--r-- | src/tools/clippy/tests/ui/repl_uninit.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/repl_uninit.rs b/src/tools/clippy/tests/ui/repl_uninit.rs index 6c7e2b854dc..01bdf79e642 100644 --- a/src/tools/clippy/tests/ui/repl_uninit.rs +++ b/src/tools/clippy/tests/ui/repl_uninit.rs @@ -1,6 +1,6 @@ #![allow(deprecated, invalid_value, clippy::uninit_assumed_init)] #![warn(clippy::mem_replace_with_uninit)] - +//@no-rustfix use std::mem; fn might_panic<X>(x: X) -> X { @@ -13,18 +13,22 @@ fn main() { // the following is UB if `might_panic` panics unsafe { let taken_v = mem::replace(&mut v, mem::uninitialized()); + //~^ ERROR: replacing with `mem::uninitialized()` + //~| NOTE: `-D clippy::mem-replace-with-uninit` implied by `-D warnings` let new_v = might_panic(taken_v); std::mem::forget(mem::replace(&mut v, new_v)); } unsafe { let taken_v = mem::replace(&mut v, mem::MaybeUninit::uninit().assume_init()); + //~^ ERROR: replacing with `mem::MaybeUninit::uninit().assume_init()` let new_v = might_panic(taken_v); std::mem::forget(mem::replace(&mut v, new_v)); } unsafe { let taken_v = mem::replace(&mut v, mem::zeroed()); + //~^ ERROR: replacing with `mem::zeroed()` let new_v = might_panic(taken_v); std::mem::forget(mem::replace(&mut v, new_v)); } @@ -37,5 +41,6 @@ fn main() { // this is still not OK, because uninit let taken_u = unsafe { mem::replace(uref, mem::uninitialized()) }; + //~^ ERROR: replacing with `mem::uninitialized()` *uref = taken_u + 1; } |
