From: Philip Herron <[email protected]>

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]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/39b53aaf7fd854dbc61146d62145da5ded61095f

The commit has been mentioned in the following issue(s):
 - Rust-GCC/gccrs#4828: https://github.com/Rust-GCC/gccrs/issues/4828

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4830

 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 bb08c3c36..16a7c3b43 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 000000000..3dba75235
--- /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;
+}

base-commit: 40ce8273c361de572b4c60bbabc11c9a2c1eb97b
-- 
2.55.0

Reply via email to