[COMMITTED 41/83] gccrs: Add hir lowering to trait item where clauses
arthur.cohen@opensrcsec.com
arthur.cohen@opensrcsec.com
Wed Sep 16 12:30:00 GMT 2026
From: Philip Herron <herron.philip@googlemail.com>
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 <herron.philip@googlemail.com>
---
gcc/rust/hir/rust-ast-lower-implitem.cc | 5 +++++
gcc/testsuite/rust/compile/issue-4828.rs | 18 ++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/issue-4828.rs
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.cc b/gcc/rust/hir/rust-ast-lower-implitem.cc
index bb08c3c36fa..16a7c3b4368 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 00000000000..3dba752356b
--- /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;
+}
--
2.50.1
More information about the Gcc-rust
mailing list