https://gcc.gnu.org/g:dcac75dfeea84f16b5deb559a552e98a739a3b68
commit r17-5140-gdcac75dfeea84f16b5deb559a552e98a739a3b68 Author: Philip Herron <[email protected]> Date: Thu Sep 17 17:24:08 2026 +0100 gccrs: Fix unconstrained when args are in the where clause Fixes Rust-GCC/gccrs#4883 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (walk_type_to_constrain): walk the generics as well gcc/testsuite/ChangeLog: * rust/compile/issues/issue-4883.rs: New test. Signed-off-by: Philip Herron <[email protected]> Diff: --- gcc/rust/typecheck/rust-hir-type-check-base.cc | 4 +++ gcc/testsuite/rust/compile/issues/issue-4883.rs | 46 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index c9e392039a3c..52a3536245a1 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc @@ -166,6 +166,10 @@ walk_type_to_constrain (std::set<HirId> &constrained_symbols, TyTy::BaseType &r) default: break; } + + if (r.has_substitutions_defined ()) + walk_types_to_constrain (constrained_symbols, + r.get_subst_argument_mappings ()); } bool diff --git a/gcc/testsuite/rust/compile/issues/issue-4883.rs b/gcc/testsuite/rust/compile/issues/issue-4883.rs new file mode 100644 index 000000000000..560290c64653 --- /dev/null +++ b/gcc/testsuite/rust/compile/issues/issue-4883.rs @@ -0,0 +1,46 @@ +// { dg-options "-w" } +#![feature(no_core, lang_items, unboxed_closures)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} + +pub trait Iterator2 { + type Item; +} + +#[lang = "fn_once"] +#[rustc_paren_sugar] +pub trait FnOnce<Args> { + #[lang = "fn_once_output"] + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +#[lang = "fn_mut"] +#[rustc_paren_sugar] +pub trait FnMut<Args>: FnOnce<Args> { + extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; +} + +pub struct FilterMap<I, F> { + iter: I, + f: F, +} + +impl<B, I: Iterator2, F> Iterator2 for FilterMap<I, F> +where + F: FnMut(I::Item) -> Option<B>, +{ + type Item = B; +} + +pub enum Option<T> { + None, + Some(T), +} + +fn main() -> i32 { + 0 +}
