https://gcc.gnu.org/g:ea11d029071188caeb0cc575d1b41ffeb8a19bd1

commit r17-4318-gea11d029071188caeb0cc575d1b41ffeb8a19bd1
Author: Philip Herron <[email protected]>
Date:   Mon Aug 31 21:43:06 2026 +0100

    gccrs: Add hir lowering to trait item where clauses
    
    Fixes Rust-GCC/gccrs#4828
    
    gcc/rust/ChangeLog:
    
            * hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit): lower 
where clauses
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/issue-4828.rs: New test.
    
    Signed-off-by: Philip Herron <[email protected]>

Diff:
---
 gcc/rust/hir/rust-ast-lower-implitem.cc  |  5 +++++
 gcc/testsuite/rust/compile/issue-4828.rs | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/gcc/rust/hir/rust-ast-lower-implitem.cc 
b/gcc/rust/hir/rust-ast-lower-implitem.cc
index bb08c3c36fab..16a7c3b4368c 100644
--- a/gcc/rust/hir/rust-ast-lower-implitem.cc
+++ b/gcc/rust/hir/rust-ast-lower-implitem.cc
@@ -234,6 +234,11 @@ void
 ASTLowerTraitItem::visit (AST::Function &func)
 {
   std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+  where_clause_items.reserve (func.get_where_clause ().get_items ().size ());
+  for (auto &item : func.get_where_clause ().get_items ())
+    where_clause_items.emplace_back (
+      ASTLowerWhereClauseItem::translate (*item.get ()));
+
   HIR::WhereClause where_clause (std::move (where_clause_items));
   HIR::FunctionQualifiers qualifiers
     = lower_qualifiers (func.get_qualifiers ());
diff --git a/gcc/testsuite/rust/compile/issue-4828.rs 
b/gcc/testsuite/rust/compile/issue-4828.rs
new file mode 100644
index 000000000000..3dba752356be
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4828.rs
@@ -0,0 +1,18 @@
+#![feature(lang_items, no_core)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+trait IntoIterator {
+    type IntoIter;
+}
+
+pub struct Chain<A, B>(A, B);
+
+trait Iterator {
+    fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
+    where
+        Self: Sized,
+        U: IntoIterator;
+}

Reply via email to