aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-pattern.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-04-15 15:27:18 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-04-15 21:23:28 +0100
commitad9e185e15fcfea8d23b03acccc26dab4e45bf45 (patch)
tree612e6376f4d9b62256d95686000c569270a35c22 /gcc/rust/backend/rust-compile-pattern.cc
parentd17e0aa7695ddb383e0a4fc43185e2ab42c81703 (diff)
downloadgcc-ad9e185e15fcfea8d23b03acccc26dab4e45bf45.zip
gcc-ad9e185e15fcfea8d23b03acccc26dab4e45bf45.tar.gz
gcc-ad9e185e15fcfea8d23b03acccc26dab4e45bf45.tar.bz2
Fix bad projection substitution
When we have a Trait such as: ``` pub unsafe trait SliceIndex<T> { type Output; fn index(self, slice: &T) -> &Self::Output; } unsafe impl<T> SliceIndex<[T]> for Range<usize> { type Output = [T]; fn index(self, slice: &[T]) -> &[T] { unsafe { &*self.get_unchecked(slice) } } } ``` When we need to verify that the impl index is compatible fir SliceIndex we get the Type info for the trait-item which is: fn<Self, T> index(self: Self, slice: &T) -> &<placeholder=projection<T>=[T]> This projection gets setup and the types are substituted with Self=Range<usize> and T=[T] which ended up substituting the projection twice resulting in a recursive slice [T=[T]]. In this case the associated type is already setup for the placeholder and does not require generic substitution. This means we added a flag to the substitution generic arguments mappings to handle this case. This patch also addressed memory corruption with the TypeBoundPredicate as part of the debugging of this issue which resulted in a segv when trying to debug the mappings. The issue was the copy constructors needed to update the used argument mappings each time since the substitution param mappings are copied and the addresses no longer exist, valgrind was great here to find this issue. Fixes #1120
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.cc')
0 files changed, 0 insertions, 0 deletions