Update tests and add known problems to docs
This commit is contained in:
parent
4a4f998c39
commit
e70817e712
4 changed files with 43 additions and 14 deletions
|
|
@ -3,16 +3,24 @@
|
|||
struct S;
|
||||
|
||||
fn main() {
|
||||
let f = drop;
|
||||
let manual = std::mem::ManuallyDrop::new(S);
|
||||
let f = std::mem::drop;
|
||||
let g = std::mem::ManuallyDrop::drop;
|
||||
let mut manual1 = std::mem::ManuallyDrop::new(S);
|
||||
let mut manual2 = std::mem::ManuallyDrop::new(S);
|
||||
let mut manual3 = std::mem::ManuallyDrop::new(S);
|
||||
let mut manual4 = std::mem::ManuallyDrop::new(S);
|
||||
|
||||
// These lines will not drop `S`
|
||||
// These lines will not drop `S` and should be linted
|
||||
drop(std::mem::ManuallyDrop::new(S));
|
||||
f(manual);
|
||||
drop(manual1);
|
||||
|
||||
// These lines will
|
||||
// FIXME: this line is not linted, though it should be
|
||||
f(manual2);
|
||||
|
||||
// These lines will drop `S` and should be okay.
|
||||
unsafe {
|
||||
std::mem::ManuallyDrop::drop(std::mem::ManuallyDrop::new(S));
|
||||
std::mem::ManuallyDrop::drop(manual);
|
||||
std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S));
|
||||
std::mem::ManuallyDrop::drop(&mut manual3);
|
||||
g(&mut manual4);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19
tests/ui/undropped_manually_drops.stderr
Normal file
19
tests/ui/undropped_manually_drops.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error: the inner value of this ManuallyDrop will not be dropped
|
||||
--> $DIR/undropped_manually_drops.rs:14:5
|
||||
|
|
||||
LL | drop(std::mem::ManuallyDrop::new(S));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::undropped-manually-drops` implied by `-D warnings`
|
||||
= help: to drop a `ManuallyDrop<T>`, use std::mem::ManuallyDrop::drop
|
||||
|
||||
error: the inner value of this ManuallyDrop will not be dropped
|
||||
--> $DIR/undropped_manually_drops.rs:15:5
|
||||
|
|
||||
LL | drop(manual1);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: to drop a `ManuallyDrop<T>`, use std::mem::ManuallyDrop::drop
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue