aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-04-19 16:33:48 +0000
committerGitHub <noreply@github.com>2022-04-19 16:33:48 +0000
commit4152743451a73591fa60bc52f0b28447ef4a8878 (patch)
tree9f14d6ba86b46d6eb778df421be3927e99d9da0e /gcc/rust/parse/rust-parse-impl.h
parent5b14291b54fe72407b840631511d1c3bb07df22e (diff)
parentad9e185e15fcfea8d23b03acccc26dab4e45bf45 (diff)
downloadgcc-4152743451a73591fa60bc52f0b28447ef4a8878.zip
gcc-4152743451a73591fa60bc52f0b28447ef4a8878.tar.gz
gcc-4152743451a73591fa60bc52f0b28447ef4a8878.tar.bz2
Merge #1121
1121: Fix bad projection substitution r=philberty a=philberty 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 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
0 files changed, 0 insertions, 0 deletions