diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-15 19:55:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-15 19:55:06 -0400 |
| commit | ee8194002e47b1a6103c7a8f5d592c625b5efba7 (patch) | |
| tree | 05019e5a7dbf634a378f590134da92b2918000e1 /src/libcore | |
| parent | caf10b5ffe6977e79f8d5f1bb407d99d2b015b4a (diff) | |
| parent | 0c981e0a8a01426dbcac895d67dd33db7f5b6ff4 (diff) | |
| download | rust-ee8194002e47b1a6103c7a8f5d592c625b5efba7.tar.gz rust-ee8194002e47b1a6103c7a8f5d592c625b5efba7.zip | |
Rollup merge of #62639 - immunant:invariant_valistimpl, r=eddyb
Make VaListImpl<'f> invariant over the 'f lifetime After doing some research on variance and going back to look at `VaList` and `VaListImpl`, I realized that `VaList<'a, 'f>` is invariant over the `'f` lifetime (and covariant over `'a`), but `VaListImpl<'f>` isn't invariant but probably should be. This patch makes `VaListImpl<'f>` invariant over `'f`. r? @eddyb cc @dlrobertson
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ffi.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index 4f87cc506ef..eda0e7c518c 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -60,7 +60,10 @@ impl fmt::Debug for c_void { #[lang = "va_list"] pub struct VaListImpl<'f> { ptr: *mut c_void, - _marker: PhantomData<&'f c_void>, + + // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to + // the region of the function it's defined in + _marker: PhantomData<&'f mut &'f c_void>, } #[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), @@ -96,7 +99,7 @@ pub struct VaListImpl<'f> { vr_top: *mut c_void, gr_offs: i32, vr_offs: i32, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// PowerPC ABI implementation of a `va_list`. @@ -114,7 +117,7 @@ pub struct VaListImpl<'f> { reserved: u16, overflow_arg_area: *mut c_void, reg_save_area: *mut c_void, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// x86_64 ABI implementation of a `va_list`. @@ -131,7 +134,7 @@ pub struct VaListImpl<'f> { fp_offset: i32, overflow_arg_area: *mut c_void, reg_save_area: *mut c_void, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// asm.js ABI implementation of a `va_list`. @@ -148,7 +151,7 @@ pub struct VaListImpl<'f> { #[lang = "va_list"] pub struct VaListImpl<'f> { inner: [crate::mem::MaybeUninit<i32>; 4], - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } #[cfg(all(target_arch = "asmjs", not(windows)))] |
