[gccrs COMMIT] gccrs: walk the binding generic arguments for unconstrained checks
gerris.rs@gmail.com
gerris.rs@gmail.com
Tue Sep 8 12:15:41 GMT 2026
From: Philip Herron <herron.philip@googlemail.com>
Fixes Rust-GCC/gccrs#4862
Fixes Rust-GCC/gccrs#4863
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-base.cc: walk type bindings
gcc/testsuite/ChangeLog:
* rust/compile/issue-4862.rs: New test.
* rust/compile/issue-4863.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
---
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/1f4ef9937bb026beddbd8436924953785a8ff3f2
The commit has been mentioned in the following issue(s):
- Rust-GCC/gccrs#4862: https://github.com/Rust-GCC/gccrs/issues/4862
- Rust-GCC/gccrs#4863: https://github.com/Rust-GCC/gccrs/issues/4863
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4873
.../typecheck/rust-hir-type-check-base.cc | 11 +++++++++++
gcc/testsuite/rust/compile/issue-4862.rs | 11 +++++++++++
gcc/testsuite/rust/compile/issue-4863.rs | 19 +++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/issue-4862.rs
create mode 100644 gcc/testsuite/rust/compile/issue-4863.rs
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc
index b53232a57..faa6d5ea9 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc
@@ -197,6 +197,17 @@ TypeCheckBase::check_for_unconstrained (
walk_types_to_constrain (constrained_symbols, constraint_b);
walk_type_to_constrain (constrained_symbols, *reference);
+ for (const auto ¶m : params_to_constrain)
+ {
+ auto *ty = param.get_param_ty ();
+ for (const auto &bound : ty->get_specified_bounds ())
+ {
+ const auto &args = bound.get_substitution_arguments ();
+ for (const auto &binding : args.get_binding_args ())
+ walk_type_to_constrain (constrained_symbols, *binding.second);
+ }
+ }
+
// check for unconstrained
bool unconstrained = false;
for (auto &sym : symbols_to_constrain)
diff --git a/gcc/testsuite/rust/compile/issue-4862.rs b/gcc/testsuite/rust/compile/issue-4862.rs
new file mode 100644
index 000000000..17d9c3ca9
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4862.rs
@@ -0,0 +1,11 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+#[lang = "sized"]
+pub trait Sized {}
+trait Iterator {
+ type Item;
+}
+pub struct Wrapper<I>(I);
+impl<T, I: Iterator<Item = T>> Iterator for Wrapper<I> {
+ type Item = T;
+}
diff --git a/gcc/testsuite/rust/compile/issue-4863.rs b/gcc/testsuite/rust/compile/issue-4863.rs
new file mode 100644
index 000000000..2c7592790
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4863.rs
@@ -0,0 +1,19 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+#[lang = "sized"]
+pub trait Sized {}
+#[lang = "fn_once"]
+trait FnOnce<Args> {
+ #[lang = "fn_once_output"]
+ type Output;
+ extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+trait Iterator {
+ type Item;
+}
+pub struct OnceWith<F> {
+ pub f: F,
+}
+impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
+ type Item = A;
+}
base-commit: 305320a0fbcbb14f30488c807fd35c7d1a813880
--
2.55.0
More information about the Gcc-rust
mailing list