You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gccrs: Add missing bounds checks on the associated impl
Before this require_b<T: B> (T) only checked for S<Bad> implement B and
it early accepted the
impl<T: A> B for S<T>
But we need to validate the impl's bound after we bind the arguments being
used on the generic impl. So when we do a call-expr/method-call expr we are
binding to that impl and we need to validate. When we do that we know that
impl T = Bad and we walk the impl generic params T: A apply the subst for
Bad: A where its is not implemented and we fail and return.
Fixes#4678
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: add emit_errors option
* typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::bind_impl_for_projection): new
(AssociatedImplTrait::bind_impl_for_bound): call new validate function
* typecheck/rust-type-util.cc (lookup_associated_impl_block): make this more generic
* typecheck/rust-tyty-call.cc (validate_call_argument_associated_impl_bounds): new
(TypeCheckCallExpr::visit): for each call arg validate and bind
(TypeCheckMethodCallExpr::check): likewise
gcc/testsuite/ChangeLog:
* rust/compile/issue-4678.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
0 commit comments