]> gcc.gnu.org Git - gcc.git/commit
Method resolution must support multiple candidates
authorPhilip Herron <philip.herron@embecosm.com>
Thu, 13 Oct 2022 09:10:37 +0000 (10:10 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Thu, 13 Oct 2022 14:45:16 +0000 (15:45 +0100)
commit9bac2dbfe999b0dffea65b9a1b6ed0a257edf3c8
tree6493d2c0de6af90ffee13bb72e210465775491f4
parent3e7320510e7bb774295ecbd8089a9f51d6475959
Method resolution must support multiple candidates

This patch fixes bad method resolution in our operator_overload_9 case.
When we have a &mut reference to something and we deref we must resolve to
the mutable reference impl block. The interface we are using to resolve
methods is the can_eq interface which allows for permissive mutability
which means allowing for mutable reference being unified with an immutable
one. This meant we actual match against both the immutable and mutable
version leading to multiple candidate error.

The fix here adds a method resolution flag to the can_eq interface so that
we enforce mutability equality. The other hack is that we do not allow
can_eq of ParamTypes to generic Slices. I think there is some subtle thing
going on for that case. The Rustc method resolver actually filters the
impl blocks for reference types based looking up the relevant lang items
we need to do this as well but is a much larger refactor to our method
resolver which should be done seperately.

Fixes #1588
gcc/rust/typecheck/rust-autoderef.cc
gcc/rust/typecheck/rust-hir-dot-operator.cc
gcc/rust/typecheck/rust-hir-dot-operator.h
gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/rust/typecheck/rust-tyty-cmp.h
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h
gcc/testsuite/rust/compile/generics7.rs
gcc/testsuite/rust/execute/torture/operator_overload_9.rs
This page took 0.06366 seconds and 6 git commands to generate.