Add compile_fail test for SyncOnceCell's dropck issue.
This commit is contained in:
parent
578e714393
commit
e56ea68db5
1 changed files with 19 additions and 1 deletions
|
@ -47,7 +47,25 @@ pub struct SyncOnceCell<T> {
|
||||||
once: Once,
|
once: Once,
|
||||||
// Whether or not the value is initialized is tracked by `state_and_queue`.
|
// Whether or not the value is initialized is tracked by `state_and_queue`.
|
||||||
value: UnsafeCell<MaybeUninit<T>>,
|
value: UnsafeCell<MaybeUninit<T>>,
|
||||||
// Make sure dropck understands we're dropping T in our Drop impl.
|
/// `PhantomData` to make sure dropck understands we're dropping T in our Drop impl.
|
||||||
|
///
|
||||||
|
/// ```compile_fail,E0597
|
||||||
|
/// #![feature(once_cell)]
|
||||||
|
///
|
||||||
|
/// use std::lazy::SyncOnceCell;
|
||||||
|
///
|
||||||
|
/// struct A<'a>(&'a str);
|
||||||
|
///
|
||||||
|
/// impl<'a> Drop for A<'a> {
|
||||||
|
/// fn drop(&mut self) {}
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let cell = SyncOnceCell::new();
|
||||||
|
/// {
|
||||||
|
/// let s = String::new();
|
||||||
|
/// let _ = cell.set(A(&s));
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
_marker: PhantomData<T>,
|
_marker: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue