aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-lang.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-10-20 17:47:17 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-10-22 11:48:42 +0100
commitfe77d2d5747b0c9f44c01eba4f6898fbb2790f23 (patch)
treebe68921b507eb448d0573d9071e1daf628653214 /gcc/rust/rust-lang.cc
parent86ec0383d45b3339edd0583452d8bc3a0a3cddca (diff)
downloadgcc-fe77d2d5747b0c9f44c01eba4f6898fbb2790f23.zip
gcc-fe77d2d5747b0c9f44c01eba4f6898fbb2790f23.tar.gz
gcc-fe77d2d5747b0c9f44c01eba4f6898fbb2790f23.tar.bz2
Fix ICE when trying to resolve associated type from type bounds
When we have a generic function with specified type bounds this allows rust code to actually then look up the relevant bounds for associated types, functions or constants. This means at code generation the relevant associated mappings msut be setup such that we compile to the implementaiton if available or the default implementation if possible. The bug here was that the resolution for associated types were auto setting up the associated type mappings even when the receiver was generic. So for example: ```rust pub trait Foo { type A; fn bar(self) -> Self::A; } struct S(i32); impl Foo for S { type A = i32; fn bar(self) -> Self::A { self.0 } } fn test_bar<T: Foo>(x: T) -> T::A { x.bar() } ``` The generic function of test_bar was auto resolving the T::A to A=i32 since it found the type-bound Foo was specified and the only implementation of Foo is on S. This is usually the correct flow to auto setup these mappings but in the conjtext of a generic receiver this needs to still result in a Placeholder type of the bound Foo to type check correctly. Fixes: #744 #741
Diffstat (limited to 'gcc/rust/rust-lang.cc')
0 files changed, 0 insertions, 0 deletions