From 37b51462dcf26dc40ac5d7e82acdfd4cbe754157 Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Wed, 10 Apr 2024 17:58:05 -0300 Subject: [PATCH] fix the array implementation using GAT --- rust/src/backgroundtask.rs | 8 ++-- rust/src/basicblock.rs | 12 +++--- rust/src/callingconvention.rs | 6 +-- rust/src/custombinaryview.rs | 8 ++-- rust/src/downloadprovider.rs | 8 ++-- rust/src/function.rs | 13 +++--- rust/src/linearview.rs | 6 +-- rust/src/metadata.rs | 6 +-- rust/src/platform.rs | 6 +-- rust/src/rc.rs | 76 +++++++++++++++++------------------ rust/src/references.rs | 14 ++++--- rust/src/relocation.rs | 8 ++-- rust/src/section.rs | 6 +-- rust/src/segment.rs | 6 +-- rust/src/string.rs | 6 +-- rust/src/symbol.rs | 6 +-- rust/src/types.rs | 38 +++++++++--------- 17 files changed, 120 insertions(+), 113 deletions(-) diff --git a/rust/src/backgroundtask.rs b/rust/src/backgroundtask.rs index 1eb090d7c..e62cfbcb0 100644 --- a/rust/src/backgroundtask.rs +++ b/rust/src/backgroundtask.rs @@ -112,13 +112,13 @@ unsafe impl CoreOwnedArrayProvider for BackgroundTask { } } -unsafe impl<'a> CoreArrayWrapper<'a> for BackgroundTask { - type Wrapped = Guard<'a, BackgroundTask>; +unsafe impl CoreArrayWrapper for BackgroundTask { + type Wrapped<'a> = Guard<'a, BackgroundTask>; - unsafe fn wrap_raw( + unsafe fn wrap_raw<'a>( raw: &'a *mut BNBackgroundTask, context: &'a (), - ) -> Guard<'a, BackgroundTask> { + ) -> Self::Wrapped<'a> { Guard::new(BackgroundTask::from_raw(*raw), context) } } diff --git a/rust/src/basicblock.rs b/rust/src/basicblock.rs index 73ad9362b..f28e596f1 100644 --- a/rust/src/basicblock.rs +++ b/rust/src/basicblock.rs @@ -76,10 +76,10 @@ unsafe impl<'a, C: 'a + BlockContext> CoreOwnedArrayProvider for Edge<'a, C> { } } -unsafe impl<'a, C: 'a + BlockContext> CoreArrayWrapper<'a> for Edge<'a, C> { - type Wrapped = Edge<'a, C>; +unsafe impl<'a, C: BlockContext> CoreArrayWrapper for Edge<'a, C> { + type Wrapped<'b> = Edge<'b, C> where 'a: 'b; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Edge<'a, C> { + unsafe fn wrap_raw<'b>(raw: &'b Self::Raw, context: &'b Self::Context) -> Self::Wrapped<'b> { let edge_target = Guard::new( BasicBlock::from_raw(raw.target, context.orig_block.context.clone()), raw, @@ -309,10 +309,10 @@ unsafe impl CoreOwnedArrayProvider for BasicBlock { } } -unsafe impl<'a, C: 'a + BlockContext> CoreArrayWrapper<'a> for BasicBlock { - type Wrapped = Guard<'a, BasicBlock>; +unsafe impl CoreArrayWrapper for BasicBlock { + type Wrapped<'a> = Guard<'a, BasicBlock> where C: 'a; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(BasicBlock::from_raw(*raw, context.clone()), context) } } diff --git a/rust/src/callingconvention.rs b/rust/src/callingconvention.rs index 815f4d42a..991b46a94 100644 --- a/rust/src/callingconvention.rs +++ b/rust/src/callingconvention.rs @@ -662,10 +662,10 @@ unsafe impl CoreOwnedArrayProvider for CallingConvention { } } -unsafe impl<'a, A: Architecture> CoreArrayWrapper<'a> for CallingConvention { - type Wrapped = Guard<'a, CallingConvention>; +unsafe impl CoreArrayWrapper for CallingConvention { + type Wrapped<'a> = Guard<'a, CallingConvention>; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new( CallingConvention { handle: *raw, diff --git a/rust/src/custombinaryview.rs b/rust/src/custombinaryview.rs index 956be9bdc..c69bad393 100644 --- a/rust/src/custombinaryview.rs +++ b/rust/src/custombinaryview.rs @@ -297,10 +297,12 @@ unsafe impl CoreOwnedArrayProvider for BinaryViewType { } } -unsafe impl<'a> CoreArrayWrapper<'a> for BinaryViewType { - type Wrapped = BinaryViewType; +unsafe impl CoreArrayWrapper for BinaryViewType { + // TODO there is nothing blocking the returned value from out-living the + // array, change it to &_ or Guard? + type Wrapped<'a> = BinaryViewType; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { BinaryViewType(*raw) } } diff --git a/rust/src/downloadprovider.rs b/rust/src/downloadprovider.rs index 97ebbdbcb..cc2437221 100644 --- a/rust/src/downloadprovider.rs +++ b/rust/src/downloadprovider.rs @@ -71,10 +71,12 @@ unsafe impl CoreOwnedArrayProvider for DownloadProvider { } } -unsafe impl<'a> CoreArrayWrapper<'a> for DownloadProvider { - type Wrapped = DownloadProvider; +unsafe impl CoreArrayWrapper for DownloadProvider { + // TODO there is nothing blocking the returned value from out-living the + // array, change it to &_ or Guard? + type Wrapped<'a> = DownloadProvider; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { DownloadProvider::from_raw(*raw) } } diff --git a/rust/src/function.rs b/rust/src/function.rs index 273a08612..d2f685dfb 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -30,7 +30,6 @@ pub use binaryninjacore_sys::BNAnalysisSkipReason as AnalysisSkipReason; pub use binaryninjacore_sys::BNFunctionAnalysisSkipOverride as FunctionAnalysisSkipOverride; pub use binaryninjacore_sys::BNFunctionUpdateType as FunctionUpdateType; - use std::hash::Hash; use std::{fmt, mem}; @@ -407,10 +406,10 @@ unsafe impl CoreOwnedArrayProvider for Function { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Function { - type Wrapped = Guard<'a, Function>; +unsafe impl CoreArrayWrapper for Function { + type Wrapped<'a> = Guard<'a, Function>; - unsafe fn wrap_raw(raw: &'a *mut BNFunction, context: &'a ()) -> Guard<'a, Function> { + unsafe fn wrap_raw<'a>(raw: &'a *mut BNFunction, context: &'a ()) -> Self::Wrapped<'a> { Guard::new(Function { handle: *raw }, context) } } @@ -461,10 +460,10 @@ unsafe impl CoreOwnedArrayProvider for AddressRange { } } -unsafe impl<'a> CoreArrayWrapper<'a> for AddressRange { - type Wrapped = &'a AddressRange; +unsafe impl CoreArrayWrapper for AddressRange { + type Wrapped<'a> = &'a AddressRange; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { mem::transmute(raw) } } diff --git a/rust/src/linearview.rs b/rust/src/linearview.rs index 09968fc68..31b05ad27 100644 --- a/rust/src/linearview.rs +++ b/rust/src/linearview.rs @@ -423,10 +423,10 @@ unsafe impl CoreOwnedArrayProvider for LinearDisassemblyLine { } } -unsafe impl<'a> CoreArrayWrapper<'a> for LinearDisassemblyLine { - type Wrapped = Guard<'a, LinearDisassemblyLine>; +unsafe impl CoreArrayWrapper for LinearDisassemblyLine { + type Wrapped<'a> = Guard<'a, LinearDisassemblyLine>; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(LinearDisassemblyLine::from_raw(raw), _context) } } diff --git a/rust/src/metadata.rs b/rust/src/metadata.rs index e29789e52..35f3b8124 100644 --- a/rust/src/metadata.rs +++ b/rust/src/metadata.rs @@ -343,10 +343,10 @@ unsafe impl CoreOwnedArrayProvider for Metadata { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Metadata { - type Wrapped = Guard<'a, Metadata>; +unsafe impl CoreArrayWrapper for Metadata { + type Wrapped<'a> = Guard<'a, Metadata>; - unsafe fn wrap_raw(raw: &'a *mut BNMetadata, context: &'a ()) -> Guard<'a, Metadata> { + unsafe fn wrap_raw<'a>(raw: &'a *mut BNMetadata, context: &'a ()) -> Self::Wrapped<'a> { Guard::new(Metadata::from_raw(*raw), context) } } diff --git a/rust/src/platform.rs b/rust/src/platform.rs index 3df5e7c47..42e2f80cc 100644 --- a/rust/src/platform.rs +++ b/rust/src/platform.rs @@ -373,10 +373,10 @@ unsafe impl CoreOwnedArrayProvider for Platform { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Platform { - type Wrapped = Guard<'a, Platform>; +unsafe impl CoreArrayWrapper for Platform { + type Wrapped<'a> = Guard<'a, Platform>; - unsafe fn wrap_raw(raw: &'a *mut BNPlatform, context: &'a ()) -> Guard<'a, Platform> { + unsafe fn wrap_raw<'a>(raw: &'a *mut BNPlatform, context: &'a ()) -> Self::Wrapped<'a> { debug_assert!(!raw.is_null()); Guard::new(Platform { handle: *raw }, context) } diff --git a/rust/src/rc.rs b/rust/src/rc.rs index cdcae1792..eaf8e5d26 100644 --- a/rust/src/rc.rs +++ b/rust/src/rc.rs @@ -196,14 +196,12 @@ pub unsafe trait CoreOwnedArrayProvider: CoreArrayProvider { unsafe fn free(raw: *mut Self::Raw, count: usize, context: &Self::Context); } -pub unsafe trait CoreArrayWrapper<'a>: CoreArrayProvider -where - Self::Raw: 'a, - Self::Context: 'a, -{ - type Wrapped: 'a; +pub unsafe trait CoreArrayWrapper: CoreArrayProvider { + type Wrapped<'a> + where + Self: 'a; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped; + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a>; } pub struct Array { @@ -250,16 +248,16 @@ impl Array

{ } } -impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreOwnedArrayProvider> Array

{ +impl Array

{ #[inline] - pub fn get(&'a self, index: usize) -> P::Wrapped { + pub fn get(&self, index: usize) -> P::Wrapped<'_> { unsafe { let backing = slice::from_raw_parts(self.contents, self.count); P::wrap_raw(&backing[index], &self.context) } } - pub fn iter(&'a self) -> ArrayIter<'a, P> { + pub fn iter(&self) -> ArrayIter

{ ArrayIter { it: unsafe { slice::from_raw_parts(self.contents, self.count).iter() }, context: &self.context, @@ -267,8 +265,8 @@ impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreOwnedArrayProvider> Array

{ } } -impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreOwnedArrayProvider> IntoIterator for &'a Array

{ - type Item = P::Wrapped; +impl<'a, P: CoreArrayWrapper + CoreOwnedArrayProvider> IntoIterator for &'a Array

{ + type Item = P::Wrapped<'a>; type IntoIter = ArrayIter<'a, P>; fn into_iter(self) -> Self::IntoIter { @@ -323,16 +321,16 @@ impl ArrayGuard

{ } } -impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreArrayProvider> ArrayGuard

{ +impl ArrayGuard

{ #[inline] - pub fn get(&'a self, index: usize) -> P::Wrapped { + pub fn get(&self, index: usize) -> P::Wrapped<'_> { unsafe { let backing = slice::from_raw_parts(self.contents, self.count); P::wrap_raw(&backing[index], &self.context) } } - pub fn iter(&'a self) -> ArrayIter<'a, P> { + pub fn iter(&self) -> ArrayIter

{ ArrayIter { it: unsafe { slice::from_raw_parts(self.contents, self.count).iter() }, context: &self.context, @@ -340,8 +338,8 @@ impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreArrayProvider> ArrayGuard

{ } } -impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreArrayProvider> IntoIterator for &'a ArrayGuard

{ - type Item = P::Wrapped; +impl<'a, P: CoreArrayWrapper + CoreArrayProvider> IntoIterator for &'a ArrayGuard

{ + type Item = P::Wrapped<'a>; type IntoIter = ArrayIter<'a, P>; fn into_iter(self) -> Self::IntoIter { @@ -351,27 +349,27 @@ impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreArrayProvider> IntoIterator for &'a pub struct ArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: CoreArrayWrapper, { it: slice::Iter<'a, P::Raw>, context: &'a P::Context, } -unsafe impl<'a, P> Send for ArrayIter<'a, P> +unsafe impl

Send for ArrayIter<'_, P> where - P: CoreArrayWrapper<'a>, + P: CoreArrayWrapper, P::Context: Sync, { } impl<'a, P> Iterator for ArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, { - type Item = P::Wrapped; + type Item = P::Wrapped<'a>; #[inline] - fn next(&mut self) -> Option { + fn next(&mut self) -> Option { self.it .next() .map(|r| unsafe { P::wrap_raw(r, self.context) }) @@ -385,7 +383,7 @@ where impl<'a, P> ExactSizeIterator for ArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, { #[inline] fn len(&self) -> usize { @@ -395,10 +393,10 @@ where impl<'a, P> DoubleEndedIterator for ArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, { #[inline] - fn next_back(&mut self) -> Option { + fn next_back(&mut self) -> Option> { self.it .next_back() .map(|r| unsafe { P::wrap_raw(r, self.context) }) @@ -412,20 +410,20 @@ use rayon::prelude::*; use rayon::iter::plumbing::*; #[cfg(feature = "rayon")] -impl<'a, P> Array

+impl

Array

where - P: 'a + CoreArrayWrapper<'a> + CoreOwnedArrayProvider, + P: CoreArrayWrapper + CoreOwnedArrayProvider, P::Context: Sync, - P::Wrapped: Send, + for<'a> P::Wrapped<'a>: Send, { - pub fn par_iter(&'a self) -> ParArrayIter<'a, P> { + pub fn par_iter(&self) -> ParArrayIter<'_, P> { ParArrayIter { it: self.iter() } } } #[cfg(feature = "rayon")] pub struct ParArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, ArrayIter<'a, P>: Send, { it: ArrayIter<'a, P>, @@ -434,11 +432,11 @@ where #[cfg(feature = "rayon")] impl<'a, P> ParallelIterator for ParArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, - P::Wrapped: Send, + P: 'a + CoreArrayWrapper, + P::Wrapped<'a>: Send, ArrayIter<'a, P>: Send, { - type Item = P::Wrapped; + type Item = P::Wrapped<'a>; fn drive_unindexed(self, consumer: C) -> C::Result where @@ -455,8 +453,8 @@ where #[cfg(feature = "rayon")] impl<'a, P> IndexedParallelIterator for ParArrayIter<'a, P> where - P: 'a + CoreArrayWrapper<'a>, - P::Wrapped: Send, + P: 'a + CoreArrayWrapper, + P::Wrapped<'a>: Send, ArrayIter<'a, P>: Send, { fn drive(self, consumer: C) -> C::Result @@ -481,7 +479,7 @@ where #[cfg(feature = "rayon")] struct ArrayIterProducer<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, ArrayIter<'a, P>: Send, { it: ArrayIter<'a, P>, @@ -490,10 +488,10 @@ where #[cfg(feature = "rayon")] impl<'a, P> Producer for ArrayIterProducer<'a, P> where - P: 'a + CoreArrayWrapper<'a>, + P: 'a + CoreArrayWrapper, ArrayIter<'a, P>: Send, { - type Item = P::Wrapped; + type Item = P::Wrapped<'a>; type IntoIter = ArrayIter<'a, P>; fn into_iter(self) -> ArrayIter<'a, P> { diff --git a/rust/src/references.rs b/rust/src/references.rs index 76ac44934..a30f3f5e2 100644 --- a/rust/src/references.rs +++ b/rust/src/references.rs @@ -64,10 +64,12 @@ unsafe impl CoreOwnedArrayProvider for CodeReference { } } -unsafe impl<'a> CoreArrayWrapper<'a> for CodeReference { - type Wrapped = CodeReference; +unsafe impl CoreArrayWrapper for CodeReference { + // TODO there is nothing blocking the returned value from out-living the + // array, change it to Guard? + type Wrapped<'a> = CodeReference; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { CodeReference::new(raw) } } @@ -85,10 +87,10 @@ unsafe impl CoreOwnedArrayProvider for DataReference { } } -unsafe impl<'a> CoreArrayWrapper<'a> for DataReference { - type Wrapped = DataReference; +unsafe impl CoreArrayWrapper for DataReference { + type Wrapped<'a> = DataReference; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { DataReference { address: *raw } } } diff --git a/rust/src/relocation.rs b/rust/src/relocation.rs index f9cbb3c52..47ec2ac0f 100644 --- a/rust/src/relocation.rs +++ b/rust/src/relocation.rs @@ -227,9 +227,11 @@ unsafe impl CoreOwnedArrayProvider for Relocation { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Relocation { - type Wrapped = Relocation; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { +unsafe impl CoreArrayWrapper for Relocation { + // TODO there is nothing blocking the returned value from out-living the + // array, change it to &_ or Guard? + type Wrapped<'a> = Relocation; + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Relocation(*raw) } } diff --git a/rust/src/section.rs b/rust/src/section.rs index 25e8ea5d0..06d09fcaa 100644 --- a/rust/src/section.rs +++ b/rust/src/section.rs @@ -179,10 +179,10 @@ unsafe impl CoreOwnedArrayProvider for Section { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Section { - type Wrapped = Guard<'a, Section>; +unsafe impl CoreArrayWrapper for Section { + type Wrapped<'a> = Guard<'a, Section>; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(Section::from_raw(*raw), context) } } diff --git a/rust/src/segment.rs b/rust/src/segment.rs index 2de785c5f..32f9db3ab 100644 --- a/rust/src/segment.rs +++ b/rust/src/segment.rs @@ -209,10 +209,10 @@ unsafe impl CoreOwnedArrayProvider for Segment { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Segment { - type Wrapped = Guard<'a, Segment>; +unsafe impl CoreArrayWrapper for Segment { + type Wrapped<'a> = Guard<'a, Segment>; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(Segment::from_raw(*raw), context) } } diff --git a/rust/src/string.rs b/rust/src/string.rs index 1011ca498..75942da91 100644 --- a/rust/src/string.rs +++ b/rust/src/string.rs @@ -169,10 +169,10 @@ unsafe impl CoreOwnedArrayProvider for BnString { } } -unsafe impl<'a> CoreArrayWrapper<'a> for BnString { - type Wrapped = &'a str; +unsafe impl CoreArrayWrapper for BnString { + type Wrapped<'a> = &'a str; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { CStr::from_ptr(*raw).to_str().unwrap() } } diff --git a/rust/src/symbol.rs b/rust/src/symbol.rs index cf4c3b107..bdf0d8552 100644 --- a/rust/src/symbol.rs +++ b/rust/src/symbol.rs @@ -335,10 +335,10 @@ unsafe impl CoreOwnedArrayProvider for Symbol { } } -unsafe impl<'a> CoreArrayWrapper<'a> for Symbol { - type Wrapped = Guard<'a, Symbol>; +unsafe impl CoreArrayWrapper for Symbol { + type Wrapped<'a> = Guard<'a, Symbol>; - unsafe fn wrap_raw(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(Symbol::from_raw(*raw), context) } } diff --git a/rust/src/types.rs b/rust/src/types.rs index 2a2a50d42..43d48b3fd 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1453,10 +1453,10 @@ unsafe impl CoreOwnedArrayProvider for NamedTypedVariable { } } -unsafe impl<'a> CoreArrayWrapper<'a> for NamedTypedVariable { - type Wrapped = ManuallyDrop; +unsafe impl CoreArrayWrapper for NamedTypedVariable { + type Wrapped<'a> = ManuallyDrop; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { ManuallyDrop::new(NamedTypedVariable { var: raw.var, ty: raw.type_, @@ -2348,10 +2348,10 @@ unsafe impl CoreOwnedArrayProvider for QualifiedName { } } -unsafe impl<'a> CoreArrayWrapper<'a> for QualifiedName { - type Wrapped = &'a QualifiedName; +unsafe impl CoreArrayWrapper for QualifiedName { + type Wrapped<'a> = &'a QualifiedName; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { mem::transmute(raw) } } @@ -2390,10 +2390,10 @@ unsafe impl CoreOwnedArrayProvider for QualifiedNameAndType { } } -unsafe impl<'a> CoreArrayWrapper<'a> for QualifiedNameAndType { - type Wrapped = &'a QualifiedNameAndType; +unsafe impl CoreArrayWrapper for QualifiedNameAndType { + type Wrapped<'a> = &'a QualifiedNameAndType; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { mem::transmute(raw) } } @@ -2436,10 +2436,10 @@ unsafe impl CoreOwnedArrayProvider for QualifiedNameTypeAndId { } } -unsafe impl<'a> CoreArrayWrapper<'a> for QualifiedNameTypeAndId { - type Wrapped = &'a QualifiedNameTypeAndId; +unsafe impl CoreArrayWrapper for QualifiedNameTypeAndId { + type Wrapped<'a> = &'a QualifiedNameTypeAndId; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { mem::transmute(raw) } } @@ -2497,10 +2497,11 @@ unsafe impl CoreOwnedArrayProvider for NameAndType { } } -unsafe impl<'a, S: 'a + BnStrCompatible> CoreArrayWrapper<'a> for NameAndType { - type Wrapped = &'a NameAndType; +unsafe impl CoreArrayWrapper for NameAndType { + type Wrapped<'a> = &'a NameAndType where S: 'a; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + // TODO this is not always valid, because the type is not transparent mem::transmute(raw) } } @@ -2544,10 +2545,11 @@ unsafe impl CoreOwnedArrayProvider for DataVariable { } } -unsafe impl<'a> CoreArrayWrapper<'a> for DataVariable { - type Wrapped = &'a DataVariable; +unsafe impl CoreArrayWrapper for DataVariable { + type Wrapped<'a> = &'a DataVariable; - unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + // TODO this is not always valid, because the type is not transparent mem::transmute(raw) } }