From: Philip Herron <[email protected]>

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]>
---
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/fb59a24364383561f5d00eec88af51e044df87ba

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

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

 .../typecheck/rust-hir-type-check-base.cc     |  4 ++
 .../rust/compile/issues/issue-4883.rs         | 46 +++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issues/issue-4883.rs

diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc 
b/gcc/rust/typecheck/rust-hir-type-check-base.cc
index c9e392039..52a353624 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 000000000..560290c64
--- /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
+}

base-commit: bd7540d5893bbe8d821dff75de1a06580637c654
-- 
2.55.0

Reply via email to