From: Utkarsh Bahuguna <[email protected]>
Fn/FnMut/FnOnce bounds can produce FUNCTION segments, which
new_type_param did not handle.
Use reconstruct() for these segments instead of hitting
rust_unreachable().
Fixes Rust-GCC/gccrs#3939
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::new_type_param): Handle
FUNCTION segments.
gcc/testsuite/ChangeLog:
* rust/compile/issues/3939.rs: New test.
Signed-off-by: Utkarsh Bahuguna <[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/de2588c201627ca5f95623d78ad1738104833834
The commit has been mentioned in the following issue(s):
- Rust-GCC/gccrs#3939: https://github.com/Rust-GCC/gccrs/issues/3939
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4929
gcc/rust/ast/rust-ast-builder.cc | 7 +-----
gcc/testsuite/rust/compile/issues/3939.rs | 30 +++++++++++++++++++++++
2 files changed, 31 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/issues/3939.rs
diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc
index 6332ce2f5..09db66957 100644
--- a/gcc/rust/ast/rust-ast-builder.cc
+++ b/gcc/rust/ast/rust-ast-builder.cc
@@ -654,12 +654,7 @@ Builder::new_type_param (
break;
case TypePathSegment::FUNCTION:
- {
- rust_unreachable ();
- // TODO
- // const TypePathSegmentFunction &fn
- // = (const TypePathSegmentFunction &) (*seg.get ());
- }
+ segments.emplace_back (seg->reconstruct ());
break;
}
}
diff --git a/gcc/testsuite/rust/compile/issues/3939.rs
b/gcc/testsuite/rust/compile/issues/3939.rs
new file mode 100644
index 000000000..da253d9b6
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issues/3939.rs
@@ -0,0 +1,30 @@
+#![feature(no_core)]
+#![feature(lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[lang = "copy"]
+trait Copy {}
+
+#[lang = "fn_once"]
+trait FnOnce<Args> {
+ #[lang = "fn_once_output"]
+ type Output;
+
+ fn call_once(self, args: Args) -> Self::Output;
+}
+
+#[lang = "fn_mut"]
+trait FnMut<Args>: FnOnce<Args> {
+ fn call_mut(&mut self, args: Args) -> Self::Output;
+}
+
+#[lang = "fn"]
+trait Fn<Args>: FnMut<Args> {
+ fn call(&self, args: Args) -> Self::Output;
+}
+
+#[derive(Copy)]
+pub struct X<T, F: Fn(T) -> T>(T, F);
base-commit: d412d003391bba6476e17be629b1870491dadffc
--
2.55.0