aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-03-27 14:22:48 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-03-27 15:23:52 +0000
commit1a2f56a9d529f39ccbd72ec9fa5b5ccb8c3e6737 (patch)
tree45891472b7dab057130f08b10bd91b85e4e70176 /gcc/rust
parent34b0a681598d52de442a0a21c3a7df20bf1485bc (diff)
downloadgcc-1a2f56a9d529f39ccbd72ec9fa5b5ccb8c3e6737.zip
gcc-1a2f56a9d529f39ccbd72ec9fa5b5ccb8c3e6737.tar.gz
gcc-1a2f56a9d529f39ccbd72ec9fa5b5ccb8c3e6737.tar.bz2
gccrs: Fix ICE when doing method resolution on trait predicates
We need to ensure we are adding methods to the possible candidates. Fixes Rust-GCC#3554 gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc: gcc/testsuite/ChangeLog: * rust/compile/issue-3554-1.rs: New test. * rust/compile/issue-3554-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-dot-operator.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-hir-dot-operator.cc b/gcc/rust/typecheck/rust-hir-dot-operator.cc
index 31034ee..e1535a2 100644
--- a/gcc/rust/typecheck/rust-hir-dot-operator.cc
+++ b/gcc/rust/typecheck/rust-hir-dot-operator.cc
@@ -472,8 +472,11 @@ MethodResolver::get_predicate_items (
if (ty->get_kind () == TyTy::TypeKind::FNDEF)
{
TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
- predicate_candidate candidate{lookup, fnty};
- predicate_items.push_back (candidate);
+ if (fnty->is_method ())
+ {
+ predicate_candidate candidate{lookup, fnty};
+ predicate_items.push_back (candidate);
+ }
}
}